NetBSD-Bugs archive

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

lib/41567: posix_memalign(3) taints errno when it shouldn't.

>Number:         41567
>Category:       lib
>Synopsis:       posix_memalign(3) taints errno when it shouldn't.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jun 10 08:15:00 +0000 2009
>Originator:     Stathis Kamperis
>Release:        NetBSD 5.0_STABLE
Aristotle University of Thessaloniki
NetBSD voyager 5.0_STABLE NetBSD 5.0_STABLE (MYGENERIC) #4: Sat May 23 15:45:44 
EEST 2009  root@voyager:/usr/obj/sys/arch/i386/compile/MYGENERIC i386

posix_memalign(3) is supposed to return an error value, not set the errno 
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>

int main(void)
        void *ptr;
        int old_errno;

         * Save old errno value to see if posix_memalign() messes with it
         * (error codes are supposed to be returned, not be saved to errno).
        old_errno = errno;

        /* Alignment parameter is not a power of 2. */
        assert(posix_memalign(&ptr, 1 + (sizeof(void *) << 5), 100) == EINVAL);
        assert(old_errno == errno);


        return (EXIT_SUCCESS);


Home | Main Index | Thread Index | Old Index