From 21eb3317c569cfd02d799aa67ae3ecf611373cab Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 13 Oct 2016 23:09:34 +0100 Subject: [PATCH] Move defaults for some switches into a default case This is clearly equivalent, and quiets -Wswitch-default. Based on part of a patch by Thomas Zimmermann. Signed-off-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=98191 --- bus/config-parser-common.c | 7 +++---- dbus/dbus-credentials.c | 6 +++--- dbus/dbus-memory.c | 5 +++-- dbus/dbus-sysdeps-win.c | 5 +++-- dbus/dbus-sysdeps.c | 4 ++-- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/bus/config-parser-common.c b/bus/config-parser-common.c index 5db6b28..c1c4191 100644 --- a/bus/config-parser-common.c +++ b/bus/config-parser-common.c @@ -187,10 +187,9 @@ bus_config_parser_element_type_to_name (ElementType type) return "allow_anonymous"; case ELEMENT_APPARMOR: return "apparmor"; + default: + _dbus_assert_not_reached ("bad element type"); + return NULL; } - - _dbus_assert_not_reached ("bad element type"); - - return NULL; } diff --git a/dbus/dbus-credentials.c b/dbus/dbus-credentials.c index 151bb00..5fa754c 100644 --- a/dbus/dbus-credentials.c +++ b/dbus/dbus-credentials.c @@ -267,10 +267,10 @@ _dbus_credentials_include (DBusCredentials *credentials, return credentials->linux_security_label != NULL; case DBUS_CREDENTIAL_ADT_AUDIT_DATA_ID: return credentials->adt_audit_data != NULL; + default: + _dbus_assert_not_reached ("Unknown credential enum value"); + return FALSE; } - - _dbus_assert_not_reached ("Unknown credential enum value"); - return FALSE; } /** diff --git a/dbus/dbus-memory.c b/dbus/dbus-memory.c index bba9884..a9c2f7a 100644 --- a/dbus/dbus-memory.c +++ b/dbus/dbus-memory.c @@ -334,9 +334,10 @@ source_string (BlockSource source) return "malloc0"; case SOURCE_REALLOC_NULL: return "realloc(NULL)"; + default: + _dbus_assert_not_reached ("Invalid malloc block source ID"); + return "invalid!"; } - _dbus_assert_not_reached ("Invalid malloc block source ID"); - return "invalid!"; } static void diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 343a51d..77c5b74 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -323,9 +323,10 @@ _dbus_win_error_from_last_error (void) case ERROR_FILE_NOT_FOUND: case ERROR_PATH_NOT_FOUND: return DBUS_ERROR_FILE_NOT_FOUND; + + default: + return DBUS_ERROR_FAILED; } - - return DBUS_ERROR_FAILED; } diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index d1a96d1..20bb894 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -670,9 +670,9 @@ _dbus_error_from_errno (int error_number) case ENOENT: return DBUS_ERROR_FILE_NOT_FOUND; #endif + default: + return DBUS_ERROR_FAILED; } - - return DBUS_ERROR_FAILED; } /** -- 2.7.4