diff options
author | Jim Meyering <meyering@redhat.com> | 2008-06-24 14:16:35 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2008-06-24 14:20:25 +0200 |
commit | edd260625eeefbc4605922aa28305b31a7f15260 (patch) | |
tree | 4ad06ec80325b85d08f7dcbf09fd98142204cf65 /src | |
parent | 1e61cd8481704cb211760d9cc03b87a860d932d9 (diff) | |
download | idutils-edd260625eeefbc4605922aa28305b31a7f15260.tar.gz idutils-edd260625eeefbc4605922aa28305b31a7f15260.tar.bz2 idutils-edd260625eeefbc4605922aa28305b31a7f15260.zip |
avoid warnings, adjust for const-correctness
* libidu/scanners.c (long_options_c, long_options_asm)
(long_options_text, long_options_perl): Add initializers.
* src/fid.c (long_options): Add initializers.
* src/fnid.c (long_options): Add initializers.
* src/lid.c (ATTRIBUTE_UNUSED): Define.
(long_options): Add initializers.
(report_nothing): Mark parameter as unused.
(get_editor_argv, report_edit): Adjust for const-correctness.
* src/mkid.c (long_options): Add initializers.
(report_statistics): Don't subtract "void*" pointers. Cast to "char*".
* src/xtokid.c (long_options): Add initializers.
Diffstat (limited to 'src')
-rw-r--r-- | src/fid.c | 2 | ||||
-rw-r--r-- | src/fnid.c | 2 | ||||
-rw-r--r-- | src/lid.c | 19 | ||||
-rw-r--r-- | src/mkid.c | 8 | ||||
-rw-r--r-- | src/xtokid.c | 2 |
5 files changed, 20 insertions, 13 deletions
@@ -63,7 +63,7 @@ static struct option const long_options[] = { "file", required_argument, 0, 'f' }, { "help", no_argument, &show_help, 1 }, { "version", no_argument, &show_version, 1 }, - { 0 } + {NULL, 0, NULL, 0} }; void @@ -61,7 +61,7 @@ static struct option const long_options[] = { "separator", required_argument, 0, 'S' }, { "help", no_argument, &show_help, 1 }, { "version", no_argument, &show_version, 1 }, - { 0 } + {NULL, 0, NULL, 0} }; static void @@ -45,6 +45,10 @@ #include "lid.h" #include "progname.h" +#ifndef ATTRIBUTE_UNUSED +# define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +#endif + typedef void (*report_func_t) (char const *name, struct file_link **flinkv); typedef int (*query_func_t) (char const *arg, report_func_t); @@ -229,7 +233,7 @@ static struct option const long_options[] = { "octal", no_argument, 0, 'o' }, { "help", no_argument, &show_help, 1 }, { "version", no_argument, &show_version, 1 }, - { 0 } + {NULL, 0, NULL, 0} }; void @@ -618,11 +622,12 @@ report_grep (char const *name, struct file_link **flinkv) } static char ** -get_editor_argv(char *fullstring, int* argc) +get_editor_argv(char const *fullstring, int* argc) { int i; - char *mark; + char const *mark; char **argv; + char *p; static int already_called; assert(already_called == 0); /* call only once, otherwise leaks */ @@ -636,8 +641,8 @@ get_editor_argv(char *fullstring, int* argc) } argv = xmalloc(sizeof(char *) * (*argc + 1)); - fullstring = xstrdup(fullstring); - argv[0] = strtok(fullstring, " "); + p = xstrdup(fullstring); + argv[0] = strtok(p, " "); for (i = 1; i < (*argc + 1); i++) { argv[i] = strtok(NULL, " "); @@ -650,7 +655,7 @@ get_editor_argv(char *fullstring, int* argc) static void report_edit (char const *name, struct file_link **flinkv) { - static char *editor; /* editor program name from env */ + static char const *editor; /* editor program name from env */ static char **editor_argv; /* editor base arguments from env */ static int editor_argc; @@ -804,7 +809,7 @@ editit: } static void -report_nothing (char const *name, struct file_link **flinkv) +report_nothing (char const *name, struct file_link **flinkv ATTRIBUTE_UNUSED) { if (key_style != ks_none) puts (name); @@ -142,7 +142,7 @@ static struct option const long_options[] = { "statistics", no_argument, 0, 's' }, { "help", no_argument, &show_help, 1 }, { "version", no_argument, &show_version, 1 }, - { 0 } + {NULL, 0, NULL, 0} }; static void @@ -555,8 +555,10 @@ report_statistics (void) printf (_("Tokens=%ld, "), occurrences); printf (_("Bytes=%ld Kb, "), input_chars / 1024); printf (_("Heap=%llu+%llu Kb, "), - (unsigned long long) (heap_after_scan - heap_after_walk) / 1024, - (unsigned long long) (heap_after_walk - heap_initial) / 1024); + (unsigned long long) ((char *) heap_after_scan + - (char *) heap_after_walk) / 1024, + (unsigned long long) ((char *) heap_after_walk + - (char *) heap_initial) / 1024); printf (_("Output=%ld (%ld tok, %ld hit)\n"), output_length, tokens_length, hits_length); diff --git a/src/xtokid.c b/src/xtokid.c index 36aa356..c45d5be 100644 --- a/src/xtokid.c +++ b/src/xtokid.c @@ -61,7 +61,7 @@ static struct option const long_options[] = { "prune", required_argument, 0, 'p' }, { "help", no_argument, &show_help, 1 }, { "version", no_argument, &show_version, 1 }, - { 0 } + {NULL, 0, NULL, 0} }; static void |