In one C application I'm maintaining, there are a number of calls to fread()
.
The return value is checked for the number of bytes read, and stops when it reaches 0
, meaning the file/stream end has been reached.
Now, that's not completely correct. fread()
may also return 0
if an error happens. A way to check for that condition is to call feof()
for example.
I can certainly add all these tests everywhere fread()
is invoked. But that's not the point : it would be some kind of "blind fix". I need a test case to observe and repeat the problem, and observe the correction as part of CI tests.
So far, I have found none. I have much less problems for fwrite()
, where it's comparatively easier to create problems, but for fread()
, I haven't found a reliable way to test issues without also impacting fopen()
, which is a completely different situation already pretty well tested.
Any suggestion welcomed.
Aucun commentaire:
Enregistrer un commentaire