{"thread":{"id":"29574","subject":"[PATCH] column: Fix some compiler and sparse warnings","startedAt":"2012-02-08T19:13:12Z","lastAt":"2012-02-08T19:13:12Z","messageCount":1,"participants":["Ramsay Jones"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"184197","messageId":"4F32C948.3030700@ramsay1.demon.co.uk","threadId":"29574","inReplyTo":null,"subject":"[PATCH] column: Fix some compiler and sparse warnings","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2012-02-08T19:13:12Z","receivedAt":"2012-02-08T19:13:12Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nSome versions of gcc complain as follows:\n\n        CC column.o\n    column.c: In function `git_config_column':\n    column.c:313: warning: 'set' might be used uninitialized in \\\n        this function\n\nThe 'set' variable is not in fact used uninitialised, but in order to\nsuppress the warning, we rework the code slightly to ensure gcc does\nnot mis-diagnose the variable usage.\n\nAlso, sparse complains as follows:\n\n        SP pager.c\n    pager.c:134:5: warning: symbol 'term_columns' was not declared. \\\n        Should it be static?\n\nIn order to fix the warning, we add an include of the column.h header,\nwhich contains an appropriate extern declaration of term_columns().\n\nSigned-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n---\n\nHi Nguyen,\n\nIf you need to re-roll your \"nd/columns\" branch, could you please squash\nthis patch (or some variant) into it. Thanks!\n\n[I haven't checked, but I'm guessing that the pager.c change would be\nsquashed into commit cb0850f (Save terminal width before setting up pager,\n04-02-2012), whereas the column.c change would be squashed into commit\nac21f2b (Add git-column and column mode parsing, 04-02-2012)]\n\nATB,\nRamsay Jones\n\n column.c |    6 +++---\n pager.c  |    1 +\n 2 files changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/column.c b/column.c\nindex f001021..98328cf 100644\n--- a/column.c\n+++ b/column.c\n@@ -310,16 +310,16 @@ static int parse_option(const char *arg, int len,\n \t\t{ OPTION, \"color\",  COL_ANSI },\n \t\t{ OPTION, \"dense\",  COL_DENSE },\n \t};\n-\tint i, set, name_len;\n+\tint i;\n \n \tfor (i = 0; i < ARRAY_SIZE(opts); i++) {\n+\t\tint set = 1, name_len;\n+\n \t\tif (opts[i].type == OPTION) {\n \t\t\tif (len > 2 && !strncmp(arg, \"no\", 2)) {\n \t\t\t\targ += 2;\n \t\t\t\tlen -= 2;\n \t\t\t\tset = 0;\n-\t\t\t} else {\n-\t\t\t\tset = 1;\n \t\t\t}\n \t\t}\n \ndiff --git a/pager.c b/pager.c\nindex 37d554d..fe203a7 100644\n--- a/pager.c\n+++ b/pager.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"run-command.h\"\n #include \"sigchain.h\"\n+#include \"column.h\"\n \n #ifndef DEFAULT_PAGER\n #define DEFAULT_PAGER \"less\"\n-- \n1.7.9\n"}]}