Bug 56457

Summary: mod_proxy_html.c: 2 * cut'n'paste errors
Product: Apache httpd-2 Reporter: David Binderman <dcb314>
Component: mod_proxy_htmlAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: RESOLVED FIXED    
Severity: normal Keywords: FixedInTrunk
Priority: P2    
Version: 2.4.9   
Target Milestone: ---   
Hardware: All   
OS: Linux   

Description David Binderman 2014-04-25 07:31:30 UTC
[mod_proxy_html.c:326]: (style) Expression is always false because 'else if' condition matches previous condition at line 320.

Source code is

    if ((ctx->cfg->doctype == fpi_html) || (ctx->cfg->doctype == fpi_xhtml)) {
        /* enforce html */
        if (!desc || desc->depr)
            return;

    }
    else if ((ctx->cfg->doctype == fpi_html)
             || (ctx->cfg->doctype == fpi_xhtml)) {
        /* enforce html legacy */
        if (!desc)
            return;
    }

[mod_proxy_html.c:379]: (style) Expression is always false because 'else if' condition matches previous condition at line 372.

    if ((ctx->cfg->doctype == fpi_html) || (ctx->cfg->doctype == fpi_xhtml)) {
        /* enforce html */
        enforce = 2;
        if (!desc || desc->depr)
            return;

    }
    else if ((ctx->cfg->doctype == fpi_html)
             || (ctx->cfg->doctype == fpi_xhtml)) {
        enforce = 1;
        /* enforce html legacy */
        if (!desc) {
            return;
        }
    }

I got these two bugs from cppcheck, a static analysis tool.
It found many other things wrong.

I think apache would benefit from meeting cppcheck.
Comment 1 Christophe JAILLET 2014-04-25 08:30:55 UTC
Hi and thanks for the report.

We are aware of cppcheck and I run it from time to time.

If you have spotted and confirmed specific issues, please, let us know, so that we can fix them.


Concerning the one you have reported here, it has been fixed on trunk in r1442409, but has not been integrated into 2.4.x branch yet.
Comment 2 David Binderman 2017-10-24 08:24:33 UTC
(In reply to Christophe JAILLET from comment #1)
> Hi and thanks for the report.
> 
> We are aware of cppcheck and I run it from time to time.
> 
> If you have spotted and confirmed specific issues, please, let us know, so
> that we can fix them.
> 
> 
> Concerning the one you have reported here, it has been fixed on trunk in
> r1442409, but has not been integrated into 2.4.x branch yet.

[httpd-2.4.29/modules/filters/mod_proxy_html.c:326]: (style) Expression is always false because 'else if' condition matches previous condition at line 320.
[httpd-2.4.29/modules/filters/mod_proxy_html.c:379]: (style) Expression is always false because 'else if' condition matches previous condition at line 372.

Three years later and still not fixed ?
Comment 3 Luca Toscano 2017-11-27 09:22:23 UTC
Hi David,

thanks for the re-ping. The code is fixed in trunk, but it should be probably backported to 2.4.x. Since it is part of r1442409, I'll see if I can ping the original author and ask to him the plans for backporting :)

Luca
Comment 4 Luca Toscano 2017-12-02 07:44:07 UTC
Follow up of the commit mentioned by Christophe: http://svn.apache.org/r1816458
Comment 5 Nick Kew 2017-12-22 22:56:14 UTC
Backported to 2.4 in r1819098 .