[PATCH] -Wno-parentheses-equality for Clang

Taro KOBAYASHI 9re.3000 at gmail.com
Mon Jun 20 06:43:12 UTC 2016


Hi Piotr,

> Fixing issue would be better than silencing the warning.

I aggree with this. And looking into this problem more detail,
I found that this is more complicated problem than simple coding
style problem.

in src/core/nginx.c:941:19

941|        if (ngx_path_separator(*p)) {
942|            cycle->conf_prefix.len = p - ngx_cycle->conf_file.data + 1;
943|            cycle->conf_prefix.data = ngx_cycle->conf_file.data;
944|            break;
945|        }

there is a macro ngx_path_separator defined in

src/os/unix/ngx_files.h
201|#define ngx_path_separator(c)    ((c) == '/')

the warning is raised by the extraneous parentheses expanded by this
macro. But generally we cannot say the parentheses in the macro is 'extraneous'
as the situation could be changed by the context where it is used.



> Hey Taro,
>
> On Sun, Jun 19, 2016 at 7:13 PM, Taro KOBAYASHI <9re.3000 at gmail.com> wrote:
> > # HG changeset patch
> > # User Taro Kobayashi <9re.3000 at gmail.com>
> > # Date 1466387734 -32400
> > #      Mon Jun 20 10:55:34 2016 +0900
> > # Node ID f693bcc8e11e63bcbcdafda1b31a9c6a438fa36e
> > # Parent  04d8d1f8564989509f9b03085df1af7618b44be8
> > With Werror and Wparentheses-equality option,
> > the following will be treated as error in Clang
> >
> > src/core/nginx.c:941:19: error: equality comparison with extraneous parentheses
> >         if (((*p) == '/')) {
> >              ~~~~~^~~~~~
>
> Fixing issue would be better than silencing the warning.
>
> Best regards,
> Piotr Sikora



More information about the nginx-devel mailing list