diff options
author | markm <markm@FreeBSD.org> | 2003-08-22 17:32:07 +0000 |
---|---|---|
committer | markm <markm@FreeBSD.org> | 2003-08-22 17:32:07 +0000 |
commit | 39e9b9e98923adef2448e1ac49af7bd905d2d72f (patch) | |
tree | 1eb050875892779ca4712d66dce6d99317516b72 /usr.bin/getconf/getconf.c | |
parent | 0ab867f1c2e75dea5b91d280648a2d35e96cddec (diff) | |
download | FreeBSD-src-39e9b9e98923adef2448e1ac49af7bd905d2d72f.zip FreeBSD-src-39e9b9e98923adef2448e1ac49af7bd905d2d72f.tar.gz |
Warns fixes. Mainly unused headers/params/vars removal, but also
some malloc cleanup.
Diffstat (limited to 'usr.bin/getconf/getconf.c')
-rw-r--r-- | usr.bin/getconf/getconf.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/usr.bin/getconf/getconf.c b/usr.bin/getconf/getconf.c index 61c1853..0ba45a0 100644 --- a/usr.bin/getconf/getconf.c +++ b/usr.bin/getconf/getconf.c @@ -138,24 +138,19 @@ main(int argc, char **argv) static void do_confstr(const char *name, int key) { - char *buf; size_t len; len = confstr(key, 0, 0); if (len == (size_t)-1) err(EX_OSERR, "confstr: %s", name); - if (len == 0) { + if (len == 0) printf("undefined\n"); - } else { - buf = malloc(len); - if (buf != NULL) { - confstr(key, buf, len); - printf("%s\n", buf); - free(buf); - } - else - err(EX_OSERR, "malloc: confstr"); + else { + char buf[len + 1]; + + confstr(key, buf, len); + printf("%s\n", buf); } } |