git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/4] Suppress "statement not reached" warnings under Sun Studio

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Dec 21, 2011, 01:18 UTC
Message-ID
<1324430302-22441-5-git-send-email-avarab@gmail.com>
In-Reply-To
<1324430302-22441-1-git-send-email-avarab@gmail.com>

Sun Studio 12 Update 1's brain will melt on these two occurances of using "goto" to jump into a loop. It'll emit these warnings:

    "read-cache.c", line 761: warning: statement not reached (E_STATEMENT_NOT_REACHED)
    "xdiff/xutils.c", line 194: warning: statement not reached (E_STATEMENT_NOT_REACHED)

Suppress these warnings by using a Sun Studio specific pragma directive to turn them off, but only do so if __sun is defined, which is the macro Sun Studio uses to identify itself under both its C and C++ variants, see http://developers.sun.com/sunstudio/products/faqs/cpp.html

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 read-cache.c   |    6 ++++++
 xdiff/xutils.c |    6 ++++++
 2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/read-cache.c b/read-cache.c
index a51bba1..0a4e895 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -758,7 +758,13 @@ int verify_path(const char *path)
 		return 0;
 
 	goto inside;
+#ifdef __sun
+#	pragma error_messages (off, E_STATEMENT_NOT_REACHED)
+#endif
 	for (;;) {
+#ifdef __sun
+#	pragma error_messages (on, E_STATEMENT_NOT_REACHED)
+#endif
 		if (!c)
 			return 1;
 		if (is_dir_sep(c)) {
diff --git a/xdiff/xutils.c b/xdiff/xutils.c
index 0de084e..62c3567 100644
--- a/xdiff/xutils.c
+++ b/xdiff/xutils.c
@@ -191,7 +191,13 @@ int xdl_recmatch(const char *l1, long s1, const char *l2, long s2, long flags)
 	 */
 	if (flags & XDF_IGNORE_WHITESPACE) {
 		goto skip_ws;
+#ifdef __sun
+#	pragma error_messages (off, E_STATEMENT_NOT_REACHED)
+#endif
 		while (i1 < s1 && i2 < s2) {
+#ifdef __sun
+#	pragma error_messages (on, E_STATEMENT_NOT_REACHED)
+#endif
 			if (l1[i1++] != l2[i2++])
 				return 0;
 		skip_ws:
-- 
1.7.7.3
Previous: Ævar Arnfjörð BjarmasonNext: Junio C Hamano
Message 5 of 8 in “Eliminate warnings under Sun Studio”
  1. 0/4 Eliminate warnings under Sun StudioÆvar Arnfjörð Bjarmason, Dec 21, 2011
  2. 1/4 Fix an enum assignment issue spotted by Sun StudioÆvar Arnfjörð Bjarmason, Dec 21, 2011
  3. 2/4 Fix a bitwise negation assignment issue spotted by Sun StudioÆvar Arnfjörð Bjarmason, Dec 21, 2011
  4. 3/4 Appease Sun Studio by renaming "tmpfile"Ævar Arnfjörð Bjarmason, Dec 21, 2011
  5. 4/4 Suppress "statement not reached" warnings under Sun StudioÆvar Arnfjörð Bjarmason, Dec 21, 2011
  6. Junio C HamanoDec 21, 2011
  7. Ævar Arnfjörð BjarmasonDec 21, 2011
  8. Junio C HamanoDec 21, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.