client: Fix AutoConnect configuration
authorJustin Maggard <jmaggard10@gmail.com>
Thu, 20 Sep 2012 23:12:36 +0000 (16:12 -0700)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Mon, 24 Sep 2012 09:26:08 +0000 (12:26 +0300)
Changing the AutoConnect setting via connmanctl does not work, due to the
mistaken use of || instead of &&.

This patch fixes the issue, and tries to make things a little more readable.

client/commands.c

index 0caacd96656c3f914b0fa117e318f392455b9481..22d5b3c815ad1b688fa443b569a99e0de14d18cb 100644 (file)
@@ -134,16 +134,20 @@ int config_switch(int argc, char *argv[], int c, DBusConnection *conn)
 
        switch (c) {
        case 'a':
-               if (*optarg != 'y' || *optarg != 'n' || *optarg != '1' ||
-                                       *optarg != '0' || *optarg != 't' ||
-                                                       *optarg != 'f')
-                       return -EINVAL;
-               if (*optarg == 'y' || *optarg == '1' ||
-                                               *optarg == 't')
+               switch (*optarg) {
+               case 'y':
+               case '1':
+               case 't':
                        val = TRUE;
-               else if (*optarg == 'n' || *optarg == '0' ||
-                                               *optarg == 'f')
+                       break;
+               case 'n':
+               case '0':
+               case 'f':
                        val = FALSE;
+                       break;
+               default:
+                       return -EINVAL;
+               }
                error = set_service_property(conn, message, argv[1],
                                                "AutoConnect", NULL,
                                                &val, 0);