Re: [PATCH] Remove unused assignments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Benjamin Kramer <benny.kra@xxxxxxxxxxxxxx> writes:

> These variables were always overwritten or the assigned
> value was unused:
>
> builtin-diff-tree.c::cmd_diff_tree(): nr_sha1
> builtin-for-each-ref.c::opt_parse_sort(): sort_tail
> builtin-mailinfo.c::decode_header_bq(): in
> builtin-shortlog.c::insert_one_record(): len
> connect.c::git_connect(): path
> imap-send.c::v_issue_imap_cmd(): n
> pretty.c::pp_user_info(): filler
> remote::parse_refspec_internal(): llen
>
> Signed-off-by: Benjamin Kramer <benny.kra@xxxxxxxxxxxxxx>

Thanks.  I eyeballed all of them and they look safe, but this patch made
me wonder...

Did you use some dataflow analysis tool to spot these?

It will never scale if a human has to sanity check output from a
mechanical process like this patch, especially when the human is already a
chokepoint of the whole process (i.e. the maintainer).

We'd need some process improvements in the longer term to handle patches
like this, but I do not think of a good one offhand.

I do not think we want to trust tool output blindly; it will not solve the
issue to give me the recipe for the mechanical process you used, to have
me run it and to make me trust the result without checking.  We would want
to keep some human whose judgement we can trust in the loop to always
check the changes mechanical analysis tools may produce.

I think the only viable long term solution would be to keep doing the
manual verification I did like this round until somebody like you
accumulate enough "trust points" in the community for consistently sending
good patches like this one to allow me to apply patches from these people
blindly, trusting the sender's judgement.

But please disregard all of the above if you spotted these by manual
inspection.

I think the patch to pp_user_info() can go one step further.  The filler
is used at only one place after this patch, as a strong given to one of
the placeholders in strbuf_addf().  We can simply feed a constant to the
function instead, like this:

diff --git a/pretty.c b/pretty.c
index 3a24cd5..efa7024 100644
--- a/pretty.c
+++ b/pretty.c
@@ -135,7 +135,6 @@ void pp_user_info(const char *what, enum cmit_fmt fmt, struct strbuf *sb,
 	int namelen;
 	unsigned long time;
 	int tz;
-	const char *filler = "    ";
 
 	if (fmt == CMIT_FMT_ONELINE)
 		return;
@@ -161,7 +160,7 @@ void pp_user_info(const char *what, enum cmit_fmt fmt, struct strbuf *sb,
 	} else {
 		strbuf_addf(sb, "%s: %.*s%.*s\n", what,
 			      (fmt == CMIT_FMT_FULLER) ? 4 : 0,
-			      filler, namelen, line);
+			      "    ", namelen, line);
 	}
 	switch (fmt) {
 	case CMIT_FMT_MEDIUM:

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux