Re: Unnecessary pointer-NULL checks in pgp-pgsql.c

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: Unnecessary pointer-NULL checks in pgp-pgsql.c
Дата
Msg-id CA+TgmobLEbhP4z7N8vb939Oyyb8EWOKFWDL3o2hO3m40S4YwPg@mail.gmail.com
обсуждение исходный текст
Ответ на Unnecessary pointer-NULL checks in pgp-pgsql.c  (Michael Paquier <michael.paquier@gmail.com>)
Ответы Re: Unnecessary pointer-NULL checks in pgp-pgsql.c  (Michael Paquier <michael.paquier@gmail.com>)
Список pgsql-hackers
On Sun, Feb 1, 2015 at 9:14 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:
> Coverity is pointing out that we are doing pointer-NULL checks on
> things that cannot be NULL in decrypt_internal():
>  out:
> -       if (src)
> -               mbuf_free(src);
> -       if (ctx)
> -               pgp_free(ctx);
> +       Assert(ctx != NULL && src != NULL && dst != NULL);
> +       mbuf_free(src);
> +       pgp_free(ctx);
>
>         if (err)
>         {
>                 px_set_debug_handler(NULL);
> -               if (dst)
> -                       mbuf_free(dst);
> +               mbuf_free(dst);
>
> src, dst and ctx are created respectively from mbuf_create_from_data,
> mbuf_create and pgp_init which never return NULL and they are palloc'd
> all the time. I think that we could simplify things with the patch
> attached, note that I added an assertion for correctness but I don't
> really think that it is much necessary.

Yeah, I'd drop the assertion.  Also, how about changing things around
slightly so that we lose the goto-label construct?  There's only one
goto, and its only about 6 lines before the label, so we could just
flip the sense of the if-test and put the code that gets skipped
inside the if-block.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: Proposal : REINDEX xxx VERBOSE
Следующее
От: Robert Haas
Дата:
Сообщение: Re: REINDEX CONCURRENTLY 2.0