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 | |
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')
-rw-r--r-- | usr.bin/getconf/confstr.gperf | 4 | ||||
-rw-r--r-- | usr.bin/getconf/fake-gperf.awk | 6 | ||||
-rw-r--r-- | usr.bin/getconf/getconf.c | 17 | ||||
-rw-r--r-- | usr.bin/getconf/limits.gperf | 4 | ||||
-rw-r--r-- | usr.bin/getconf/pathconf.gperf | 7 | ||||
-rw-r--r-- | usr.bin/getconf/progenv.gperf | 4 | ||||
-rw-r--r-- | usr.bin/getconf/sysconf.gperf | 5 |
7 files changed, 19 insertions, 28 deletions
diff --git a/usr.bin/getconf/confstr.gperf b/usr.bin/getconf/confstr.gperf index 14ad5f2..c629987 100644 --- a/usr.bin/getconf/confstr.gperf +++ b/usr.bin/getconf/confstr.gperf @@ -15,7 +15,7 @@ /* * Override gperf's built-in external scope. */ -static const struct map *in_word_set(const char *str, unsigned int len); +static const struct map *in_word_set(const char *str); /* * The Standard seems a bit ambiguous over whether the POSIX_V6_* @@ -58,7 +58,7 @@ find_confstr(const char *name, int *key) { const struct map *rv; - rv = in_word_set(name, strlen(name)); + rv = in_word_set(name); if (rv != NULL) { if (rv->valid) { *key = rv->key; diff --git a/usr.bin/getconf/fake-gperf.awk b/usr.bin/getconf/fake-gperf.awk index 2705d6a..96fcd3c 100644 --- a/usr.bin/getconf/fake-gperf.awk +++ b/usr.bin/getconf/fake-gperf.awk @@ -20,8 +20,6 @@ state == 1 { print; next; } } /^%%$/ && state == 0 { state = 2; - print "#include <stddef.h>"; - print "#include <string.h>"; if (struct_seen !~ /^$/) { print "static const struct", struct_seen, "wordlist[] = {"; } else { @@ -36,11 +34,11 @@ state == 1 { print; next; } } /^%%$/ && state == 2 { state = 3; - print "\t{ NULL }"; + print "\t{ NULL, 0, 0 }"; print "};"; print "#define\tNWORDS\t(sizeof(wordlist)/sizeof(wordlist[0]) - 1)"; print "static const struct map *"; - print "in_word_set(const char *word, unsigned int len)"; + print "in_word_set(const char *word)"; print "{"; print "\tconst struct", struct_seen, "*mp;"; print ""; 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); } } diff --git a/usr.bin/getconf/limits.gperf b/usr.bin/getconf/limits.gperf index bb8ef0d..68e0d65 100644 --- a/usr.bin/getconf/limits.gperf +++ b/usr.bin/getconf/limits.gperf @@ -15,7 +15,7 @@ /* * Override gperf's built-in external scope. */ -static const struct map *in_word_set(const char *str, unsigned int len); +static const struct map *in_word_set(const char *str); %} struct map { const char *name; intmax_t value; int valid; }; @@ -106,7 +106,7 @@ find_limit(const char *name, intmax_t *value) { const struct map *rv; - rv = in_word_set(name, strlen(name)); + rv = in_word_set(name); if (rv != NULL) { if (rv->valid) { *value = rv->value; diff --git a/usr.bin/getconf/pathconf.gperf b/usr.bin/getconf/pathconf.gperf index 60c05d4..e8b8365 100644 --- a/usr.bin/getconf/pathconf.gperf +++ b/usr.bin/getconf/pathconf.gperf @@ -7,7 +7,6 @@ #include <sys/types.h> -#include <limits.h> #include <string.h> #include <unistd.h> @@ -16,10 +15,10 @@ /* * Override gperf's built-in external scope. */ -static const struct map *in_word_set(const char *str, unsigned int len); +static const struct map *in_word_set(const char *str); %} -struct map { char *name; int key; int valid; }; +struct map { const char *name; int key; int valid; }; %% FILESIZEBITS, _PC_FILESIZEBITS LINK_MAX, _PC_LINK_MAX @@ -51,7 +50,7 @@ find_pathconf(const char *name, int *key) { const struct map *rv; - rv = in_word_set(name, strlen(name)); + rv = in_word_set(name); if (rv != NULL) { if (rv->valid) { *key = rv->key; diff --git a/usr.bin/getconf/progenv.gperf b/usr.bin/getconf/progenv.gperf index 64c9b4c..cfbde66 100644 --- a/usr.bin/getconf/progenv.gperf +++ b/usr.bin/getconf/progenv.gperf @@ -15,7 +15,7 @@ /* * Override gperf's built-in external scope. */ -static const struct map *in_word_set(const char *str, unsigned int len); +static const struct map *in_word_set(const char *str); /* * The Standard seems a bit ambiguous over whether the POSIX_V6_* @@ -55,7 +55,7 @@ find_progenv(const char *name, const char **alt_path) { const struct map *rv; - rv = in_word_set(name, strlen(name)); + rv = in_word_set(name); if (rv != NULL) { if (rv->valid) { *alt_path = rv->alt_path; diff --git a/usr.bin/getconf/sysconf.gperf b/usr.bin/getconf/sysconf.gperf index 1c9d2bc..ae88464 100644 --- a/usr.bin/getconf/sysconf.gperf +++ b/usr.bin/getconf/sysconf.gperf @@ -7,7 +7,6 @@ #include <sys/types.h> -#include <limits.h> #include <string.h> #include <unistd.h> @@ -16,7 +15,7 @@ /* * Override gperf's built-in external scope. */ -static const struct map *in_word_set(const char *str, unsigned int len); +static const struct map *in_word_set(const char *str); %} struct map { const char *name; int key; int valid; }; @@ -138,7 +137,7 @@ find_sysconf(const char *name, int *key) { const struct map *rv; - rv = in_word_set(name, strlen(name)); + rv = in_word_set(name); if (rv != NULL) { if (rv->valid) { *key = rv->key; |