{"thread":{"id":"29218","subject":"[PATCH 0/4] Eliminate warnings under Sun Studio","startedAt":"2011-12-21T01:18:18Z","lastAt":"2011-12-21T20:41:17Z","messageCount":8,"participants":["Ævar Arnfjörð Bjarmason","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"181551","messageId":"1324430302-22441-1-git-send-email-avarab@gmail.com","threadId":"29218","inReplyTo":null,"subject":"[PATCH 0/4] Eliminate warnings under Sun Studio","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2011-12-21T01:18:18Z","receivedAt":"2011-12-21T01:18:18Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"This patch series eliminates warnings under Sun Studio. The first two\npatches address actual (but obviously minor) issues, the third is a\nnit, and the fourth disables a warning Sun Studio gets wrong.\n\nI'm not sure whether we want the verbose code needed in the forth to\ndisable warnings under specific compilers, but since it's a rare\nenough case and saves people compiling the code from wondering about\nit's it's probably warranted. It's a verbose way to get rid of it\nthough.\n\nI've CC'd people involved in the code touched by the first two, but\nthe second two are generic enough that I've decided not to bother the\noriginal authors.\n\nÆvar Arnfjörð Bjarmason (4):\n  Fix an enum assignment issue spotted by Sun Studio\n  Fix a bitwise negation assignment issue spotted by Sun Studio\n  Appease Sun Studio by renaming \"tmpfile\"\n  Suppress \"statement not reached\" warnings under Sun Studio\n\n builtin/fast-export.c |    4 ++--\n builtin/index-pack.c  |    6 +++---\n fast-import.c         |    8 ++++----\n pack-write.c          |    6 +++---\n read-cache.c          |    6 ++++++\n sha1_file.c           |   12 ++++++------\n test-treap.c          |    2 +-\n vcs-svn/repo_tree.c   |    2 +-\n vcs-svn/string_pool.c |    4 ++--\n xdiff/xutils.c        |    6 ++++++\n 10 files changed, 34 insertions(+), 22 deletions(-)\n\n-- \n1.7.7.3\n"},{"id":"181552","messageId":"1324430302-22441-2-git-send-email-avarab@gmail.com","threadId":"29218","inReplyTo":"1324430302-22441-1-git-send-email-avarab@gmail.com","subject":"[PATCH 1/4] Fix an enum assignment issue spotted by Sun Studio","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2011-12-21T01:18:19Z","receivedAt":"2011-12-21T01:18:19Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"In builtin/fast-export.c we'd assign to variables of the\ntag_of_filtered_mode enum type with constants defined for the\nsigned_tag_mode enum.\n\nWe'd get the intended value since both the value we were assigning\nwith and the one we actually wanted had the same positional within\ntheir respective enums, but doing it this way makes no sense.\n\nThis issue was spotted by Sun Studio 12 Update 1:\n\n    \"builtin/fast-export.c\", line 54: warning: enum type mismatch: op \"=\" (E_ENUM_TYPE_MISMATCH_OP)\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/fast-export.c |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 9836e6b..08fed98 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -25,7 +25,7 @@ static const char *fast_export_usage[] = {\n \n static int progress;\n static enum { ABORT, VERBATIM, WARN, STRIP } signed_tag_mode = ABORT;\n-static enum { ERROR, DROP, REWRITE } tag_of_filtered_mode = ABORT;\n+static enum { ERROR, DROP, REWRITE } tag_of_filtered_mode = ERROR;\n static int fake_missing_tagger;\n static int use_done_feature;\n static int no_data;\n@@ -51,7 +51,7 @@ static int parse_opt_tag_of_filtered_mode(const struct option *opt,\n \t\t\t\t\t  const char *arg, int unset)\n {\n \tif (unset || !strcmp(arg, \"abort\"))\n-\t\ttag_of_filtered_mode = ABORT;\n+\t\ttag_of_filtered_mode = ERROR;\n \telse if (!strcmp(arg, \"drop\"))\n \t\ttag_of_filtered_mode = DROP;\n \telse if (!strcmp(arg, \"rewrite\"))\n-- \n1.7.7.3\n"},{"id":"181553","messageId":"1324430302-22441-3-git-send-email-avarab@gmail.com","threadId":"29218","inReplyTo":"1324430302-22441-1-git-send-email-avarab@gmail.com","subject":"[PATCH 2/4] Fix a bitwise negation assignment issue spotted by Sun Studio","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2011-12-21T01:18:20Z","receivedAt":"2011-12-21T01:18:20Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change direct and indirect assignments of the bitwise negation of 0 to\nuint32_t variables to have a \"U\" suffix. I.e. ~0U instead of ~0. This\neliminates warnings under Sun Studio 12 Update 1:\n\n    \"vcs-svn/string_pool.c\", line 11: warning: initializer will be sign-extended: -1 (E_INIT_SIGN_EXTEND)\n    \"vcs-svn/string_pool.c\", line 81: warning: initializer will be sign-extended: -1 (E_INIT_SIGN_EXTEND)\n    \"vcs-svn/repo_tree.c\", line 112: warning: initializer will be sign-extended: -1 (E_INIT_SIGN_EXTEND)\n    \"vcs-svn/repo_tree.c\", line 112: warning: initializer will be sign-extended: -1 (E_INIT_SIGN_EXTEND)\n    \"test-treap.c\", line 34: warning: initializer will be sign-extended: -1 (E_INIT_SIGN_EXTEND)\n\nThe semantics are still the same as demonstrated by this program:\n\n    $ cat test.c && make test && ./test\n    #include <stdio.h>\n    #include <stdint.h>\n\n    int main(void)\n    {\n        uint32_t foo = ~0;\n        uint32_t bar = ~0U;\n\n        printf(\"foo = <%u> bar = <%u>\\n\", foo, bar);\n\n        return 0;\n    }\n    cc     test.c   -o test\n    \"test.c\", line 5: warning: initializer will be sign-extended: -1\n    foo = <4294967295> bar = <4294967295>\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n test-treap.c          |    2 +-\n vcs-svn/repo_tree.c   |    2 +-\n vcs-svn/string_pool.c |    4 ++--\n 3 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/test-treap.c b/test-treap.c\nindex ab8c951..294d7ee 100644\n--- a/test-treap.c\n+++ b/test-treap.c\n@@ -31,7 +31,7 @@ static void strtonode(struct int_node *item, const char *s)\n int main(int argc, char *argv[])\n {\n \tstruct strbuf sb = STRBUF_INIT;\n-\tstruct trp_root root = { ~0 };\n+\tstruct trp_root root = { ~0U };\n \tuint32_t item;\n \n \tif (argc != 1)\ndiff --git a/vcs-svn/repo_tree.c b/vcs-svn/repo_tree.c\nindex a21d89d..c3f198d 100644\n--- a/vcs-svn/repo_tree.c\n+++ b/vcs-svn/repo_tree.c\n@@ -109,7 +109,7 @@ static struct repo_dirent *repo_read_dirent(uint32_t revision,\n static void repo_write_dirent(const uint32_t *path, uint32_t mode,\n \t\t\t      uint32_t content_offset, uint32_t del)\n {\n-\tuint32_t name, revision, dir_o = ~0, parent_dir_o = ~0;\n+\tuint32_t name, revision, dir_o = ~0U, parent_dir_o = ~0U;\n \tstruct repo_dir *dir;\n \tstruct repo_dirent *key;\n \tstruct repo_dirent *dent = NULL;\ndiff --git a/vcs-svn/string_pool.c b/vcs-svn/string_pool.c\nindex 8af8d54..1b63b19 100644\n--- a/vcs-svn/string_pool.c\n+++ b/vcs-svn/string_pool.c\n@@ -8,7 +8,7 @@\n #include \"obj_pool.h\"\n #include \"string_pool.h\"\n \n-static struct trp_root tree = { ~0 };\n+static struct trp_root tree = { ~0U };\n \n struct node {\n \tuint32_t offset;\n@@ -78,7 +78,7 @@ void pool_print_seq(uint32_t len, uint32_t *seq, char delim, FILE *stream)\n uint32_t pool_tok_seq(uint32_t sz, uint32_t *seq, const char *delim, char *str)\n {\n \tchar *context = NULL;\n-\tuint32_t token = ~0;\n+\tuint32_t token = ~0U;\n \tuint32_t length;\n \n \tif (sz == 0)\n-- \n1.7.7.3\n"},{"id":"181554","messageId":"1324430302-22441-4-git-send-email-avarab@gmail.com","threadId":"29218","inReplyTo":"1324430302-22441-1-git-send-email-avarab@gmail.com","subject":"[PATCH 3/4] Appease Sun Studio by renaming \"tmpfile\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2011-12-21T01:18:21Z","receivedAt":"2011-12-21T01:18:21Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Solaris the system headers define the \"tmpfile\" name, which'll\ncause Git compiled with Sun Studio 12 Update 1 to whine about us\nredefining the name:\n\n    \"pack-write.c\", line 76: warning: name redefined by pragma redefine_extname declared static: tmpfile     (E_PRAGMA_REDEFINE_STATIC)\n    \"sha1_file.c\", line 2455: warning: name redefined by pragma redefine_extname declared static: tmpfile    (E_PRAGMA_REDEFINE_STATIC)\n    \"fast-import.c\", line 858: warning: name redefined by pragma redefine_extname declared static: tmpfile   (E_PRAGMA_REDEFINE_STATIC)\n    \"builtin/index-pack.c\", line 175: warning: name redefined by pragma redefine_extname declared static: tmpfile    (E_PRAGMA_REDEFINE_STATIC)\n\nJust renaming the \"tmpfile\" variable to \"tmp_file\" in the relevant\nplaces is the easiest way to fix this.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/index-pack.c |    6 +++---\n fast-import.c        |    8 ++++----\n pack-write.c         |    6 +++---\n sha1_file.c          |   12 ++++++------\n 4 files changed, 16 insertions(+), 16 deletions(-)\n\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 98025da..af7dc37 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -172,10 +172,10 @@ static const char *open_pack_file(const char *pack_name)\n \tif (from_stdin) {\n \t\tinput_fd = 0;\n \t\tif (!pack_name) {\n-\t\t\tstatic char tmpfile[PATH_MAX];\n-\t\t\toutput_fd = odb_mkstemp(tmpfile, sizeof(tmpfile),\n+\t\t\tstatic char tmp_file[PATH_MAX];\n+\t\t\toutput_fd = odb_mkstemp(tmp_file, sizeof(tmp_file),\n \t\t\t\t\t\t\"pack/tmp_pack_XXXXXX\");\n-\t\t\tpack_name = xstrdup(tmpfile);\n+\t\t\tpack_name = xstrdup(tmp_file);\n \t\t} else\n \t\t\toutput_fd = open(pack_name, O_CREAT|O_EXCL|O_RDWR, 0600);\n \t\tif (output_fd < 0)\ndiff --git a/fast-import.c b/fast-import.c\nindex 4b9c4b7..6cd19e5 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -855,15 +855,15 @@ static struct tree_content *dup_tree_content(struct tree_content *s)\n \n static void start_packfile(void)\n {\n-\tstatic char tmpfile[PATH_MAX];\n+\tstatic char tmp_file[PATH_MAX];\n \tstruct packed_git *p;\n \tstruct pack_header hdr;\n \tint pack_fd;\n \n-\tpack_fd = odb_mkstemp(tmpfile, sizeof(tmpfile),\n+\tpack_fd = odb_mkstemp(tmp_file, sizeof(tmp_file),\n \t\t\t      \"pack/tmp_pack_XXXXXX\");\n-\tp = xcalloc(1, sizeof(*p) + strlen(tmpfile) + 2);\n-\tstrcpy(p->pack_name, tmpfile);\n+\tp = xcalloc(1, sizeof(*p) + strlen(tmp_file) + 2);\n+\tstrcpy(p->pack_name, tmp_file);\n \tp->pack_fd = pack_fd;\n \tp->do_not_close = 1;\n \tpack_file = sha1fd(pack_fd, p->pack_name);\ndiff --git a/pack-write.c b/pack-write.c\nindex de2bd01..ca9e63b 100644\n--- a/pack-write.c\n+++ b/pack-write.c\n@@ -73,9 +73,9 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec\n \t\tf = sha1fd_check(index_name);\n \t} else {\n \t\tif (!index_name) {\n-\t\t\tstatic char tmpfile[PATH_MAX];\n-\t\t\tfd = odb_mkstemp(tmpfile, sizeof(tmpfile), \"pack/tmp_idx_XXXXXX\");\n-\t\t\tindex_name = xstrdup(tmpfile);\n+\t\t\tstatic char tmp_file[PATH_MAX];\n+\t\t\tfd = odb_mkstemp(tmp_file, sizeof(tmp_file), \"pack/tmp_idx_XXXXXX\");\n+\t\t\tindex_name = xstrdup(tmp_file);\n \t\t} else {\n \t\t\tunlink(index_name);\n \t\t\tfd = open(index_name, O_CREAT|O_EXCL|O_WRONLY, 0600);\ndiff --git a/sha1_file.c b/sha1_file.c\nindex f291f3f..88f2151 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -2452,15 +2452,15 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,\n \tgit_SHA_CTX c;\n \tunsigned char parano_sha1[20];\n \tchar *filename;\n-\tstatic char tmpfile[PATH_MAX];\n+\tstatic char tmp_file[PATH_MAX];\n \n \tfilename = sha1_file_name(sha1);\n-\tfd = create_tmpfile(tmpfile, sizeof(tmpfile), filename);\n+\tfd = create_tmpfile(tmp_file, sizeof(tmp_file), filename);\n \tif (fd < 0) {\n \t\tif (errno == EACCES)\n \t\t\treturn error(\"insufficient permission for adding an object to repository database %s\\n\", get_object_directory());\n \t\telse\n-\t\t\treturn error(\"unable to create temporary sha1 filename %s: %s\\n\", tmpfile, strerror(errno));\n+\t\t\treturn error(\"unable to create temporary sha1 filename %s: %s\\n\", tmp_file, strerror(errno));\n \t}\n \n \t/* Set it up */\n@@ -2505,12 +2505,12 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,\n \t\tstruct utimbuf utb;\n \t\tutb.actime = mtime;\n \t\tutb.modtime = mtime;\n-\t\tif (utime(tmpfile, &utb) < 0)\n+\t\tif (utime(tmp_file, &utb) < 0)\n \t\t\twarning(\"failed utime() on %s: %s\",\n-\t\t\t\ttmpfile, strerror(errno));\n+\t\t\t\ttmp_file, strerror(errno));\n \t}\n \n-\treturn move_temp_to_file(tmpfile, filename);\n+\treturn move_temp_to_file(tmp_file, filename);\n }\n \n int write_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *returnsha1)\n-- \n1.7.7.3\n"},{"id":"181555","messageId":"1324430302-22441-5-git-send-email-avarab@gmail.com","threadId":"29218","inReplyTo":"1324430302-22441-1-git-send-email-avarab@gmail.com","subject":"[PATCH 4/4] Suppress \"statement not reached\" warnings under Sun Studio","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2011-12-21T01:18:22Z","receivedAt":"2011-12-21T01:18:22Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Sun Studio 12 Update 1's brain will melt on these two occurances of\nusing \"goto\" to jump into a loop. It'll emit these warnings:\n\n    \"read-cache.c\", line 761: warning: statement not reached (E_STATEMENT_NOT_REACHED)\n    \"xdiff/xutils.c\", line 194: warning: statement not reached (E_STATEMENT_NOT_REACHED)\n\nSuppress these warnings by using a Sun Studio specific pragma\ndirective to turn them off, but only do so if __sun is defined, which\nis the macro Sun Studio uses to identify itself under both its C and\nC++ variants, see http://developers.sun.com/sunstudio/products/faqs/cpp.html\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n read-cache.c   |    6 ++++++\n xdiff/xutils.c |    6 ++++++\n 2 files changed, 12 insertions(+), 0 deletions(-)\n\ndiff --git a/read-cache.c b/read-cache.c\nindex a51bba1..0a4e895 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -758,7 +758,13 @@ int verify_path(const char *path)\n \t\treturn 0;\n \n \tgoto inside;\n+#ifdef __sun\n+#\tpragma error_messages (off, E_STATEMENT_NOT_REACHED)\n+#endif\n \tfor (;;) {\n+#ifdef __sun\n+#\tpragma error_messages (on, E_STATEMENT_NOT_REACHED)\n+#endif\n \t\tif (!c)\n \t\t\treturn 1;\n \t\tif (is_dir_sep(c)) {\ndiff --git a/xdiff/xutils.c b/xdiff/xutils.c\nindex 0de084e..62c3567 100644\n--- a/xdiff/xutils.c\n+++ b/xdiff/xutils.c\n@@ -191,7 +191,13 @@ int xdl_recmatch(const char *l1, long s1, const char *l2, long s2, long flags)\n \t */\n \tif (flags & XDF_IGNORE_WHITESPACE) {\n \t\tgoto skip_ws;\n+#ifdef __sun\n+#\tpragma error_messages (off, E_STATEMENT_NOT_REACHED)\n+#endif\n \t\twhile (i1 < s1 && i2 < s2) {\n+#ifdef __sun\n+#\tpragma error_messages (on, E_STATEMENT_NOT_REACHED)\n+#endif\n \t\t\tif (l1[i1++] != l2[i2++])\n \t\t\t\treturn 0;\n \t\tskip_ws:\n-- \n1.7.7.3\n"},{"id":"181586","messageId":"7vvcp9hjam.fsf@alter.siamese.dyndns.org","threadId":"29218","inReplyTo":"1324430302-22441-5-git-send-email-avarab@gmail.com","subject":"Re: [PATCH 4/4] Suppress \"statement not reached\" warnings under Sun Studio","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-12-21T18:27:29Z","receivedAt":"2011-12-21T18:27:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> diff --git a/read-cache.c b/read-cache.c\n> index a51bba1..0a4e895 100644\n> --- a/read-cache.c\n> +++ b/read-cache.c\n> @@ -758,7 +758,13 @@ int verify_path(const char *path)\n>  \t\treturn 0;\n>  \n>  \tgoto inside;\n> +#ifdef __sun\n> +#\tpragma error_messages (off, E_STATEMENT_NOT_REACHED)\n> +#endif\n>  \tfor (;;) {\n> +#ifdef __sun\n> +#\tpragma error_messages (on, E_STATEMENT_NOT_REACHED)\n> +#endif\n>  \t\tif (!c)\n>  \t\t\treturn 1;\n\nPatches 1-3 makes sense, but this one is too ugly to live.\n\nWouldn't something like this be equivalent and have the same effect\nwithout sacrificing the readablity?\n\ndiff --git a/read-cache.c b/read-cache.c\nindex a51bba1..73af797 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -757,12 +757,12 @@ int verify_path(const char *path)\n \tif (has_dos_drive_prefix(path))\n \t\treturn 0;\n \n-\tgoto inside;\n+\t/* we are at the beginning of a path component */\n+\tc = '/';\n \tfor (;;) {\n \t\tif (!c)\n \t\t\treturn 1;\n \t\tif (is_dir_sep(c)) {\n-inside:\n \t\t\tc = *path++;\n \t\t\tif ((c == '.' && !verify_dotfile(path)) ||\n \t\t\t    is_dir_sep(c) || c == '\\0')\n"},{"id":"181590","messageId":"CACBZZX4htZRQH+2xvoskwE7KoTz98Ox-3xQf0hyEbbFDYCZYHw@mail.gmail.com","threadId":"29218","inReplyTo":"7vvcp9hjam.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 4/4] Suppress \"statement not reached\" warnings under Sun Studio","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2011-12-21T19:03:47Z","receivedAt":"2011-12-21T19:03:47Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Wed, Dec 21, 2011 at 19:27, Junio C Hamano <gitster@pobox.com> wrote:\n> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>\n>> diff --git a/read-cache.c b/read-cache.c\n>> index a51bba1..0a4e895 100644\n>> --- a/read-cache.c\n>> +++ b/read-cache.c\n>> @@ -758,7 +758,13 @@ int verify_path(const char *path)\n>>               return 0;\n>>\n>>       goto inside;\n>> +#ifdef __sun\n>> +#    pragma error_messages (off, E_STATEMENT_NOT_REACHED)\n>> +#endif\n>>       for (;;) {\n>> +#ifdef __sun\n>> +#    pragma error_messages (on, E_STATEMENT_NOT_REACHED)\n>> +#endif\n>>               if (!c)\n>>                       return 1;\n>\n> Patches 1-3 makes sense, but this one is too ugly to live.\n>\n> Wouldn't something like this be equivalent and have the same effect\n> without sacrificing the readablity?\n>\n> diff --git a/read-cache.c b/read-cache.c\n> index a51bba1..73af797 100644\n> --- a/read-cache.c\n> +++ b/read-cache.c\n> @@ -757,12 +757,12 @@ int verify_path(const char *path)\n>        if (has_dos_drive_prefix(path))\n>                return 0;\n>\n> -       goto inside;\n> +       /* we are at the beginning of a path component */\n> +       c = '/';\n>        for (;;) {\n>                if (!c)\n>                        return 1;\n>                if (is_dir_sep(c)) {\n> -inside:\n>                        c = *path++;\n>                        if ((c == '.' && !verify_dotfile(path)) ||\n>                            is_dir_sep(c) || c == '\\0')\n\nThat would make that warning go away, but I don't know if that changes\nthe semantics of the code. I was aiming not to change any code, just\nto squash spurious warnings under Sun Studio.\n\nWe could also just wrap the whole function definition in the pragma,\nwhich would make the code more readable since we wouldn't have 6 lines\nof warning suppression in the middle of the function.\n\nOr we could just drop this patch entirely, or rewrite the code. Your\npick.\n"},{"id":"181598","messageId":"7vk45pfyj6.fsf@alter.siamese.dyndns.org","threadId":"29218","inReplyTo":"CACBZZX4htZRQH+2xvoskwE7KoTz98Ox-3xQf0hyEbbFDYCZYHw@mail.gmail.com","subject":"Re: [PATCH 4/4] Suppress \"statement not reached\" warnings under Sun Studio","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-12-21T20:41:17Z","receivedAt":"2011-12-21T20:41:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> That would make that warning go away, but I don't know if that changes\n> the semantics of the code. I was aiming not to change any code, just\n> to squash spurious warnings under Sun Studio.\n\nWell, earlier we skipped \"if it is NUL return 1 and otherwise make sure it\nis a directory separator\" check and went directly into whatever happens\nafter we see a directory separator. The patch causes the same without goto.\n\nIf the code is too complex to confuse not so bright compilers, it is\nlikely to confuse no so bright humans as well, and rewriting the logic in\na more straightforward way to help humans is independently a good thing.\n\nI am not particularly interested in squashing spurious warnings, but if it\nfalls out of a side effect of helping humans, I wouldn't object to it.\n"}]}