NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/45587: rewind(3) errno lossage

>Number:         45587
>Category:       lib
>Synopsis:       rewind(3) errno lossage
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 07 14:25:00 +0000 2011
>Originator:     David A. Holland
>Release:        NetBSD 5.99.49 (20110411)
System: NetBSD macaran 5.99.49 NetBSD 5.99.49 (MACARAN) #8: Mon Apr 11 19:54:18 
EDT 2011 dholland@macaran:/usr/src/sys/arch/amd64/compile/MACARAN amd64
Architecture: x86_64
Machine: amd64

The man page for rewind(3) says:

   Since the rewind() function does not return an error code,
   applications need to clear errno before calling it in order to
   detect errors.

Since in general code is allowed to (and does) leave garbage in errno
when succeeding, any function that's going to allow this method of
error checking needs to take precautions to make sure it works.
Unfortunately, rewind doesn't.

If this is going to be a supported method of checking whether rewind
failed, it should save errno on entry and restore it except on
explicit failure.

Note that since rewind is supposed to clear the FILE's error flag, it
isn't possible to use ferror() to check for error, and it's defined by
C to return void, so I guess clearing and testing errno is the only
possible way to check for error... but maybe it shouldn't be supported
anyway. It's certainly not required by C99, although I haven't checked


man page / code / standards reading.


save/restore errno as above.

Home | Main Index | Thread Index | Old Index