]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
DBusTransport: be explicit about _dbus_auth_do_work() results
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Tue, 17 Jan 2017 20:50:08 +0000 (20:50 +0000)
committerSimon McVittie <smcv@collabora.com>
Fri, 7 Apr 2017 13:02:13 +0000 (14:02 +0100)
Explicitly enumerate the states where we reset the maybe_authenticated
flag, and assert that _dbus_auth_do_work() doesn't return an impossible
or invalid state (by source code inspection, it doesn't).

This silences -Wswitch-enum. Based on part of a patch from
Thomas Zimmermann.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=98191

dbus/dbus-transport.c

index b1932c32e678d5fa93aad1d9a226dcfa0252ed39..69e2241d7296c0f9d9857927b17004892363108c 100644 (file)
@@ -749,8 +749,17 @@ _dbus_transport_try_to_authenticate (DBusTransport *transport)
             case DBUS_AUTH_STATE_AUTHENTICATED:
               /* leave as maybe_authenticated */
               break;
-            default:
+
+            case DBUS_AUTH_STATE_WAITING_FOR_INPUT:
+            case DBUS_AUTH_STATE_WAITING_FOR_MEMORY:
+            case DBUS_AUTH_STATE_HAVE_BYTES_TO_SEND:
+            case DBUS_AUTH_STATE_NEED_DISCONNECT:
               maybe_authenticated = FALSE;
+              break;
+
+            case DBUS_AUTH_STATE_INVALID:
+            default:
+              _dbus_assert_not_reached ("invalid authentication state");
             }
         }