View Issue Details

IDProjectCategoryView StatusLast Update
00003971003.1(2008)/Issue 7System Interfacespublic2013-04-16 13:06
Reportereblake Assigned Toajosey  
PrioritynormalSeverityObjectionTypeError
Status ClosedResolutionAccepted As Marked 
NameEric Blake
OrganizationRed Hat
User Referenceebb.setbuf
Sectionsetbuf
Page Number1855
Line Number59282
Interp Status---
Final Accepted TextSee 0000397:0000799
Summary0000397: setbuf and errno
DescriptionSince setbuf is required to be implemented in terms of setvbuf, and the
latter is documented as being permitted to set errno on failure, we must
document how to detect the same failure for setbuf.
Desired ActionAt line 59278 [XSH setbuf DESCRIPTION], add a paragraph with CX shading:

setbuf() shall not modify errno on success. Since no value is returned, an
application wishing to check for error situations should set errno to 0,
call setbuf(), then check errno.

At line 59282 [ERRORS], replace "None." with:

    [CX] Refer to [xref to setvbuf()]. [/CX]
Tagstc1-2008

Relationships

related to 0000384 Closedajosey the stdarg macros should not modify errno 

Activities

geoffclare

2011-05-27 09:39

manager   bugnote:0000798

This fixes the discrepancy between setbuf() and setvbuf() for errors,
but it also introduces one for successful calls, since setvbuf() is
allowed to set errno on success.

I suggest the following changes instead of the Desired Action:

At line 59272 [XSH setbuf DESCRIPTION] change:

    Except that it returns no value, the function call:

    setbuf(stream, buf)

    shall be equivalent to:

    setvbuf(stream, buf, _IOFBF, BUFSIZ)

    if buf is not a null pointer, or to:

    setvbuf(stream, buf, _IONBF, BUFSIZ)

    if buf is a null pointer.

to:

    The function call:

    setbuf(stream, buf)

    shall be equivalent to:

    (void) setvbuf(stream, buf, _IOFBF, BUFSIZ)

    if buf is not a null pointer, or to:

    (void) setvbuf(stream, buf, _IONBF, BUFSIZ)

    if buf is a null pointer, [CX]except that setbuf() shall not
    modify errno on success[/CX].

    [CX]Since no value is returned, an application wishing to check for
    error situations should set errno to 0, call setbuf(), then check
    errno.[/CX]

At line 59282 [ERRORS], replace "None." with:

    [CX]Refer to [xref to setvbuf()].[/CX]

nick

2011-06-02 15:26

manager   bugnote:0000799

Since existing implementations do not work to preserve errno values in the case of no error, the following changes should be made instead:

At p 1855 line 59282, change ERRORS text from:
 No errors are defined.
To:
 Although the setvbuf() interface may set errno in defined ways, the value of errno after a call to setbuf() is unspecified.

At line 59289 add to Application Usage:
 Since errno is not required to be unchanged on success, in order to correctly detect and possibly recover from errors, applications should use setvbuf() instead of setbuf().

Issue History

Date Modified Username Field Change
2011-03-17 18:36 eblake New Issue
2011-03-17 18:36 eblake Status New => Under Review
2011-03-17 18:36 eblake Assigned To => ajosey
2011-03-17 18:36 eblake Name => Eric Blake
2011-03-17 18:36 eblake Organization => Red Hat
2011-03-17 18:36 eblake User Reference => ebb.setbuf
2011-03-17 18:36 eblake Section => setbuf
2011-03-17 18:36 eblake Page Number => 1855
2011-03-17 18:36 eblake Line Number => 59282
2011-03-17 18:36 eblake Interp Status => ---
2011-05-26 15:50 msbrown Tag Attached: tc1-2008
2011-05-26 15:50 msbrown Status Under Review => Resolved
2011-05-26 15:50 msbrown Resolution Open => Accepted
2011-05-27 09:39 geoffclare Note Added: 0000798
2011-05-27 09:39 geoffclare Status Resolved => Under Review
2011-05-27 09:39 geoffclare Resolution Accepted => Reopened
2011-06-02 15:26 nick Note Added: 0000799
2011-06-02 15:29 nick Final Accepted Text => See 0000397:0000799
2011-06-02 15:29 nick Status Under Review => Resolved
2011-06-02 15:29 nick Resolution Reopened => Accepted As Marked
2013-04-16 13:06 ajosey Status Resolved => Closed
2016-07-28 15:08 eblake Relationship added related to 0000384