git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukas Fleischer <git@cryptocrack.de>
To: git@vger.kernel.org
Cc: Andrew Wong <andrew.kw.w@gmail.com>, Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] setup.c: Remove duplicate code from prefix_pathspec()
Date: Thu, 14 Mar 2013 01:24:55 +0100	[thread overview]
Message-ID: <1363220695-27911-1-git-send-email-git@cryptocrack.de> (raw)

Only check for ',' explicitly and handle both ')' and '\0' in the else
branch. strcspn() can only return ',', ')' and '\0' at this point so the
new code is completely equivalent to what we had before.

This also fixes following GCC warning:

    setup.c: In function ‘get_pathspec’:
    setup.c:207:8: warning: ‘nextat’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    setup.c:205:15: note: ‘nextat’ was declared here

Signed-off-by: Lukas Fleischer <git@cryptocrack.de>
---
This removes the only warning that currently occurs when building the
next branch.

Junio: Feel free to squash this into Andrew's patch (805da4dee15b,
"setup.c: stop prefix_pathspec() from looping past the end of string").

 setup.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/setup.c b/setup.c
index d2335a8..94c1e61 100644
--- a/setup.c
+++ b/setup.c
@@ -207,12 +207,11 @@ static const char *prefix_pathspec(const char *prefix, int prefixlen, const char
 		     *copyfrom && *copyfrom != ')';
 		     copyfrom = nextat) {
 			size_t len = strcspn(copyfrom, ",)");
-			if (copyfrom[len] == '\0')
-				nextat = copyfrom + len;
-			else if (copyfrom[len] == ')')
-				nextat = copyfrom + len;
-			else if (copyfrom[len] == ',')
+			if (copyfrom[len] == ',')
 				nextat = copyfrom + len + 1;
+			else
+				/* handle ')' and '\0' */
+				nextat = copyfrom + len;
 			if (!len)
 				continue;
 			for (i = 0; i < ARRAY_SIZE(pathspec_magic); i++)
-- 
1.8.2.rc2.352.g908df73

                 reply	other threads:[~2013-03-14  0:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1363220695-27911-1-git-send-email-git@cryptocrack.de \
    --to=git@cryptocrack.de \
    --cc=andrew.kw.w@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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).