diff options
Diffstat (limited to 'misc/lnstat.c')
-rw-r--r-- | misc/lnstat.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/misc/lnstat.c b/misc/lnstat.c index 264c9531..863fd4d9 100644 --- a/misc/lnstat.c +++ b/misc/lnstat.c @@ -56,10 +56,8 @@ static struct option opts[] = { static int usage(char *name, int exit_code) { fprintf(stderr, "%s Version %s\n", name, LNSTAT_VERSION); - fprintf(stderr, "Copyright (C) 2004 by Harald Welte " - "<laforge@gnumonks.org>\n"); - fprintf(stderr, "This program is free software licensed under GNU GPLv2" - "\nwith ABSOLUTELY NO WARRANTY.\n\n"); + fprintf(stderr, "Copyright (C) 2004 by Harald Welte <laforge@gnumonks.org>\n"); + fprintf(stderr, "This program is free software licensed under GNU GPLv2\nwith ABSOLUTELY NO WARRANTY.\n\n"); fprintf(stderr, "Parameters:\n"); fprintf(stderr, "\t-V --version\t\tPrint Version of Program\n"); fprintf(stderr, "\t-c --count <count>\t" @@ -145,14 +143,13 @@ static int map_field_params(struct lnstat_file *lnstat_files, if (++j >= MAX_FIELDS - 1) { fprintf(stderr, - "WARN: MAX_FIELDS (%d) reached," - " truncating number of keys\n", + "WARN: MAX_FIELDS (%d) reached, truncating number of keys\n", MAX_FIELDS); goto full; } } } - full: +full: fps->num = j; return 1; } @@ -181,14 +178,12 @@ static struct table_hdr *build_hdr_string(struct lnstat_file *lnstat_files, struct field_params *fps, int linewidth) { - int h,i; + int h, i; static struct table_hdr th; int ofs = 0; - for (i = 0; i < HDR_LINES; i++) { - th.hdr[i] = malloc(HDR_LINE_LENGTH); - memset(th.hdr[i], 0, HDR_LINE_LENGTH); - } + for (i = 0; i < HDR_LINES; i++) + th.hdr[i] = calloc(1, HDR_LINE_LENGTH); for (i = 0; i < fps->num; i++) { char *cname, *fname = fps->params[i].lf->name; @@ -269,7 +264,7 @@ int main(int argc, char **argv) num_req_files = 1; } - while ((c = getopt_long(argc, argv,"Vc:djpf:h?i:k:s:w:", + while ((c = getopt_long(argc, argv, "Vc:djpf:h?i:k:s:w:", opts, NULL)) != -1) { int len = 0; char *tmp, *tok; @@ -303,8 +298,7 @@ int main(int argc, char **argv) tok = strtok(NULL, ",")) { if (fp.num >= MAX_FIELDS) { fprintf(stderr, - "WARN: too many keys" - " requested: (%d max)\n", + "WARN: too many keys requested: (%d max)\n", MAX_FIELDS); break; } @@ -356,7 +350,7 @@ int main(int argc, char **argv) if (!header) exit(1); - if (interval < 1 ) + if (interval < 1) interval = 1; for (i = 0; i < count || !count; i++) { |