Warns fixes. Mainly unused headers/params/vars removal, but also
some malloc cleanup.
This commit is contained in:
parent
b842ac21d6
commit
a272cd3af0
@ -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;
|
||||
|
@ -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 "";
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user