From a718ebac867c1141580fe1e815071ca4e00d763c Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Sun, 29 Jul 2018 17:13:16 +0200 Subject: [PATCH] build: enable -Wswitch-default In case the surrounding code handles missing cases break, otherwise add a g_assert_not_reached(). The generated parser code triggers this as well, so disable it there only. --- gicallableinfo.c | 2 ++ giconstantinfo.c | 2 ++ gifieldinfo.c | 8 ++++++++ girffi.c | 2 ++ girnode.c | 4 ++++ girparser.c | 2 ++ girwriter.c | 4 ++++ 7 files changed, 24 insertions(+) diff --git a/gicallableinfo.c b/gicallableinfo.c index 5f923d1a9..e9a426e15 100644 --- a/gicallableinfo.c +++ b/gicallableinfo.c @@ -77,6 +77,8 @@ signature_offset (GICallableInfo *info) case GI_INFO_TYPE_SIGNAL: sigoff = G_STRUCT_OFFSET (SignalBlob, signature); break; + default: + g_assert_not_reached (); } if (sigoff >= 0) return *(guint32 *)&rinfo->typelib->data[rinfo->offset + sigoff]; diff --git a/giconstantinfo.c b/giconstantinfo.c index 60715a4b6..d44646ee7 100644 --- a/giconstantinfo.c +++ b/giconstantinfo.c @@ -166,6 +166,8 @@ g_constant_info_get_value (GIConstantInfo *info, case GI_TYPE_TAG_DOUBLE: DO_ALIGNED_COPY(&value->v_double, &rinfo->typelib->data[blob->offset], gdouble); break; + default: + g_assert_not_reached (); } } } diff --git a/gifieldinfo.c b/gifieldinfo.c index ea64dabbd..4d07304e3 100644 --- a/gifieldinfo.c +++ b/gifieldinfo.c @@ -337,12 +337,16 @@ g_field_info_get_field (GIFieldInfo *field_info, g_base_info_get_name ((GIBaseInfo *)field_info), g_base_info_get_type (interface)); break; + default: + break; } g_base_info_unref ((GIBaseInfo *)interface); break; } break; + default: + break; } } @@ -513,12 +517,16 @@ g_field_info_set_field (GIFieldInfo *field_info, g_base_info_get_name ((GIBaseInfo *)field_info), g_base_info_get_type (interface)); break; + default: + break; } g_base_info_unref ((GIBaseInfo *)interface); break; } break; + default: + break; } } else { switch (g_type_info_get_tag (type_info)) diff --git a/girffi.c b/girffi.c index 30642fe18..86a13052e 100644 --- a/girffi.c +++ b/girffi.c @@ -102,6 +102,8 @@ gi_type_tag_get_ffi_type_internal (GITypeTag tag, return &ffi_type_pointer; else return &ffi_type_void; + default: + break; } g_assert_not_reached (); diff --git a/girnode.c b/girnode.c index fb21c2884..decd84201 100644 --- a/girnode.c +++ b/girnode.c @@ -923,6 +923,8 @@ _g_ir_node_can_have_member (GIrNode *node) case G_IR_NODE_FIELD: case G_IR_NODE_XREF: return FALSE; + default: + g_assert_not_reached (); }; return FALSE; } @@ -2305,6 +2307,8 @@ _g_ir_node_build_typelib (GIrNode *node, blob->size = strlen (constant->value) + 1; memcpy (&data[blob->offset], constant->value, blob->size); break; + default: + g_assert_not_reached (); } *offset2 += ALIGN_VALUE (blob->size, 4); diff --git a/girparser.c b/girparser.c index 893a9a4eb..97e62a533 100644 --- a/girparser.c +++ b/girparser.c @@ -3092,6 +3092,8 @@ start_element_handler (GMarkupParseContext *context, ctx, error)) goto out; break; + default: + break; } if (*error == NULL && ctx->state != STATE_PASSTHROUGH) diff --git a/girwriter.c b/girwriter.c index bb82a46f6..7b255423f 100644 --- a/girwriter.c +++ b/girwriter.c @@ -505,6 +505,8 @@ write_callable_info (const gchar *namespace, case GI_DIRECTION_INOUT: xml_printf (file, " direction=\"inout\""); break; + default: + g_assert_not_reached (); } if (g_arg_info_may_be_null (arg)) @@ -529,6 +531,8 @@ write_callable_info (const gchar *namespace, case GI_SCOPE_TYPE_NOTIFIED: xml_printf (file, " scope=\"notified\""); break; + default: + g_assert_not_reached (); } if (g_arg_info_get_closure (arg) >= 0)