git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, gitster@pobox.com, stolee@gmail.com,
	Derrick Stolee <derrickstolee@github.com>,
	Derrick Stolee <dstolee@microsoft.com>
Subject: Re: [PATCH] remote: initialize values that might not be set
Date: Mon, 7 Jun 2021 23:59:14 +0200 (CEST)	[thread overview]
Message-ID: <nycvar.QRO.7.76.6.2106072355110.55@tvgsbejvaqbjf.bet> (raw)
In-Reply-To: <pull.974.git.1623069570553.gitgitgadget@gmail.com>

Hi Stolee,

On Mon, 7 Jun 2021, Derrick Stolee via GitGitGadget wrote:

> From: Derrick Stolee <dstolee@microsoft.com>
>
> I noticed during an unrelated test with Valgrind that these variables
> might be left un-set by stat_tracking_info() in some cases. Initialize
> them so that a later branch upon their value is consistent.
>
> Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
> ---
>     remote: initialize values that might not be set
>
>     A very minor fixup.
>
>     Thanks, -Stolee
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-974%2Fderrickstolee%2Fremote-uninitialized-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-974/derrickstolee/remote-uninitialized-v1
> Pull-Request: https://github.com/gitgitgadget/git/pull/974
>
>  remote.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/remote.c b/remote.c
> index c3f85c17ca7c..a116392fb057 100644
> --- a/remote.c
> +++ b/remote.c
> @@ -2101,7 +2101,7 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,
>  int format_tracking_info(struct branch *branch, struct strbuf *sb,
>  			 enum ahead_behind_flags abf)
>  {
> -	int ours, theirs, sti;
> +	int ours = 0, theirs = 0, sti = 0;

While I like this change, I am somewhat confused where the values are used
for branching. The only time I see them used when `stat_branch_pair()` has
_not_ initialized `ours` and `theirs` is in those `trace2_data_intmax()`
calls. Otherwise `sti` is set to -1 and the other users of `ours` and
`theirs` aren't reached.

If my reading of the code is correct, maybe the commit message could be
adjusted to talk about tracing instead of branching?

Thanks,
Dscho

>  	const char *full_base;
>  	char *base;
>  	int upstream_is_gone = 0;
>
> base-commit: 71ca53e8125e36efbda17293c50027d31681a41f
> --
> gitgitgadget
>

  reply	other threads:[~2021-06-07 22:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-07 12:39 [PATCH] remote: initialize values that might not be set Derrick Stolee via GitGitGadget
2021-06-07 21:59 ` Johannes Schindelin [this message]
2021-06-07 23:21   ` Junio C Hamano
2021-06-10  9:24     ` Johannes Schindelin
2021-06-11  1:41       ` Junio C Hamano
2021-06-11 17:56       ` Derrick Stolee

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=nycvar.QRO.7.76.6.2106072355110.55@tvgsbejvaqbjf.bet \
    --to=johannes.schindelin@gmx.de \
    --cc=derrickstolee@github.com \
    --cc=dstolee@microsoft.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=stolee@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).