From: Junio C Hamano <gitster@pobox.com>
To: Benjamin Kramer <benny.kra@googlemail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Remove unused assignments
Date: Sat, 14 Mar 2009 13:18:02 -0700 [thread overview]
Message-ID: <7v7i2rc0zp.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <49BA56D5.5050807@googlemail.com> (Benjamin Kramer's message of "Fri, 13 Mar 2009 13:51:33 +0100")
Benjamin Kramer <benny.kra@googlemail.com> 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@googlemail.com>
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:
next prev parent reply other threads:[~2009-03-14 20:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-13 12:51 [PATCH] Remove unused assignments Benjamin Kramer
2009-03-14 20:18 ` Junio C Hamano [this message]
2009-03-14 20:57 ` Benjamin Kramer
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=7v7i2rc0zp.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=benny.kra@googlemail.com \
--cc=git@vger.kernel.org \
/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).