[asterisk-bugs] [JIRA] (ASTERISK-27793) cppcheck identifies redundant "if"

Ilya Shipitsin (JIRA) noreply at issues.asterisk.org
Tue Apr 10 00:10:52 CDT 2018


    [ https://issues.asterisk.org/jira/browse/ASTERISK-27793?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=242968#comment-242968 ] 

Ilya Shipitsin commented on ASTERISK-27793:
-------------------------------------------

it's cppcheck ( https://github.com/danmar/cppcheck )

cd asterisk
script
cppcheck --force --enable=all .
...
...
Ctrl-D
grep '(warning' typescript | grep 'Either the condition'


[addons/ooh323c/src/memheap.c:1067] -> [addons/ooh323c/src/memheap.c:1065]: (warning) Either the condition 'ppMemHeap!=0' is redundant or there is possible null pointer dereference: ppMemHeap.
[addons/ooh323c/src/ooCalls.c:806] -> [addons/ooh323c/src/ooCalls.c:808]: (warning) Either the condition '!call' is redundant or there is possible null pointer dereference: call.
[addons/ooh323c/src/ooCapability.c:58] -> [addons/ooh323c/src/ooCapability.c:66]: (warning) Either the condition '!call' is redundant or there is possible null pointer dereference: call.
[addons/ooh323c/src/ooCapability.c:628] -> [addons/ooh323c/src/ooCapability.c:627]: (warning) Either the condition '!params' is redundant or there is possible null pointer dereference: params.
[addons/ooh323c/src/ooCapability.c:813] -> [addons/ooh323c/src/ooCapability.c:812]: (warning) Either the condition '!events' is redundant or there is possible null pointer dereference: events.
[addons/ooh323c/src/ooGkClient.c:2339] -> [addons/ooh323c/src/ooGkClient.c:2337]: (warning) Either the condition '!perCallInfo' is redundant or there is possible null pointer dereference: perCallInfo.
[addons/ooh323c/src/ooh245.c:360] -> [addons/ooh323c/src/ooh245.c:359]: (warning) Either the condition 'request==NULL' is redundant or there is possible null pointer dereference: request.
[addons/ooh323c/src/ooq931.c:2444] -> [addons/ooh323c/src/ooq931.c:2443]: (warning) Either the condition '!pNewAlias' is redundant or there is possible null pointer dereference: pNewAlias.
[addons/res_config_mysql.c:505] -> [addons/res_config_mysql.c:466]: (warning) Either the condition 'if(initfield)' is redundant or there is possible null pointer dereference: initfield.
[apps/app_minivm.c:1262] -> [apps/app_minivm.c:1264]: (warning) Either the condition 'vmu' is redundant or there is possible null pointer dereference: vmu.
[apps/app_minivm.c:1262] -> [apps/app_minivm.c:1265]: (warning) Either the condition 'vmu' is redundant or there is possible null pointer dereference: vmu.
[apps/app_minivm.c:2190] -> [apps/app_minivm.c:2194]: (warning) Either the condition 'duration_string' is redundant or there is possible null pointer dereference: duration_string.
[apps/app_minivm.c:3436] -> [apps/app_minivm.c:3440]: (warning) Either the condition 'countername' is redundant or there is possible null pointer dereference: countername.
[channels/chan_mgcp.c:985] -> [channels/chan_mgcp.c:997]: (warning) Either the condition 'p' is redundant or there is possible null pointer dereference: p.
[channels/chan_mgcp.c:2179] -> [channels/chan_mgcp.c:2176]: (warning) Either the condition '!sub' is redundant or there is possible null pointer dereference: sub.
[channels/chan_mgcp.c:2659] -> [channels/chan_mgcp.c:2665]: (warning) Either the condition 'p' is redundant or there is possible null pointer dereference: p.
[channels/chan_mgcp.c:2843] -> [channels/chan_mgcp.c:2841]: (warning) Either the condition 'sub?sub->id:-1' is redundant or there is possible null pointer dereference: sub.
[channels/chan_mgcp.c:3474] -> [channels/chan_mgcp.c:3471]: (warning) Either the condition 'if(p)' is redundant or there is possible null pointer dereference: p.
[channels/chan_misdn.c:6802] -> [channels/chan_misdn.c:6798]: (warning) Either the condition 'newbc?newbc->pid:-1' is redundant or there is possible null pointer dereference: newbc.
[channels/chan_sip.c:13194] -> [channels/chan_sip.c:13208]: (warning) Either the condition 'max_packet_size' is redundant or there is possible null pointer dereference: max_packet_size.
[channels/chan_skinny.c:7636] -> [channels/chan_skinny.c:7291]: (warning) Either the condition 'if(req)' is redundant or there is possible null pointer dereference: req.
[channels/chan_unistim.c:5525] -> [channels/chan_unistim.c:5515]: (warning) Either the condition '!pte' is redundant or there is possible null pointer dereference: pte.
[channels/chan_vpb.cc:2362] -> [channels/chan_vpb.cc:2364]: (warning) Either the condition 'fr' is redundant or there is possible null pointer dereference: fr.
[channels/chan_vpb.cc:564] -> [channels/chan_vpb.cc:585]: (warning) Either the condition '!f' is redundant or there is possible null pointer dereference: f.
[channels/misdn/isdn_lib.c:1936] -> [channels/misdn/isdn_lib.c:1934]: (warning) Either the condition 'if(hold_bc)' is redundant or there is possible null pointer dereference: hold_bc.
[channels/misdn/isdn_lib.c:4536] -> [channels/misdn/isdn_lib.c:4535]: (warning) Either the condition '!stack' is redundant or there is possible null pointer dereference: stack.
[codecs/lpc10/analys.c:457] -> [codecs/lpc10/analys.c:641]: (warning) Either the condition 'voice' is redundant or there is possible null pointer dereference: voice.
[codecs/lpc10/analys.c:457] -> [codecs/lpc10/analys.c:642]: (warning) Either the condition 'voice' is redundant or there is possible null pointer dereference: voice.
[codecs/lpc10/voicin.c:502] -> [codecs/lpc10/voicin.c:594]: (warning) Either the condition 'ivrc' is redundant or there is possible null pointer dereference: ivrc.
[main/astfd.c:282] -> [main/astfd.c:283]: (warning) Either the condition '!ptr' is redundant or there is possible null pointer dereference: ptr.
[main/astobj2.c:709] -> [main/astobj2.c:695]: (warning) Either the condition '(obj)==NULL' is redundant or there is possible null pointer dereference: obj.
[main/astobj2.c:709] -> [main/astobj2.c:696]: (warning) Either the condition '(obj)==NULL' is redundant or there is possible null pointer dereference: obj.
[main/astobj2.c:709] -> [main/astobj2.c:697]: (warning) Either the condition '(obj)==NULL' is redundant or there is possible null pointer dereference: obj.
[main/astobj2.c:709] -> [main/astobj2.c:698]: (warning) Either the condition '(obj)==NULL' is redundant or there is possible null pointer dereference: obj.
[main/astobj2.c:709] -> [main/astobj2.c:701]: (warning) Either the condition '(obj)==NULL' is redundant or there is possible null pointer dereference: obj.
[main/pbx.c:1087] -> [main/pbx.c:1090]: (warning) Either the condition 'node' is redundant or there is possible null pointer dereference: node.
[main/sdp_state.c:3192] -> [main/sdp_state.c:3285]: (warning) Either the condition 'udptl' is redundant or there is possible null pointer dereference: udptl.
[main/sdp_state.c:3192] -> [main/sdp_state.c:3293]: (warning) Either the condition 'udptl' is redundant or there is possible null pointer dereference: udptl.
[main/strings.c:367] -> [main/strings.c:365]: (warning) Either the condition '!buffer' is redundant or there is possible null pointer dereference: buffer.
[res/ael/pval.c:3399] -> [res/ael/pval.c:2945]: (warning) Either the condition 'if(exten)' is redundant or there is possible null pointer dereference: exten.
[res/ael/pval.c:3399] -> [res/ael/pval.c:2949]: (warning) Either the condition 'if(exten)' is redundant or there is possible null pointer dereference: exten.
[res/ael/pval.c:3399] -> [res/ael/pval.c:2950]: (warning) Either the condition 'if(exten)' is redundant or there is possible null pointer dereference: exten.
[res/ael/pval.c:3719] -> [res/ael/pval.c:3039]: (warning) Either the condition 'exten' is redundant or there is possible null pointer dereference: exten.
[res/ael/pval.c:3719] -> [res/ael/pval.c:3040]: (warning) Either the condition 'exten' is redundant or there is possible null pointer dereference: exten.
[res/ael/pval.c:3719] -> [res/ael/pval.c:3687]: (warning) Either the condition 'if(exten&&exten->checked_switch)' is redundant or there is possible null pointer dereference: exten.
[res/ael/pval.c:3719] -> [res/ael/pval.c:3688]: (warning) Either the condition 'if(exten&&exten->checked_switch)' is redundant or there is possible null pointer dereference: exten.
[res/ael/pval.c:3719] -> [res/ael/pval.c:3706]: (warning) Either the condition 'if(exten&&exten->checked_switch)' is redundant or there is possible null pointer dereference: exten.
[res/ael/pval.c:3719] -> [res/ael/pval.c:3707]: (warning) Either the condition 'if(exten&&exten->checked_switch)' is redundant or there is possible null pointer dereference: exten.
[res/ael/pval.c:3719] -> [res/ael/pval.c:3726]: (warning) Either the condition 'exten' is redundant or there is possible null pointer dereference: exten.
[res/ael/pval.c:3719] -> [res/ael/pval.c:3727]: (warning) Either the condition 'exten' is redundant or there is possible null pointer dereference: exten.
[res/ael/pval.c:3793] -> [res/ael/pval.c:3800]: (warning) Either the condition 'exten' is redundant or there is possible null pointer dereference: exten.
[res/ael/pval.c:3793] -> [res/ael/pval.c:3801]: (warning) Either the condition 'exten' is redundant or there is possible null pointer dereference: exten.
[res/ael/pval.c:3866] -> [res/ael/pval.c:3896]: (warning) Either the condition 'exten' is redundant or there is possible null pointer dereference: exten.
[res/ael/pval.c:3866] -> [res/ael/pval.c:3897]: (warning) Either the condition 'exten' is redundant or there is possible null pointer dereference: exten.
[res/ael/pval.c:3866] -> [res/ael/pval.c:3901]: (warning) Either the condition 'exten' is redundant or there is possible null pointer dereference: exten.
[res/ael/pval.c:3866] -> [res/ael/pval.c:3902]: (warning) Either the condition 'exten' is redundant or there is possible null pointer dereference: exten.
[res/res_config_ldap.c:1071] -> [res/res_config_ldap.c:1052]: (warning) Either the condition 'if(initfield&&!strcmp(initfield,var->name))' is redundant or there is possible null pointer dereference: initfield.
[res/res_config_pgsql.c:629] -> [res/res_config_pgsql.c:580]: (warning) Either the condition 'if(initfield)' is redundant or there is possible null pointer dereference: initfield.
[res/res_endpoint_stats.c:65] -> [res/res_endpoint_stats.c:47]: (warning) Either the condition 'old_snapshot' is redundant or there is possible null pointer dereference: snapshot.
[res/res_endpoint_stats.c:65] -> [res/res_endpoint_stats.c:69]: (warning) Either the condition 'old_snapshot' is redundant or there is possible null pointer dereference: old_snapshot.
[res/res_format_attr_celt.c:121] -> [res/res_format_attr_celt.c:132]: (warning) Either the condition 'attr1' is redundant or there is possible null pointer dereference: attr1.
[res/res_format_attr_celt.c:121] -> [res/res_format_attr_celt.c:134]: (warning) Either the condition 'attr1' is redundant or there is possible null pointer dereference: attr1.
[res/res_format_attr_celt.c:121] -> [res/res_format_attr_celt.c:134]: (warning) Either the condition 'attr2' is redundant or there is possible null pointer dereference: attr2.
[res/res_format_attr_celt.c:121] -> [res/res_format_attr_celt.c:136]: (warning) Either the condition 'attr2' is redundant or there is possible null pointer dereference: attr2.
[res/res_pjsip/pjsip_message_filter.c:113] -> [res/res_pjsip/pjsip_message_filter.c:119]: (warning) Either the condition 'transport_state' is redundant or there is possible null pointer dereference: transport_state.
[res/res_pjsip_pubsub.c:640] -> [res/res_pjsip_pubsub.c:662]: (warning) Either the condition 'contact_hdr' is redundant or there is possible null pointer dereference: contact_hdr.
[res/res_pjsip_registrar.c:273] -> [res/res_pjsip_registrar.c:272]: (warning) Either the condition '!path_str' is redundant or there is possible null pointer dereference: path_str.
[res/res_pktccops.c:633] -> [res/res_pktccops.c:554]: (warning) Either the condition '(cmd==GATE_INFO||cmd==GATE_SET_HAVE_GATEID||cmd==GATE_DEL)&&gate' is redundant or there is possible null pointer dereference: gate.
[res/res_rtp_asterisk.c:4071] -> [res/res_rtp_asterisk.c:4063]: (warning) Either the condition '!rtp' is redundant or there is possible null pointer dereference: rtp.
[res/res_rtp_asterisk.c:4071] -> [res/res_rtp_asterisk.c:4068]: (warning) Either the condition '!rtp' is redundant or there is possible null pointer dereference: rtp.
[tests/test_cdr.c:333] -> [tests/test_cdr.c:339]: (warning) Either the condition 'actual' is redundant or there is possible null pointer dereference: actual.
[utils/db1-ast/btree/bt_open.c:407] -> [utils/db1-ast/btree/bt_open.c:401]: (warning) Either the condition 'envtmp?envtmp:"/tmp"' is redundant or there is possible null pointer dereference: envtmp.
[utils/db1-ast/btree/bt_seq.c:393] -> [utils/db1-ast/btree/bt_seq.c:394]: (warning) Either the condition '(h=__mpool_get(t->bt_mp,h->prevpg,0))==NULL' is redundant or there is possible null pointer dereference: h.
[utils/db1-ast/hash/hash_buf.c:279] -> [utils/db1-ast/hash/hash_buf.c:265]: (warning) Either the condition 'bp?bp->addr:0' is redundant or there is possible null pointer dereference: bp.
[utils/db1-ast/hash/hash_buf.c:279] -> [utils/db1-ast/hash/hash_buf.c:268]: (warning) Either the condition 'bp?bp->addr:0' is redundant or there is possible null pointer dereference: bp.
[utils/db1-ast/hash/hash_buf.c:279] -> [utils/db1-ast/hash/hash_buf.c:270]: (warning) Either the condition 'bp?bp->addr:0' is redundant or there is possible null pointer dereference: bp.
[utils/db1-ast/hash/hash_buf.c:279] -> [utils/db1-ast/hash/hash_buf.c:278]: (warning) Either the condition 'bp?bp->addr:0' is redundant or there is possible null pointer dereference: bp.
[utils/extconf.c:3146] -> [utils/extconf.c:2793]: (warning) Either the condition 'withcomments&&cfg' is redundant or there is possible null pointer dereference: cfg.





> cppcheck identifies redundant "if"
> ----------------------------------
>
>                 Key: ASTERISK-27793
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-27793
>             Project: Asterisk
>          Issue Type: Improvement
>      Security Level: None
>          Components: Addons/chan_ooh323
>    Affects Versions: 15.3.0
>            Reporter: Ilya Shipitsin
>            Assignee: Ilya Shipitsin
>            Severity: Trivial
>              Labels: patch, pjsip
>         Attachments: 0001-clean-cppcheck-warning.patch
>
>
> there's already if(dfr), no need for one more



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list