diff options
| author | Maxim Konovalov <maxim@FreeBSD.org> | 2006-12-06 12:00:26 +0000 |
|---|---|---|
| committer | Maxim Konovalov <maxim@FreeBSD.org> | 2006-12-06 12:00:26 +0000 |
| commit | 37716191a8160cf1165faa96759636d4cdb4e8c2 (patch) | |
| tree | 0477696cf833ef7684fa9aa9b1169b054a2a45d0 /usr.bin/getconf | |
| parent | 8b0a738288f8e63f247c75ec1d1055b2d9509492 (diff) | |
Notes
Diffstat (limited to 'usr.bin/getconf')
| -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 0ba45a0e3ce3..5f88db6cbe18 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 |
