git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stephan Beyer <s-beyer@gmx.net>
To: "René Scharfe" <l.s.r@web.de>, "Paul Tan" <pyokagan@gmail.com>,
	"Jeff King" <peff@peff.net>,
	"brian m. carlson" <sandals@crustytoothpaste.net>,
	"Shawn O. Pearce" <spearce@spearce.org>,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>
Cc: Stephan Beyer <s-beyer@gmx.net>, git@vger.kernel.org
Subject: [PATCH v2 2/4] test-read-cache: fix maybe-uninitialized warning for namelen
Date: Fri,  6 Sep 2019 00:48:31 +0200	[thread overview]
Message-ID: <20190905224833.24913-2-s-beyer@gmx.net> (raw)
In-Reply-To: <20190905224833.24913-1-s-beyer@gmx.net>

This is done by removing namelen at all. It is only used once
and simply strlen(name), hence we use strlen(name) directly.

Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
---
 t/helper/test-read-cache.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c
index 7e79b555de..244977a29b 100644
--- a/t/helper/test-read-cache.c
+++ b/t/helper/test-read-cache.c
@@ -4,11 +4,10 @@

 int cmd__read_cache(int argc, const char **argv)
 {
-	int i, cnt = 1, namelen;
+	int i, cnt = 1;
 	const char *name = NULL;

 	if (argc > 1 && skip_prefix(argv[1], "--print-and-refresh=", &name)) {
-		namelen = strlen(name);
 		argc--;
 		argv++;
 	}
@@ -24,7 +23,7 @@ int cmd__read_cache(int argc, const char **argv)

 			refresh_index(&the_index, REFRESH_QUIET,
 				      NULL, NULL, NULL);
-			pos = index_name_pos(&the_index, name, namelen);
+			pos = index_name_pos(&the_index, name, strlen(name));
 			if (pos < 0)
 				die("%s not in index", name);
 			printf("%s is%s up to date\n", name,
--
2.23.0.43.g31ebfd7ae6.dirty


  reply	other threads:[~2019-09-05 22:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-05 22:48 [PATCH v2 1/4] am: fail if no author line is given in --rebasing mode Stephan Beyer
2019-09-05 22:48 ` Stephan Beyer [this message]
2019-09-05 22:48 ` [PATCH v2 3/4] pack-objects: fix maybe-uninitialized warning for index_pos Stephan Beyer
2019-09-05 22:48 ` [PATCH v2 4/4] Silence false-positive maybe-uninitialized warnings found by gcc 9 -flto Stephan Beyer
2019-09-06 12:39 ` [PATCH v2 1/4] am: fail if no author line is given in --rebasing mode Stephan Beyer

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=20190905224833.24913-2-s-beyer@gmx.net \
    --to=s-beyer@gmx.net \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=l.s.r@web.de \
    --cc=peff@peff.net \
    --cc=pyokagan@gmail.com \
    --cc=sandals@crustytoothpaste.net \
    --cc=spearce@spearce.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.
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).