<div dir="ltr"><div>thank you.<br></div>sorry for false positive<br></div><div class="gmail_extra"><br><div class="gmail_quote">2018-04-09 12:43 GMT+05:00 Michal Srb <span dir="ltr"><<a href="mailto:msrb@suse.com" target="_blank">msrb@suse.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On pondělí 9. dubna 2018 9:31:54 CEST Ilya Shipitsin wrote:<br>
> [dix/inpututils.c:909] -> [dix/inpututils.c:905]: (warning) Either the<br>
> condition 'if(list)' is redundant or there is possible null pointer<br>
> dereference: list.<br>
<br>
</span>I think this is a false positive by cppcheck. It looks like it misinterprets<br>
the `list.next` in the macro as dereferencing the `list` variable.<br>
<br>
The `nt_list_init(opt, list.next)` macro expands to:<br>
<br>
  (opt)->list.next = NULL<br>
<br>
So wrapping it in the `if (list)` condition is not correct.<br>
<span class="HOEnZb"><font color="#888888"><br>
Michal Srb<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
> ---<br>
>  dix/inpututils.c | 4 +++-<br>
>  1 file changed, 3 insertions(+), 1 deletion(-)<br>
><br>
> diff --git a/dix/inpututils.c b/dix/inpututils.c<br>
> index 6bff9efab..f4c386a24 100644<br>
> --- a/dix/inpututils.c<br>
> +++ b/dix/inpututils.c<br>
> @@ -902,7 +902,9 @@ input_option_new(InputOption *list, const char *key,<br>
> const char *value) if (!opt)<br>
>          return NULL;<br>
><br>
> -    nt_list_init(opt, list.next);<br>
> +    if (list)<br>
> +        nt_list_init(opt, list.next);<br>
> +<br>
>      input_option_set_key(opt, key);<br>
>      input_option_set_value(opt, value);<br>
<br>
<br>
</div></div></blockquote></div><br></div>