Re: [PATCH 3/5] add helper handle_simple_switch()

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

 



I have some very minor comment.

On Wed, Apr 12, 2017 at 1:37 AM, Luc Van Oostenryck
<luc.vanoostenryck@xxxxxxxxx> wrote:
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
> ---
>  lib.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>
> diff --git a/lib.c b/lib.c
> index 8c9c36bd5..1d21a2fb7 100644
> --- a/lib.c
> +++ b/lib.c
> @@ -454,6 +454,25 @@ static void handle_arch_finalize(void)
>  }
>
>
> +static int handle_simple_switch(const char *arg, const char *name, int *flag)
> +{
> +       int val = 1;
> +
> +       // Prefixe "no-" mean to turn flag off.
> +       if (strncmp(arg, "no-", 3) == 0) {

You don't need to compare to zero. This can be written as:
 if (!strncmp(arg, "no-", 3)) {

That is how most of the strcmp done in sparse.

> +       if (strcmp(arg, name) == 0) {
> +               *flag = val;
> +               return 1;
> +       }

Same here.

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



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux