This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, libiberty]: Avoid 'right-hand operand of comma expression has no effect' when compiling regex.c
- From: Ian Lance Taylor <iant at google dot com>
- To: Uros Bizjak <ubizjak at gmail dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 13 Mar 2014 11:32:11 -0700
- Subject: Re: [PATCH, libiberty]: Avoid 'right-hand operand of comma expression has no effect' when compiling regex.c
- Authentication-results: sourceware.org; auth=none
- References: <CAFULd4YHE2++2ZJAg2+gxdT8tso=-4ha3VsGLYhaB3TBLoCXxg at mail dot gmail dot com> <CAKOQZ8yEJZef+K1LZQMrnBGWzPZzhdWH9wKr0L3pnfFpvA1eZg at mail dot gmail dot com> <CAFULd4bNLCfTKBmszA6i81mPm74L4NgZN3GKzeQZ1Mq7Ko06fA at mail dot gmail dot com>
On Thu, Mar 13, 2014 at 11:24 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Thu, Mar 13, 2014 at 6:30 PM, Ian Lance Taylor <iant@google.com> wrote:
>> On Thu, Mar 13, 2014 at 3:36 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
>>>
>>> Attached patch changes the return value of the bzero macro to void, as
>>> defined in a 4.3BSD:
>>>
>>> void bzero(void *s, size_t n);
>>>
>>> As an additional benefit, the changed macro now generates warning when
>>> its return value is used (which is *not* the case in regex.c):
>>
>> I'm not worried about anybody using the return value incorrectly in
>> this file. I think we should just
>>
>> # define bzero(s, n) memset (s, '\0', n)
>>
>> I'll approve that change if it works.
>
> Attached patch compiles without warnings as well. However, in some
> case, we have similar situation with unused return value of
>
> # define memcpy(d, s, n) (bcopy (s, d, n), (d))
>
> so, I put (void) casts to memcpy call to avoid eventual "right-hand
> operand of comma expression has no effect" warnings there.
>
> 2014-03-13 Uros Bizjak <ubizjak@gmail.com>
>
> * regex.c (bzero) [!_LIBC]: Define without coma expression.
> (regerror): Cast the call to memcpy to (void) to avoid unused
> value warnings.
>
> Is this version acceptable for mainline?
This is OK.
Thanks.
Ian