Opened 7 months ago

Closed 7 months ago

Last modified 7 months ago

#15893 closed optimization (fixed)

PVS Studio check

Reported by: pavel_pimenov Owned by:
Priority: low Milestone:
Component: wxMSW Version: 3.0.0
Keywords: Cc:
Blocked By: Blocking:
Patch: no

Description

http://www.viva64.com/en/V805

V805 Decreased performance. It is inefficient to identify an empty string by using 'strlen(str) == 0' construct. A more efficient way is to check: str[0] == '\0'. lexhtml.cxx 492
V805 Decreased performance. It is inefficient to identify an empty string by using 'strlen(str) == 0' construct. A more efficient way is to check: str[0] == '\0'. lexhtml.cxx 512

http://www.viva64.com/en/V801

V801 Decreased performance. It is better to redefine the second function argument as a reference. Consider replacing 'const .. s' with 'const .. &s'. ipcbase.h 94
V801 Decreased performance. It is better to redefine the second function argument as a reference. Consider replacing 'const .. s' with 'const .. &s'. ipcbase.h 116
V801 Decreased performance. It is better to redefine the first function argument as a reference. Consider replacing 'const .. ch' with 'const .. &ch'. ustring.h 602
V801 Decreased performance. It is better to redefine the first function argument as a reference. Consider replacing 'const .. ch' with 'const .. &ch'. ustring.h 604
V801 Decreased performance. It is better to redefine the first function argument as a reference. Consider replacing 'const .. ch' with 'const .. &ch'. ustring.h 632
V801 Decreased performance. It is better to redefine the first function argument as a reference. Consider replacing 'const .. ch' with 'const .. &ch'. ustring.h 634
V801 Decreased performance. It is better to redefine the third function argument as a reference. Consider replacing 'const .. filename' with 'const .. &filename'. filectrlcmn.cpp 66
V801 Decreased performance. It is better to redefine the third function argument as a reference. Consider replacing 'const .. url' with 'const .. &url'. webview.h 240
V801 Decreased performance. It is better to redefine the fourth function argument as a reference. Consider replacing 'const .. target' with 'const .. &target'. webview.h 241
V801 Decreased performance. It is better to redefine the first function argument as a reference. Consider replacing 'const .. text' with 'const .. &text'. propgrid.h 1701
V801 Decreased performance. It is better to redefine the first function argument as a reference. Consider replacing 'const .. pt' with 'const .. &pt'. richtextctrl.cpp 2891

http://www.viva64.com/en/V669

V669 The 'ch' argument is a non-constant reference. The analyzer is unable to determine the position at which this argument is being modified. It is possible that the function contains an error. lexruby.cxx 204
V669 The 'chNext2' argument is a non-constant reference. The analyzer is unable to determine the position at which this argument is being modified. It is possible that the function contains an error. lexruby.cxx 212
V669 The 'lineState' argument is a non-constant reference. The analyzer is unable to determine the position at which this argument is being modified. It is possible that the function contains an error. lextads3.cxx 305
V669 The 'lineState' argument is a non-constant reference. The analyzer is unable to determine the position at which this argument is being modified. It is possible that the function contains an error. lextads3.cxx 346
V669 The 'lIndex' argument is a non-constant reference. The analyzer is unable to determine the position at which this argument is being modified. It is possible that the function contains an error. fileconf.cpp 761
V669 The 'lIndex' argument is a non-constant reference. The analyzer is unable to determine the position at which this argument is being modified. It is possible that the function contains an error. fileconf.cpp 777
V669 The 'argc' argument is a non-constant reference. The analyzer is unable to determine the position at which this argument is being modified. It is possible that the function contains an error. init.cpp 360
V669 The 'argc' argument is a non-constant reference. The analyzer is unable to determine the position at which this argument is being modified. It is possible that the function contains an error. init.cpp 503
V669 The 'id' argument is a non-constant reference. The analyzer is unable to determine the position at which this argument is being modified. It is possible that the function contains an error. nativdlg.cpp 46
V669 The 'style' argument is a non-constant reference. The analyzer is unable to determine the position at which this argument is being modified. It is possible that the function contains an error. auibar.cpp 777
V669 The 'y' argument is a non-constant reference. The analyzer is unable to determine the position at which this argument is being modified. It is possible that the function contains an error. richtextbuffer.cpp 6662

http://www.viva64.com/en/V595

V595 The 'm_dc' pointer was utilized before it was verified against nullptr. Check lines: 112, 125. dcbufcmn.cpp 112
V595 The 'm_owner' pointer was utilized before it was verified against nullptr. Check lines: 4083, 4111. datavgen.cpp 4083
V595 The 'm_NavigPan' pointer was utilized before it was verified against nullptr. Check lines: 574, 578. helpwnd.cpp 574
V595 The 'propgrid' pointer was utilized before it was verified against nullptr. Check lines: 512, 539. property.cpp 512
V595 The 'nextParagraph' pointer was utilized before it was verified against nullptr. Check lines: 3008, 3011. richtextbuffer.cpp 3008

http://www.viva64.com/en/V581

V581 The conditional expressions of the 'if' operators situated alongside each other are identical. Check lines: 718, 720. regc_nfa.c 720
V581 The conditional expressions of the 'if' operators situated alongside each other are identical. Check lines: 249, 258. lexverilog.cxx 258
V581 The conditional expressions of the 'if' operators situated alongside each other are identical. Check lines: 1131, 1155. dialup.cpp 1155
V581 The conditional expressions of the 'if' operators situated alongside each other are identical. Check lines: 1993, 1995. richtextbuffer.cpp 1995

http://www.viva64.com/en/V560

V560 A part of conditional expression is always false: (long) test_mac != 1000000000L. jmemmgr.c 1052
V560 A part of conditional expression is always false: !isDelayedExpansion. lextcmd.cxx 272
V560 A part of conditional expression is always false: !isDelayedExpansion. lextcmd.cxx 391
V560 A part of conditional expression is always true: !scrolledWindow. dlgcmn.cpp 676
V560 A part of conditional expression is always true: colSpan == 1. richtextbuffer.cpp 10046
V560 A part of conditional expression is always true: colSpan == 1. richtextbuffer.cpp 10049

http://www.viva64.com/en/V519

V519 The 'self->m_pCurrentGroup' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 796, 798. fileconf.cpp 798
V519 The 'self->m_pCurrentGroup' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 814, 816. fileconf.cpp 816
V519 The 'hr' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 173, 176. webview_ie.cpp 176
V519 The 'hr' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 151, 155. webview_ie.cpp 155
V519 The 'listValue' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 2986, 3000. propgrid.cpp 3000
V519 The 'm_processedEvent' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 4707, 4709. propgrid.cpp 4709
V519 The 'maxAscent' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 5027, 5061. richtextbuffer.cpp 5061
V519 The 'sm_showMinMaxSizeControls' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 119, 120. richtextsizepage.cpp 120

http://www.viva64.com/en/V513

V513 Use _beginthreadex/_endthreadex functions instead of CreateThread/ExitThread functions. utilsexc.cpp 948
V513 Use _beginthreadex/_endthreadex functions instead of CreateThread/ExitThread functions. dialup.cpp 1137

http://www.viva64.com/en/V507

V507 Pointer to local array 'mat' is stored outside the scope of this array. Such a pointer will become invalid. regexec.c 204
V507 Pointer to local array 'mem' is stored outside the scope of this array. Such a pointer will become invalid. regexec.c 222

http://www.viva64.com/en/V506

V506 Pointer to local variable 'tempListVariant' is stored outside the scope of this variable. Such a pointer will become invalid. property.cpp 1344
V506 Pointer to local variable 'text1' is stored outside the scope of this variable. Such a pointer will become invalid. props.cpp 682

http://www.viva64.com/en/V501

V501 There are identical sub-expressions '((sc.state == 11) && isdigit(sc.ch))' to the left and to the right of the '
' operator. lexa68k.cxx 160

V501 There are identical sub-expressions 'ParseH16(uri)' to the left and to the right of the '&&' operator. uri.cpp 941
V501 There are identical sub-expressions 'ParseH16(uri)' to the left and to the right of the '&&' operator. uri.cpp 975
V501 There are identical sub-expressions 'wxGIFHandler_WriteWord(stream, 0)' to the left and to the right of the '&&' operator. imaggif.cpp 676
V501 There are identical sub-expressions '!(m_dirName.empty())' to the left and to the right of the '&&' operator. filectrlg.cpp 569

V501 There are identical sub-expressions 'RemoveMenu(hMenu, 0, 0x00000400L)' to the left and to the right of the '
' operator. menu.cpp 917

Change History (6)

comment:1 Changed 7 months ago by vadz

  • Resolution set to fixed
  • Status changed from new to closed

Thanks, I think I've fixed all of the real problems. The rest of them are

  1. In the third party code which we won't change without a very good reason.
  2. Analyser mistakes: too many to list here but it seems to be totally confused by wxFileConfig code notably and it doesn't take side effects into account for its V501.
  3. I don't know how to fix (but neither am I sure they are real problems): V506, V519 in webview_ie.cpp.
  4. Not worth fixing because it would make code less readable/consistent: V801 in ustring.h, V669 in richtext.

FWIW it's nice to see that there are no serious/real problems detected.

comment:2 Changed 7 months ago by VZ

(In [75657]) Pass non-primitive types by const reference instead of value.

No real changes, just avoid the unnecessary copying and also make the
signatures more consistent by adding the apparently forgotten "&" in a couple
of places.

See #15893.

comment:3 Changed 7 months ago by VZ

(In [75659]) Don't pass input parameter by non-const reference unnecessarily.

This is confusing.

See #15893.

comment:4 Changed 7 months ago by VZ

(In [75660]) Correct wrong error handler in wxDialUpManagerMSW code.

Forgot to set the success flag to false if thread creation failed.

See #15893.

comment:5 Changed 7 months ago by VZ

(In [75661]) Remove redundant checks from conditional statements.

It is not necessary to test for the condition which is already known to be
true or false because the code is inside the if statement checking it.

See #15893.

comment:6 Changed 7 months ago by VZ

(In [75662]) Remove unnecessary redundant assignments.

Don't assign values consecutively to the same variable without using it in
between the assignments, this is useless.

See #15893.

Note: See TracTickets for help on using tickets.