Re: Confused by segfault with legitimate call to strerror(3) on amd64 / sysctl (3) setting `odd' errno's
- From: Christoph Mallon <christoph.mallon@xxxxxx>
- Date: Fri, 16 Jan 2009 11:21:22 +0100
Christian Kandeler schrieb:
On Friday 16 January 2009 09:53, Christoph Mallon wrote:
intThe use of errno is wrong. printf might change errno.
main() {
int mib[4];
size_t len;
if (sysctlnametomib("kern.ipc.shmmax", mib, &len) != 0) {
printf("Errno: %d\n", errno);
errx(errno, "Error: %s", strerror(errno));
I don't think printf() can set errno. And even if it could, it
Of course it can. See ISO/IEC 9899:1999 (E) §7.5:3.
wouldn't matter, because C has call-by-value semantics.
This has nothing to do with call-by-value. errno is read (even twice!) *after* the call to printf().
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"
- Follow-Ups:
- References:
- Confused by segfault with legitimate call to strerror(3) on amd64 / sysctl(3) setting `odd' errno's
- From: Garrett Cooper
- Re: Confused by segfault with legitimate call to strerror(3) on amd64 / sysctl(3) setting `odd' errno's
- From: Christoph Mallon
- Re: Confused by segfault with legitimate call to strerror(3) on amd64 / sysctl (3) setting `odd' errno's
- From: Christian Kandeler
- Confused by segfault with legitimate call to strerror(3) on amd64 / sysctl(3) setting `odd' errno's
- Prev by Date: Re: Confused by segfault with legitimate call to strerror(3) on amd64 / sysctl (3) setting `odd' errno's
- Next by Date: Re: Confused by segfault with legitimate call to strerror(3) on amd64 / sysctl (3) setting `odd' errno's
- Previous by thread: Re: Confused by segfault with legitimate call to strerror(3) on amd64 / sysctl (3) setting `odd' errno's
- Next by thread: Re: Confused by segfault with legitimate call to strerror(3) on amd64 / sysctl (3) setting `odd' errno's
- Index(es):
Relevant Pages
|