From 3f98fe3155b8f19431411370198102f30f00b45e Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 25 May 2011 22:27:53 +0200 Subject: maint: env.c: remove unnecessary use of strchr * src/env.c (main): Remove excess (and confusing to static analyzers) use of strchr. --- src/env.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/env.c b/src/env.c index 1eb39a110..9f7a8528b 100644 --- a/src/env.c +++ b/src/env.c @@ -123,13 +123,17 @@ main (int argc, char **argv) if (optind < argc && STREQ (argv[optind], "-")) ++optind; - while (optind < argc && strchr (argv[optind], '=')) - if (putenv (argv[optind++])) - { - char *name = argv[optind - 1]; - *(strchr (name, '=')) = '\0'; - error (EXIT_CANCELED, errno, _("cannot set %s"), quote (name)); - } + char *eq; + while (optind < argc && (eq = strchr (argv[optind], '='))) + { + if (putenv (argv[optind])) + { + *eq = '\0'; + error (EXIT_CANCELED, errno, _("cannot set %s"), + quote (argv[optind])); + } + optind++; + } /* If no program is specified, print the environment and exit. */ if (argc <= optind) -- cgit v1.2.3-54-g00ecf