Re: [uclibc-ng-devel] stdio fudging errno ?

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

 



* Vineet Gupta:

> Here's a simple test case which shows the problem:
>
> 	#define _GNU_SOURCE
> 	#include <stdio.h>
> 	#include <stdlib.h>
> 	#include <errno.h>
>
> 	void main(void)
> 	{
>         	const char *this_func = "finite";
> 	        char *test_name;
>
>         	errno = 0;
> 	        if (asprintf (&test_name, "%s (%s)", this_func, "my-str") == -1)
> 			abort ();
>
> 	        printf("%d\n", errno);	// <-- prints 11
> 	}
>
> The errno unconditionally being set to EAGAIN seems to have been
> introduced in commit 568ceebf6adfc58c64a95133311268db6 ("Fix
> infinite loop when fopencookie custom write returns 0 on error")
> bakc in 2016.

For functions specified by standards, successful calls can alter errno
unless specified otherwise.  asprintf is not a standardized function,
but it is reasonable to expect that a similar rule applies.

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/linux-snps-arc



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux