[glib/wip/otte/fallthrough: 2/3] Use G_GNUC_FALLTHROUGH where appropriate



commit 3aff811d13f245af1ff3c33d6247c16cd5dd6a52
Author: Benjamin Otte <otte redhat com>
Date:   Sun Sep 2 20:47:32 2018 +0200

    Use G_GNUC_FALLTHROUGH where appropriate

 gio/tests/data-output-stream.c | 2 ++
 gio/tests/sleepy-stream.c      | 2 ++
 glib/gbase64.c                 | 7 +++++--
 glib/gconvert.c                | 3 ++-
 glib/gmarkup.c                 | 2 ++
 glib/gregex.c                  | 1 +
 glib/gtimezone.c               | 2 ++
 glib/gvariant-parser.c         | 9 +++++----
 8 files changed, 21 insertions(+), 7 deletions(-)
---
diff --git a/gio/tests/data-output-stream.c b/gio/tests/data-output-stream.c
index b656b2744..0872edf9c 100644
--- a/gio/tests/data-output-stream.c
+++ b/gio/tests/data-output-stream.c
@@ -166,9 +166,11 @@ test_data_array (guchar *buffer, gsize len,
     case TEST_DATA_INT16:
     case TEST_DATA_UINT16:
       g_assert_cmpint (len % 2, ==, 0);
+      G_GNUC_FALLTHROUGH;
     case TEST_DATA_INT32:
     case TEST_DATA_UINT32:
       g_assert_cmpint (len % 4, ==, 0);
+      G_GNUC_FALLTHROUGH;
     case TEST_DATA_INT64:
     case TEST_DATA_UINT64:
       g_assert_cmpint (len % 8, ==, 0);
diff --git a/gio/tests/sleepy-stream.c b/gio/tests/sleepy-stream.c
index c80871684..664fb3b02 100644
--- a/gio/tests/sleepy-stream.c
+++ b/gio/tests/sleepy-stream.c
@@ -33,12 +33,14 @@ cook_piece (void)
         {
          case 26:
           buffer[i++] = '\n';
+          G_GNUC_FALLTHROUGH;
          case 27:
           buffer[i++] = '\r';
           break;
 
          case 28:
           buffer[i++] = '\r';
+          G_GNUC_FALLTHROUGH;
          case 29:
           buffer[i++] = '\n';
           break;
diff --git a/glib/gbase64.c b/glib/gbase64.c
index 7d8b20dee..ae9d5fef5 100644
--- a/glib/gbase64.c
+++ b/glib/gbase64.c
@@ -170,8 +170,11 @@ g_base64_encode_step (const guchar *in,
       /* len can only be 0 1 or 2 */
       switch(len)
         {
-        case 2: *saveout++ = *inptr++;
-        case 1: *saveout++ = *inptr++;
+        case 2:
+          *saveout++ = *inptr++;
+          G_GNUC_FALLTHROUGH;
+        case 1:
+          *saveout++ = *inptr++;
         }
       ((char *)save)[0] += len;
     }
diff --git a/glib/gconvert.c b/glib/gconvert.c
index 50286478c..3f6621b2a 100644
--- a/glib/gconvert.c
+++ b/glib/gconvert.c
@@ -788,7 +788,8 @@ g_convert_with_fallback (const gchar *str,
                  inbytes_remaining = strlen (p);
                  break;
                }
-             /* fall thru if p is NULL */
+              /* if p is null */
+              G_GNUC_FALLTHROUGH;
            default:
               {
                 int errsv = errno;
diff --git a/glib/gmarkup.c b/glib/gmarkup.c
index f1ab94e56..43bb0c7f8 100644
--- a/glib/gmarkup.c
+++ b/glib/gmarkup.c
@@ -2872,6 +2872,8 @@ failure:
             case G_MARKUP_COLLECT_STRDUP:
               if (written)
                 g_free (*(char **) ptr);
+              *(char **) ptr = NULL;
+              break;
 
             case G_MARKUP_COLLECT_STRING:
               *(char **) ptr = NULL;
diff --git a/glib/gregex.c b/glib/gregex.c
index f49aaaefc..f004c1f8a 100644
--- a/glib/gregex.c
+++ b/glib/gregex.c
@@ -2537,6 +2537,7 @@ expand_escape (const gchar        *replacement,
           base = 8;
           p = g_utf8_next_char (p);
         }
+      G_GNUC_FALLTHROUGH;
     case '1':
     case '2':
     case '3':
diff --git a/glib/gtimezone.c b/glib/gtimezone.c
index b3220dc35..df40d852d 100644
--- a/glib/gtimezone.c
+++ b/glib/gtimezone.c
@@ -372,6 +372,8 @@ parse_constant_offset (const gchar *name,
           *offset = -*offset;
           return TRUE;
         }
+      else
+        return FALSE;
 
     default:
       return FALSE;
diff --git a/glib/gvariant-parser.c b/glib/gvariant-parser.c
index 335c71425..f9e296dbe 100644
--- a/glib/gvariant-parser.c
+++ b/glib/gvariant-parser.c
@@ -210,10 +210,7 @@ token_stream_prepare (TokenStream *stream)
           break;
         }
 
-      else
-        {
-          /* ↓↓↓ */
-        }
+      G_GNUC_FALLTHROUGH;
 
     case 'a': /* 'b' */ case 'c': case 'd': case 'e': case 'f':
     case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
@@ -1646,6 +1643,8 @@ string_parse (TokenStream  *stream,
           case '\n': i++; continue;
           }
 
+        G_GNUC_FALLTHROUGH;
+
       default:
         str[j++] = token[i++];
       }
@@ -1773,6 +1772,8 @@ bytestring_parse (TokenStream  *stream,
           case '\n': i++; continue;
           }
 
+        G_GNUC_FALLTHROUGH;
+
       default:
         str[j++] = token[i++];
       }


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