Austin Group Defect Tracker

Aardvark Mark III


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0000384 [1003.1(2008)/Issue 7] Base Definitions and Headers Objection Omission 2011-02-22 18:52 2016-07-28 15:10
Reporter eblake View Status public  
Assigned To ajosey
Priority normal Resolution Rejected  
Status Closed  
Name Eric Blake
Organization Red Hat
User Reference ebb.va_end
Section stdarg.h
Page Number 339
Line Number 11403
Interp Status ---
Final Accepted Text
Summary 0000384: the stdarg macros should not modify errno
Description Line 25639 [XSH errno] is explicit that "The setting of errno after a
successful call to a function is unspecified unless the description of
that function specifies that errno shall not be modified." However, none
of the stdarg macros (va_start, va_copy, va_arg, va_end) mention their
interaction with errno, which renders common code like this undefined,
all because the successful va_end() invocation occurs between the point
of the failure and the actual error reporting:

// error-checking variant of snprintf
int xsnprintf(char *str, size_t size, const char *fmt, ...)
{
    va_list ap;
    int ret;

    va_start(ap, fmt);
    ret = vsprintf(str, size, fmt, ap);
    va_end(ap);
    if (ret < 0) {
        perror("vsprintf failed");
        exit(EXIT_FAILURE);
    }
    return ret;
}

Typically, all va_* macros have no effect on errno, so we might as well
require that, which would make the above example conforming.
Desired Action After line 11403 [XCU <stdarg.h> DESCRIPTION], add a sentence with CX shading:

The four macros defined in this header shall not change the value of errno.
Tags No tags attached.
Attached Files

- Relationships
related to 0000401Closedajosey ferror should not modify errno 
related to 0000385Resolvedajosey free should not change errno on success 
related to 0000447Closedajosey strerror_r and strerror_l error checking 
related to 0000397Closedajosey setbuf and errno 
related to 0000511Closedajosey getuid and friends should not modify errno 

-  Notes
(0000691)
eblake (manager)
2011-03-10 16:39

The intention is to match the C Standard, where the wording is:

(7.5 para 3) "The value of errno may be set to nonzero by a library
function call whether or not there is an error, provided the use of
errno is not documented in the description of the function in this
International Standard."

The use of "library function call" here makes it clear that it
does not apply to macros such as va_start().

It is worth creating a new bug that cleans up the use of the word
"function" throughout the standard (in some instances, such as htonl
on page 1097, the word "function" was used in the mathematical sense
of an interface that defines a mapping even though that interface
is only a C macro, rather than in the C sense of external linkage).

- Issue History
Date Modified Username Field Change
2011-02-22 18:52 eblake New Issue
2011-02-22 18:52 eblake Status New => Under Review
2011-02-22 18:52 eblake Assigned To => ajosey
2011-02-22 18:52 eblake Name => Eric Blake
2011-02-22 18:52 eblake Organization => Red Hat
2011-02-22 18:52 eblake User Reference => ebb.va_end
2011-02-22 18:52 eblake Section => stdarg.h
2011-02-22 18:52 eblake Page Number => 339
2011-02-22 18:52 eblake Line Number => 11403
2011-02-22 18:52 eblake Interp Status => ---
2011-03-10 16:39 eblake Note Added: 0000691
2011-03-10 16:40 eblake Status Under Review => Closed
2011-03-10 16:40 eblake Resolution Open => Rejected
2016-07-28 15:06 eblake Relationship added related to 0000401
2016-07-28 15:06 eblake Relationship added related to 0000385
2016-07-28 15:07 eblake Relationship added related to 0000447
2016-07-28 15:08 eblake Relationship added related to 0000397
2016-07-28 15:10 eblake Relationship added related to 0000511


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker