aboutsummaryrefslogtreecommitdiff
path: root/argp
diff options
context:
space:
mode:
authorAlejandro Colomar <alx@kernel.org>2024-11-16 16:51:31 +0100
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2024-11-25 16:45:59 -0300
commit53fcdf5f743aa9b02972eec658e66f96d6a63386 (patch)
treee1bd3ed90d89027abe4b8ba6f0dbffd833f08a9b /argp
parent83d4b42ded712bbbc22ceeefe886b8315190da5b (diff)
downloadglibc-53fcdf5f743aa9b02972eec658e66f96d6a63386.zip
glibc-53fcdf5f743aa9b02972eec658e66f96d6a63386.tar.gz
glibc-53fcdf5f743aa9b02972eec658e66f96d6a63386.tar.bz2
Silence most -Wzero-as-null-pointer-constant diagnostics
Replace 0 by NULL and {0} by {}. Omit a few cases that aren't so trivial to fix. Link: <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117059> Link: <https://software.codidact.com/posts/292718/292759#answer-292759> Signed-off-by: Alejandro Colomar <alx@kernel.org>
Diffstat (limited to 'argp')
-rw-r--r--argp/argp-fmtstream.c2
-rw-r--r--argp/argp-help.c34
-rw-r--r--argp/argp-parse.c44
3 files changed, 40 insertions, 40 deletions
diff --git a/argp/argp-fmtstream.c b/argp/argp-fmtstream.c
index eb0a886..35b5b1d 100644
--- a/argp/argp-fmtstream.c
+++ b/argp/argp-fmtstream.c
@@ -74,7 +74,7 @@ __argp_make_fmtstream (FILE *stream,
if (! fs->buf)
{
free (fs);
- fs = 0;
+ fs = NULL;
}
else
{
diff --git a/argp/argp-help.c b/argp/argp-help.c
index cc43f37..5c41fdc 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -443,7 +443,7 @@ make_hol (const struct argp *argp, struct hol_cluster *cluster)
assert (hol);
hol->num_entries = 0;
- hol->clusters = 0;
+ hol->clusters = NULL;
if (opts)
{
@@ -615,7 +615,7 @@ static char
hol_entry_first_short (const struct hol_entry *entry)
{
return hol_entry_short_iterate (entry, until_short,
- entry->argp->argp_domain, 0);
+ entry->argp->argp_domain, NULL);
}
/* Returns the first valid long option in ENTRY, or NULL if there is none. */
@@ -627,7 +627,7 @@ hol_entry_first_long (const struct hol_entry *entry)
for (opt = entry->opt, num = entry->num; num > 0; opt++, num--)
if (opt->name && ovisible (opt))
return opt->name;
- return 0;
+ return NULL;
}
/* Returns the entry in HOL with the long option name NAME, or NULL if there is
@@ -652,7 +652,7 @@ hol_find_entry (struct hol *hol, const char *name)
entry++;
}
- return 0;
+ return NULL;
}
/* If an entry with the long option NAME occurs in HOL, set it's special
@@ -926,7 +926,7 @@ hol_append (struct hol *hol, struct hol *more)
while (*cl_end)
cl_end = &(*cl_end)->next;
*cl_end = more->clusters;
- more->clusters = 0;
+ more->clusters = NULL;
/* Merge entries. */
if (more->num_entries > 0)
@@ -1299,7 +1299,7 @@ hol_entry_help (struct hol_entry *entry, const struct argp_state *state,
{
const char *tstr = real->doc ? dgettext (state == NULL ? NULL
: state->root_argp->argp_domain,
- real->doc) : 0;
+ real->doc) : NULL;
const char *fstr = filter_doc (tstr, real->key, entry->argp, state);
if (fstr && *fstr)
{
@@ -1339,7 +1339,7 @@ hol_help (struct hol *hol, const struct argp_state *state,
{
unsigned num;
struct hol_entry *entry;
- struct hol_help_state hhstate = { 0, 0, 0 };
+ struct hol_help_state hhstate = { NULL, 0, 0 };
for (entry = hol->entries, num = hol->num_entries; num > 0; entry++, num--)
hol_entry_help (entry, state, stream, &hhstate);
@@ -1351,7 +1351,7 @@ hol_help (struct hol *hol, const struct argp_state *state,
Mandatory or optional arguments to long options are also mandatory or \
optional for any corresponding short options.");
const char *fstr = filter_doc (tstr, ARGP_KEY_HELP_DUP_ARGS_NOTE,
- state ? state->root_argp : 0, state);
+ state ? state->root_argp : NULL, state);
if (fstr && *fstr)
{
__argp_fmtstream_putc (stream, '\n');
@@ -1511,7 +1511,7 @@ argp_args_usage (const struct argp *argp, const struct argp_state *state,
char *our_level = *levels;
int multiple = 0;
const struct argp_child *child = argp->children;
- const char *tdoc = dgettext (argp->argp_domain, argp->args_doc), *nl = 0;
+ const char *tdoc = dgettext (argp->argp_domain, argp->args_doc), *nl = NULL;
const char *fdoc = filter_doc (tdoc, ARGP_KEY_HELP_ARGS_DOC, argp, state);
if (fdoc)
@@ -1573,7 +1573,7 @@ argp_doc (const struct argp *argp, const struct argp_state *state,
{
const char *text;
const char *inp_text;
- void *input = 0;
+ void *input = NULL;
int anything = 0;
size_t inp_text_limit = 0;
const char *doc = dgettext (argp->argp_domain, argp->doc);
@@ -1582,11 +1582,11 @@ argp_doc (const struct argp *argp, const struct argp_state *state,
if (doc)
{
char *vt = strchr (doc, '\v');
- inp_text = post ? (vt ? vt + 1 : 0) : doc;
+ inp_text = post ? (vt ? vt + 1 : NULL) : doc;
inp_text_limit = (!post && vt) ? (vt - doc) : 0;
}
else
- inp_text = 0;
+ inp_text = NULL;
if (argp->help_filter)
/* We have to filter the doc strings. */
@@ -1628,7 +1628,7 @@ argp_doc (const struct argp *argp, const struct argp_state *state,
if (post && argp->help_filter)
/* Now see if we have to output a ARGP_KEY_HELP_EXTRA text. */
{
- text = (*argp->help_filter) (ARGP_KEY_HELP_EXTRA, 0, input);
+ text = (*argp->help_filter) (ARGP_KEY_HELP_EXTRA, NULL, input);
if (text)
{
if (anything || pre_blank)
@@ -1661,7 +1661,7 @@ _help (const struct argp *argp, const struct argp_state *state, FILE *stream,
unsigned flags, char *name)
{
int anything = 0; /* Whether we've output anything. */
- struct hol *hol = 0;
+ struct hol *hol = NULL;
argp_fmtstream_t fs;
if (! stream)
@@ -1684,7 +1684,7 @@ _help (const struct argp *argp, const struct argp_state *state, FILE *stream,
if (flags & (ARGP_HELP_USAGE | ARGP_HELP_SHORT_USAGE | ARGP_HELP_LONG))
{
- hol = argp_hol (argp, 0);
+ hol = argp_hol (argp, NULL);
/* If present, these options always come last. */
hol_set_group (hol, "help", -1);
@@ -1801,7 +1801,7 @@ Try `%s --help' or `%s --usage' for more information.\n"),
void __argp_help (const struct argp *argp, FILE *stream,
unsigned flags, char *name)
{
- _help (argp, 0, stream, flags, name);
+ _help (argp, NULL, stream, flags, name);
}
#ifdef weak_alias
weak_alias (__argp_help, argp_help)
@@ -1843,7 +1843,7 @@ __argp_state_help (const struct argp_state *state, FILE *stream, unsigned flags)
if (state && (state->flags & ARGP_LONG_ONLY))
flags |= ARGP_HELP_LONG_ONLY;
- _help (state ? state->root_argp : 0, state, stream, flags,
+ _help (state ? state->root_argp : NULL, state, stream, flags,
state ? state->name : __argp_short_program_name ());
if (!state || ! (state->flags & ARGP_NO_EXIT))
diff --git a/argp/argp-parse.c b/argp/argp-parse.c
index 9b7b91f..7a75fa3 100644
--- a/argp/argp-parse.c
+++ b/argp/argp-parse.c
@@ -83,13 +83,13 @@ static volatile int _argp_hang;
static const struct argp_option argp_default_options[] =
{
- {"help", '?', 0, 0, N_("Give this help list"), -1},
- {"usage", OPT_USAGE, 0, 0, N_("Give a short usage message")},
+ {"help", '?', NULL, 0, N_("Give this help list"), -1},
+ {"usage", OPT_USAGE, NULL, 0, N_("Give a short usage message")},
{"program-name",OPT_PROGNAME, N_("NAME"), OPTION_HIDDEN,
N_("Set the program name")},
{"HANG", OPT_HANG, N_("SECS"), OPTION_ARG_OPTIONAL | OPTION_HIDDEN,
N_("Hang for SECS seconds (default 3600)")},
- {0, 0}
+ {NULL, 0}
};
static error_t
@@ -149,8 +149,8 @@ static const struct argp argp_default_argp =
static const struct argp_option argp_version_options[] =
{
- {"version", 'V', 0, 0, N_("Print program version"), -1},
- {0, 0}
+ {"version", 'V', NULL, 0, N_("Print program version"), -1},
+ {NULL, 0}
};
static error_t
@@ -341,7 +341,7 @@ convert_options (const struct argp *argp,
? optional_argument
: required_argument)
: no_argument);
- cvt->long_end->flag = 0;
+ cvt->long_end->flag = NULL;
/* we add a disambiguating code to all the user's
values (which is removed before we actually call
the function to parse the value); this means that
@@ -364,9 +364,9 @@ convert_options (const struct argp *argp,
group->args_processed = 0;
group->parent = parent;
group->parent_index = parent_index;
- group->input = 0;
- group->hook = 0;
- group->child_inputs = 0;
+ group->input = NULL;
+ group->hook = NULL;
+ group->child_inputs = NULL;
if (children)
/* Assign GROUP's CHILD_INPUTS field some space from
@@ -382,7 +382,7 @@ convert_options (const struct argp *argp,
parent = group++;
}
else
- parent = 0;
+ parent = NULL;
if (children)
{
@@ -417,7 +417,7 @@ parser_convert (struct parser *parser, const struct argp *argp, int flags)
parser->argp = argp;
if (argp)
- parser->egroup = convert_options (argp, 0, 0, parser->groups, &cvt);
+ parser->egroup = convert_options (argp, NULL, 0, parser->groups, &cvt);
else
parser->egroup = parser->groups; /* No parsers at all! */
}
@@ -530,7 +530,7 @@ parser_init (struct parser *parser, const struct argp *argp,
makes very simple wrapper argps more convenient). */
group->child_inputs[0] = group->input;
- err = group_parse (group, &parser->state, ARGP_KEY_INIT, 0);
+ err = group_parse (group, &parser->state, ARGP_KEY_INIT, NULL);
}
if (err == EBADKEY)
err = 0; /* Some parser didn't understand. */
@@ -582,11 +582,11 @@ parser_finalize (struct parser *parser,
group < parser->egroup && (!err || err==EBADKEY);
group++)
if (group->args_processed == 0)
- err = group_parse (group, &parser->state, ARGP_KEY_NO_ARGS, 0);
+ err = group_parse (group, &parser->state, ARGP_KEY_NO_ARGS, NULL);
for (group = parser->egroup - 1;
group >= parser->groups && (!err || err==EBADKEY);
group--)
- err = group_parse (group, &parser->state, ARGP_KEY_END, 0);
+ err = group_parse (group, &parser->state, ARGP_KEY_END, NULL);
if (err == EBADKEY)
err = 0; /* Some parser didn't understand. */
@@ -625,7 +625,7 @@ parser_finalize (struct parser *parser,
/* Since we didn't exit, give each parser an error indication. */
for (group = parser->groups; group < parser->egroup; group++)
- group_parse (group, &parser->state, ARGP_KEY_ERROR, 0);
+ group_parse (group, &parser->state, ARGP_KEY_ERROR, NULL);
}
else
/* Notify parsers of success, and propagate back values from parsers. */
@@ -636,14 +636,14 @@ parser_finalize (struct parser *parser,
for (group = parser->egroup - 1
; group >= parser->groups && (!err || err == EBADKEY)
; group--)
- err = group_parse (group, &parser->state, ARGP_KEY_SUCCESS, 0);
+ err = group_parse (group, &parser->state, ARGP_KEY_SUCCESS, NULL);
if (err == EBADKEY)
err = 0; /* Some parser didn't understand. */
}
/* Call parsers once more, to do any final cleanup. Errors are ignored. */
for (group = parser->egroup - 1; group >= parser->groups; group--)
- group_parse (group, &parser->state, ARGP_KEY_FINI, 0);
+ group_parse (group, &parser->state, ARGP_KEY_FINI, NULL);
if (err == EBADKEY)
err = EINVAL;
@@ -682,7 +682,7 @@ parser_parse_arg (struct parser *parser, char *val)
{
parser->state.next--; /* For ARGP_KEY_ARGS, put back the arg. */
key = ARGP_KEY_ARGS;
- err = group_parse (group, &parser->state, key, 0);
+ err = group_parse (group, &parser->state, key, NULL);
}
}
@@ -792,11 +792,11 @@ parser_parse_next (struct parser *parser, int *arg_ebadkey)
parser->opt_data.optopt = KEY_END;
if (parser->state.flags & ARGP_LONG_ONLY)
opt = _getopt_long_only_r (parser->state.argc, parser->state.argv,
- parser->short_opts, parser->long_opts, 0,
+ parser->short_opts, parser->long_opts, NULL,
&parser->opt_data);
else
opt = _getopt_long_r (parser->state.argc, parser->state.argv,
- parser->short_opts, parser->long_opts, 0,
+ parser->short_opts, parser->long_opts, NULL,
&parser->opt_data);
/* And see what getopt did. */
parser->state.next = parser->opt_data.optind;
@@ -893,7 +893,7 @@ __argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags,
child[child_index++].argp = &argp_default_argp;
if (argp_program_version || argp_program_version_hook)
child[child_index++].argp = &argp_version_argp;
- child[child_index].argp = 0;
+ child[child_index].argp = NULL;
argp = &top_argp;
}
@@ -930,7 +930,7 @@ __argp_input (const struct argp *argp, const struct argp_state *state)
return group->input;
}
- return 0;
+ return NULL;
}
#ifdef weak_alias
weak_alias (__argp_input, _argp_input)