diff options
author | maxim <maxim@FreeBSD.org> | 2006-12-06 12:00:26 +0000 |
---|---|---|
committer | maxim <maxim@FreeBSD.org> | 2006-12-06 12:00:26 +0000 |
commit | ee86f7872a19a9af8c7d540f035fd38ca238ebe6 (patch) | |
tree | 0477696cf833ef7684fa9aa9b1169b054a2a45d0 /usr.bin | |
parent | d8a0af2579fffb39a23b2a1113ed580e8c80a2a3 (diff) | |
download | FreeBSD-src-ee86f7872a19a9af8c7d540f035fd38ca238ebe6.zip FreeBSD-src-ee86f7872a19a9af8c7d540f035fd38ca238ebe6.tar.gz |
o confstr(3) returns 0 on error. Check the return value accordingly.
PR: misc/106414
MFC after: 1 week
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/getconf/getconf.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/usr.bin/getconf/getconf.c b/usr.bin/getconf/getconf.c index 0ba45a0..5f88db6 100644 --- a/usr.bin/getconf/getconf.c +++ b/usr.bin/getconf/getconf.c @@ -139,19 +139,23 @@ static void do_confstr(const char *name, int key) { size_t len; + int savederr; + savederr = errno; + errno = 0; len = confstr(key, 0, 0); - if (len == (size_t)-1) - err(EX_OSERR, "confstr: %s", name); - - if (len == 0) - printf("undefined\n"); - else { + if (len == 0) { + if (errno) + err(EX_OSERR, "confstr: %s", name); + else + printf("undefined\n"); + } else { char buf[len + 1]; confstr(key, buf, len); printf("%s\n", buf); } + errno = savederr; } static void |