Git development
 help / color / mirror / Atom feed
From: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
To: Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
	GIT Mailing-list <git@vger.kernel.org>
Subject: [PATCH] column: Fix some compiler and sparse warnings
Date: Wed, 08 Feb 2012 19:13:12 +0000	[thread overview]
Message-ID: <4F32C948.3030700@ramsay1.demon.co.uk> (raw)


Some versions of gcc complain as follows:

        CC column.o
    column.c: In function `git_config_column':
    column.c:313: warning: 'set' might be used uninitialized in \
        this function

The 'set' variable is not in fact used uninitialised, but in order to
suppress the warning, we rework the code slightly to ensure gcc does
not mis-diagnose the variable usage.

Also, sparse complains as follows:

        SP pager.c
    pager.c:134:5: warning: symbol 'term_columns' was not declared. \
        Should it be static?

In order to fix the warning, we add an include of the column.h header,
which contains an appropriate extern declaration of term_columns().

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---

Hi Nguyen,

If you need to re-roll your "nd/columns" branch, could you please squash
this patch (or some variant) into it. Thanks!

[I haven't checked, but I'm guessing that the pager.c change would be
squashed into commit cb0850f (Save terminal width before setting up pager,
04-02-2012), whereas the column.c change would be squashed into commit
ac21f2b (Add git-column and column mode parsing, 04-02-2012)]

ATB,
Ramsay Jones

 column.c |    6 +++---
 pager.c  |    1 +
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/column.c b/column.c
index f001021..98328cf 100644
--- a/column.c
+++ b/column.c
@@ -310,16 +310,16 @@ static int parse_option(const char *arg, int len,
 		{ OPTION, "color",  COL_ANSI },
 		{ OPTION, "dense",  COL_DENSE },
 	};
-	int i, set, name_len;
+	int i;
 
 	for (i = 0; i < ARRAY_SIZE(opts); i++) {
+		int set = 1, name_len;
+
 		if (opts[i].type == OPTION) {
 			if (len > 2 && !strncmp(arg, "no", 2)) {
 				arg += 2;
 				len -= 2;
 				set = 0;
-			} else {
-				set = 1;
 			}
 		}
 
diff --git a/pager.c b/pager.c
index 37d554d..fe203a7 100644
--- a/pager.c
+++ b/pager.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "run-command.h"
 #include "sigchain.h"
+#include "column.h"
 
 #ifndef DEFAULT_PAGER
 #define DEFAULT_PAGER "less"
-- 
1.7.9

                 reply	other threads:[~2012-02-08 19:36 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=4F32C948.3030700@ramsay1.demon.co.uk \
    --to=ramsay@ramsay1.demon.co.uk \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox