[Spice-devel] [PATCH] covscan: add comment on false-positive on g_memdup()
Uri Lublin
uril at redhat.com
Wed Aug 28 06:27:56 UTC 2019
On 8/27/19 6:16 PM, Victor Toso wrote:
> From: Victor Toso <me at victortoso.com>
>
> Previous commit set last element of orig_argv array to NULL.
> That's redundant as g_memdup() uses memcpy() and it would do
> just that. Add a comment that the reason for this change is
> to workaround clang's warning.
>
> Suggested by Uri.
> Signed-off-by: Victor Toso <victortoso at redhat.com>
Acked-by: Uri Lublin <uril at redhat.com>
Thanks,
Uri.
> ---
> src/vdagent/vdagent.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/src/vdagent/vdagent.c b/src/vdagent/vdagent.c
> index 5b146db..a944214 100644
> --- a/src/vdagent/vdagent.c
> +++ b/src/vdagent/vdagent.c
> @@ -418,10 +418,8 @@ int main(int argc, char *argv[])
> GOptionContext *context;
> GError *error = NULL;
> VDAgent *agent;
> - char **orig_argv;
> -
> - orig_argv = g_memdup(argv, sizeof(char*) * (argc+1));
> - orig_argv[argc] = NULL;
> + char **orig_argv = g_memdup(argv, sizeof(char*) * (argc+1));
> + orig_argv[argc] = NULL; /* To avoid clang analyzer false-positive */
>
> context = g_option_context_new(NULL);
> g_option_context_add_main_entries(context, entries, NULL);
>
More information about the Spice-devel
mailing list