Re: [PATCH 3/5] diff --color-moved-ws: fix a memory leak

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

 



On Tue, 2 Oct 2018 at 20:04, Phillip Wood <phillip.wood@xxxxxxxxxxxx> wrote:
>         const struct emitted_diff_symbol *longer =  a->len > b->len ? a : b;
>         const struct emitted_diff_symbol *shorter = a->len > b->len ? b : a;
>         int d = longer->len - shorter->len;
> +       int ret = !strncmp(longer->line + d, shorter->line, shorter->len);
> +
> +       if (!ret)
> +               return ret;
>
>         out->string = xmemdupz(longer->line, d);
>         out->current_longer = (a == longer);
>
> -       return !strncmp(longer->line + d, shorter->line, shorter->len);
> +       return ret;
>  }

The caller only cares about 0 vs non-0, so this would also work:

   if (strncmp(...))
           return 0;

   ...

   return 1;

Just a thought, to avoid some "!"s and the new variable `ret`.

Martin



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux