Opened 3 years ago

Closed 3 years ago

#2279 closed defect (invalid)

cppcheck find bug

Reported by: RekGRpth@… Owned by:
Priority: minor Milestone:
Component: nginx-module Version: 1.19.x
Keywords: Cc:
uname -a: Linux nginx 5.13.0-21-generic #21-Ubuntu SMP Tue Oct 19 08:59:28 UTC 2021 x86_64 Linux
nginx -V: nginx version: nginx/1.21.4
built by gcc 10.3.1 20211027 (Alpine 10.3.1_git20211027)
built with OpenSSL 1.1.1l 24 Aug 2021
TLS SNI support enabled
configure arguments: --add-dynamic-module='modules/iconv-nginx-module modules/ngx_http_auth_basic_ldap_module modules/nginx-jwt-module modules/ngx_http_json_module modules/ngx_http_evaluate_module modules/nginx-push-stream-module modules/ngx_http_auth_pam_module modules/ngx_http_headers_module modules/ngx_http_upstream_session_sticky_module modules/njs/nginx modules/form-input-nginx-module modules/set-misc-nginx-module modules/ngx_http_htmldoc_module modules/nginx_csrf_prevent modules/nginx-upload-module modules/ngx_http_mustach_module modules/spnego-http-auth-nginx-module modules/ngx_postgres modules/ngx_http_response_body_module modules/ngx_http_substitutions_filter_module modules/ngx_http_sign_module modules/encrypted-session-nginx-module modules/ngx_brotli/filter modules/ngx_brotli/static modules/ngx_http_zip_var_module modules/ngx_http_handlebars_module modules/nginx-upstream-fair modules/ngx_http_captcha_module modules/nginx-uuid4-module modules/echo-nginx-module' --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --group=nginx --http-client-body-temp-path=/var/cache/nginx/client_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --lock-path=/run/nginx/nginx.lock --modules-path=/usr/local/lib/nginx --pid-path=/run/nginx/nginx.pid --prefix=/etc/nginx --sbin-path=/usr/local/bin/nginx --user=nginx --with-cc-opt='-W -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wmissing-prototypes -Werror -Wno-discarded-qualifiers -g -O' --with-compat --with-file-aio --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_xslt_module=dynamic --with-pcre --with-pcre-jit --with-poll_module --with-select_module --with-stream=dynamic --with-stream_geoip_module=dynamic --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-threads

Description (last modified by Maxim Dounin)

http/modules/ngx_http_charset_filter_module.c:671:16: style: The statement 'if (*p!=table[*p]) *p=table[*p]' is logically equivalent to '*p=table[*p]'. [duplicateConditionalAssign]
        if (*p != table[*p]) {
               ^
http/modules/ngx_http_charset_filter_module.c:672:16: note: Assignment '*p=table[*p]'
            *p = table[*p];
               ^
http/modules/ngx_http_charset_filter_module.c:671:16: note: Condition '*p!=table[*p]' is redundant
        if (*p != table[*p]) {
               ^

and

http/modules/ngx_http_grpc_module.c:2624:57: style: Suspicious calculation. Please use parentheses to clarify the code. The code ''a&b?c:d'' should be written as either ''(a&b)?c:d'' or ''a&(b?c:d)''. [clarifyCalculation]
            min = (ctx->flags & NGX_HTTP_V2_PADDED_FLAG ? 1 : 0)
                                                        ^
http/modules/ngx_http_grpc_module.c:2625:61: style: Suspicious calculation. Please use parentheses to clarify the code. The code ''a&b?c:d'' should be written as either ''(a&b)?c:d'' or ''a&(b?c:d)''. [clarifyCalculation]
                  + (ctx->flags & NGX_HTTP_V2_PRIORITY_FLAG ? 5 : 0);
                                                            ^

Change History (2)

comment:1 by Maxim Dounin, 3 years ago

Could you please clarify what makes you think these are bugs? Looks like purely stylistic complaints (and certainly we don't agree with them).

comment:2 by Maxim Dounin, 3 years ago

Description: modified (diff)
Resolution: invalid
Status: newclosed

Feedback timeout.

Note: See TracTickets for help on using tickets.