Re: [PATCH BlueZ 5/6] client: Introduce parse_argument()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Eramoto,

On Fri, Sep 22, 2017 at 3:20 PM, ERAMOTO Masaya
<eramoto.masaya@xxxxxxxxxxxxxx> wrote:
> ---
>  client/main.c | 38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
>
> diff --git a/client/main.c b/client/main.c
> index 7b24633..1c34269 100644
> --- a/client/main.c
> +++ b/client/main.c
> @@ -845,6 +845,44 @@ static gboolean check_default_ctrl(void)
>         return TRUE;
>  }
>
> +static gboolean parse_argument(const char *arg, const char * const *arg_table,
> +                                       const char *msg, dbus_bool_t *value,
> +                                       const char **option)
> +{
> +       const char * const *opt;
> +
> +       if (!arg || !strlen(arg)) {
> +               if (msg)
> +                       rl_printf("Missing on/off/%s argument\n", msg);
> +               else
> +                       rl_printf("Missing on/off argument\n");
> +               return FALSE;
> +       }
> +
> +       if (!strcmp(arg, "on") || !strcmp(arg, "yes")) {
> +               *value = TRUE;
> +               if (option)
> +                       *option = "";
> +               return TRUE;
> +       }
> +
> +       if (!strcmp(arg, "off") || !strcmp(arg, "no")) {
> +               *value = FALSE;
> +               return TRUE;
> +       }
> +
> +       for (opt = arg_table; opt && *opt; opt++) {
> +               if (strcmp(arg, *opt) == 0) {
> +                       *value = TRUE;
> +                       *option = *opt;
> +                       return TRUE;
> +               }
> +       }
> +
> +       rl_printf("Invalid argument %s\n", arg);
> +       return FALSE;
> +}
> +
>  static gboolean parse_argument_on_off(const char *arg, dbus_bool_t *value)
>  {
>         if (!arg || !strlen(arg)) {
> --
> 2.7.4

This one if applied separately would break bisect:

client/main.c:848:17: error: ‘parse_argument’ defined but not used
[-Werror=unused-function]
 static gboolean parse_argument(const char *arg, const char * const *arg_table,
                 ^~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Lets have it merged with 6/6.


>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Luiz Augusto von Dentz
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux