git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Reece Dunn <msclrhd@googlemail.com>
To: Jeff King <peff@peff.net>
Cc: Giuseppe Scrivano <gscrivano@gnu.org>,
	git@vger.kernel.org,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Sverre Rabbelier <srabbelier@gmail.com>
Subject: Re: [PATCH] Remove various dead assignments and dead increments found  by the clang static analyzer
Date: Sat, 26 Sep 2009 22:03:27 +0100	[thread overview]
Message-ID: <3f4fd2640909261403n78a7e45cm3d2cd48408b5ff52@mail.gmail.com> (raw)
In-Reply-To: <20090926204604.GA2960@coredump.intra.peff.net>

2009/9/26 Jeff King <peff@peff.net>:
> On Sat, Sep 26, 2009 at 09:15:58PM +0200, Giuseppe Scrivano wrote:
>
>> Here is a cleaned patch.  I think these assignments can be removed
>> without any problem.
>
>> --- a/builtin-receive-pack.c
>> +++ b/builtin-receive-pack.c
>> @@ -368,7 +368,7 @@ static char update_post_hook[] = "hooks/post-update";
>>  static void run_update_post_hook(struct command *cmd)
>>  {
>>       struct command *cmd_p;
>> -     int argc, status;
>> +     int argc;
>>       const char **argv;
>>
>>       for (argc = 0, cmd_p = cmd; cmd_p; cmd_p = cmd_p->next) {
>> @@ -391,7 +391,7 @@ static void run_update_post_hook(struct command *cmd)
>>               argc++;
>>       }
>>       argv[argc] = NULL;
>> -     status = run_command_v_opt(argv, RUN_COMMAND_NO_STDIN
>> +     run_command_v_opt(argv, RUN_COMMAND_NO_STDIN
>>                       | RUN_COMMAND_STDOUT_TO_STDERR);
>>  }
>
> Now this is one that I do think is sensible. The variable isn't used, so
> don't even bother declaring it.

The status variable is removed in this patch.

But then shouldn't the status returned be checked and acted on? That
is, are failures from run_command_v_opt being reported to the user, or
otherwise reacted to?

In this case, IIUC, the status should be returned by the
run_update_post_hook function. I.e.:

-  static void run_update_post_hook(struct command *cmd)
+  static int run_update_post_hook(struct command *cmd)
  {
      struct command *cmd_p;
-     int argc, status;
+     int argc;
...
-     status = run_command_v_opt(argv, RUN_COMMAND_NO_STDIN
+     return run_command_v_opt(argv, RUN_COMMAND_NO_STDIN
                      | RUN_COMMAND_STDOUT_TO_STDERR);
   }

Thus having the same effect (removing the status variable). Callers of
run_update_post_hook should be checked as well, as should other
run_command_* calls.

- Reece

  reply	other threads:[~2009-09-26 21:03 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-26 14:46 [PATCH] Remove various dead assignments and dead increments found by the clang static analyzer Giuseppe Scrivano
2009-09-26 15:58 ` Johannes Schindelin
2009-09-26 18:21   ` Giuseppe Scrivano
2009-09-26 18:34     ` Sverre Rabbelier
2009-09-26 18:46       ` Giuseppe Scrivano
2009-09-26 19:15       ` Giuseppe Scrivano
2009-09-26 19:28         ` René Scharfe
2009-09-26 20:39         ` Johannes Schindelin
2009-09-26 20:46         ` Jeff King
2009-09-26 21:03           ` Reece Dunn [this message]
2009-09-26 21:12             ` Jeff King
2009-09-26 21:20               ` Reece Dunn
2009-09-26 21:36                 ` Jeff King
2009-09-26 21:46                   ` Reece Dunn
2009-09-26 21:42                 ` Giuseppe Scrivano
2009-09-27  0:41           ` Nicolas Pitre
2009-09-27  8:21             ` Giuseppe Scrivano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3f4fd2640909261403n78a7e45cm3d2cd48408b5ff52@mail.gmail.com \
    --to=msclrhd@googlemail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gscrivano@gnu.org \
    --cc=peff@peff.net \
    --cc=srabbelier@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).