bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] maint: placate gcc's -Wjump-misses-init warning


From: Jim Meyering
Subject: [PATCH] maint: placate gcc's -Wjump-misses-init warning
Date: Wed, 03 Oct 2012 10:51:02 +0200

Without the following, gcc 4.8.0 20121002 complains:

    kwsearch.c: In function 'Fexecute':
    kwsearch.c:158:3: error: jump skips variable initialization\
      [-Werror=jump-misses-init]
       goto out;
       ^
    kwsearch.c:174:2: note: label 'out' defined here
      out:
      ^
    kwsearch.c:169:10: note: 'off' declared here
       size_t off = beg - buf;
              ^
    dfasearch.c: In function 'EGexecute':
    dfasearch.c:416:3: error: jump skips variable initialization\
      [-Werror=jump-misses-init]
       goto out;
       ^
    dfasearch.c:425:2: note: label 'out' defined here
      out:
      ^
    dfasearch.c:421:10: note: 'off' declared here
       size_t off = beg - buf;
              ^
    ...

>From d083d8f38bfc344d39196f2825cf43b032bd070b Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sun, 2 Sep 2012 10:45:48 +0200
Subject: [PATCH] maint: placate gcc's -Wjump-misses-init warning

* src/kwsearch.c (Fexecute): Replace a "goto" and "return" with
a simple return statement, eliminating the label, since that was
the sole use.
* src/dfasearch.c (EGexecute): Likewise.
---
 src/dfasearch.c | 4 +---
 src/kwsearch.c  | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/dfasearch.c b/src/dfasearch.c
index eaf783e..dfe6fcc 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -412,8 +412,7 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
     } /* for (beg = end ..) */

  failure:
-  ret_val = -1;
-  goto out;
+  return -1;

  success:
   len = end - beg;
@@ -422,6 +421,5 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
   mb_case_map_apply (map, &off, &len);
   *match_size = len;
   ret_val = off;
- out:
   return ret_val;
 }
diff --git a/src/kwsearch.c b/src/kwsearch.c
index b56b465..96da58e 100644
--- a/src/kwsearch.c
+++ b/src/kwsearch.c
@@ -154,8 +154,7 @@ Fexecute (char const *buf, size_t size, size_t *match_size,
     } /* for (beg in buf) */

  failure:
-  ret_val = -1;
-  goto out;
+  return -1;

  success:
   if ((end = memchr (beg + len, eol, (buf + size) - (beg + len))) != NULL)
@@ -171,6 +170,5 @@ Fexecute (char const *buf, size_t size, size_t *match_size,

   *match_size = len;
   ret_val = off;
- out:
   return ret_val;
 }
--
1.7.12.1.382.gb0576a6



reply via email to

[Prev in Thread] Current Thread [Next in Thread]