Re: [HACKERS] [PATCH] Suppress Clang 3.9 warnings - Mailing list pgsql-hackers

From Aleksander Alekseev
Subject Re: [HACKERS] [PATCH] Suppress Clang 3.9 warnings
Date
Msg-id 20170313153553.GB2564@e733.localdomain
Whole thread Raw
In response to Re: [HACKERS] [PATCH] Suppress Clang 3.9 warnings  (David Steele <david@pgmasters.net>)
Responses Re: [HACKERS] [PATCH] Suppress Clang 3.9 warnings  (Noah Misch <noah@leadboat.com>)
Re: [HACKERS] [PATCH] Suppress Clang 3.9 warnings  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
List pgsql-hackers
Hi David,

Thank you for reminding about this patch!

Here is a new patch. I tried to make as little changes as possible. This
is no doubt not the most beautiful patch on Earth but it removes all
warnings. I anyone could suggest an approach that would be significantly
better please don't hesitate to share your ideas.

Tested on Clang 3.9.1 and GCC 6.3.1.

> Why not update the target type to "unsigned char" instead, so that no
> cast is needed and the value compatibility is checked by the compiler? I
> guess there would be some more changes (question is how much), but it
> would be cleaner.

I tried this way as well. After rebuilding PostgreSQL in 5th time I
discovered that now I have to redefine a Poiner typedef. I don't think
we can avoid using type casts. There will be just different type casts
in other places, or we'll have to break most of existing PostgreSQL
extensions.

On Mon, Mar 13, 2017 at 10:19:57AM -0400, David Steele wrote:
> Hi Aleksander,
>
> On 2/22/17 9:43 AM, Fabien COELHO wrote:
> >
> > Hello Aleksander,
> >
> >> ```
> >> xloginsert.c:742:18: warning: implicit conversion from 'int' to 'char'
> >> changes value from 253 to -3 [-Wconstant-conversion]
> >> ```
> >
> > There is a bunch of these in "xlog.c" as well, and the same code is used
> > in "pg_resetwal.c".
> >
> >> Patch that fixes these warnings is attached to this email.
> >
> > My 0.02€:
> >
> > I'm not at ease at putting the thing bluntly under the carpet with a cast.
> >
> > Why not update the target type to "unsigned char" instead, so that no
> > cast is needed and the value compatibility is checked by the compiler? I
> > guess there would be some more changes (question is how much), but it
> > would be cleaner.
>
> There's been no discussion or new patch on this thread recently.  If you
> are planning to address the issues raised please plan to do so by
> Thursday, March 16th.
>
> If no new patch is submitted by that date I will mark this patch
> "Returned with Feedback".
>
> Thanks,
> --
> -David
> david@pgmasters.net

--
Best regards,
Aleksander Alekseev

Attachment

pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: [HACKERS] [COMMITTERS] pgsql: Improve postmaster's logging oflisten socket creation.
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] [COMMITTERS] pgsql: Improve postmaster's logging of listen socket creation.