[PATCH] client: Fix AutoConnect configuration
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 | 20 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/client/commands.c b/client/commands.c index 0caacd9..22d5b3c 100644 --- a/client/commands.c +++ b/client/commands.c @@ -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); -- 1.7.9.5 ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
Re: [PATCH] client: Fix AutoConnect configuration
On Thu, Sep 20, 2012 at 4:12 PM, Justin Maggard wrote: > 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 | 20 > 1 file changed, 12 insertions(+), 8 deletions(-) > > diff --git a/client/commands.c b/client/commands.c > index 0caacd9..22d5b3c 100644 > --- a/client/commands.c > +++ b/client/commands.c > @@ -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); > -- > 1.7.9.5 Thanks, that indeed looks a lot better. Auke ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
Re: [PATCH] client: Fix AutoConnect configuration
On Thu, 2012-09-20 at 16:12 -0700, Justin Maggard wrote: > 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. Patch has been applied, many thanks! Patrik ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman