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

Bug#616627: stdio functions should not be declared __wur (ignoring return value of ‘fwrite’, declared with attribute warn_unused_result)



Hi again,

Jonathan Nieder wrote:

> Unfortunately glibc marks fwrite --- but oddly not the other stdio
> output functions --- with __wur (which expands to
> __attribute__((__warn_unused_result__)) when optimization is enabled
> and the _FORTIFY_SOURCE feature is in use).

An alternative fix would be to make this configurable with another
macro (for example, _FORTIFY_STDIO_SOURCE).  In that case, putchar,
printf, etc would need to be annotated with the same

	__wur_stdio

attribute as fwrite, so programs that have declared they want to
employ the

	if (putchar('H') == EOF ||
	    printf("el") < 0 ||
	    fwrite("lo\n", 3, 1, stdout) != 1)
		... handle error ...

style would have sufficient checks to employ it consistently.



Reply to: