RapidScada / scada

Contains Rapid SCADA sources
Apache License 2.0
680 stars 311 forks source link

PVS-Studio #68

Open pavel-pimenov opened 5 years ago

pavel-pimenov commented 5 years ago

V3125 The 'styleAttr' object was used after it was verified against null. Check lines: 296, 262. ExcelRepBuilder.cs 296

pavel-pimenov commented 5 years ago

ScadaData.sln

V3111 Checking value of 'key' for null will always return false when generic type is instantiated with a value type. Cache.cs 152 V3111 Checking value of 'key' for null will always return false when generic type is instantiated with a value type. Cache.cs 177 V3080 Possible null dereference. Consider inspecting 'cnlProps'. DataFormatter.cs 334 V3024 An odd precise comparison: dt == 0.0. Consider using a comparison with defined precision: Math.Abs(A - B) < Epsilon. ServerComm.cs 1385 V3024 An odd precise comparison: dateTime.TimeOfDay.TotalMilliseconds == 0. Consider using a comparison with defined precision: Math.Abs(A - B) < Epsilon. ScadaUtils.cs 188 V3019 Possibly an incorrect variable is compared to null after type conversion using 'as' keyword. Check variables 'srezTableLight', 'srezTable'. SrezAdapter.cs 143 V3125 The 'trend' object was used after it was verified against null. Check lines: 178, 143. SrezAdapter.cs 178 V3095 The 'trend' object was used before it was verified against null. Check lines: 179, 261. SrezAdapter.cs 179

pavel-pimenov commented 5 years ago

ScadaComm.sln V3008 The 'checking' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 235, 217. FrmImport.cs 235 V3125 The 'tagSrez' object was used after it was verified against null. Check lines: 85, 68. ServerCommEx.cs 85 V3054 Potentially unsafe double-checked locking. Use volatile variable(s) or synchronization primitives to avoid this. CommLine.cs 1252 V3054 Potentially unsafe double-checked locking. Use volatile variable(s) or synchronization primitives to avoid this. CommLine.cs 1280 V3073 Not all IDisposable members are properly disposed. Call 'Dispose' when disposing 'FrmMain' class. Inspect: icoStart, icoStop, svcContr. FrmMain.cs 50 V3125 The 'lastLine' object was used after it was verified against null. Check lines: 757, 755. FrmMain.cs 757 V3024 An odd precise comparison: number != 0. Consider using a comparison with defined precision: Math.Abs(A - B) > Epsilon. KPLogic.cs 928

pavel-pimenov commented 5 years ago

OpenKPs.sln

V3063 A part of conditional expression is always true if it is evaluated: 0 <= srcInd. ModbusUtils.cs 240 V3125 The 'deviceTemplate' object was used after it was verified against null. Check lines: 320, 313. KpModbusLogic.cs 320 V3130 Priority of the '&&' operator is higher than that of the '||' operator. Possible missing parentheses. KpSnmpLogic.cs 374 V3072 The 'KpEmailLogic' class containing IDisposable members does not itself implement IDisposable. Inspect: smtpClient. KpEmailLogic.cs 46 V3134 Shift by [32..256] bits is greater than the size of 'Int32' type of expression 'part'. KpSmsLogic.cs 220 V3134 Shift by [-248..-1] bits is greater than the size of 'Int32' type of expression '(b & MaskR[bit - 1])'. KpSmsLogic.cs 220

pavel-pimenov commented 5 years ago

ScadaServer.sln

V3127 Two similar code fragments were found. Perhaps, this is a typo and 'SrezCopyAdapter' variable should be used instead of 'SrezAdapter' MainLogic.Types.cs 131 V3073 Not all IDisposable members are properly disposed. Call 'Dispose' when disposing 'FrmMain' class. Inspect: svcContr. FrmMain.cs 50 V3095 The 'node' object was used before it was verified against null. Check lines: 938, 940. FrmMain.cs 938 V3072 The 'ClientInfo' class containing IDisposable members does not itself implement IDisposable. Inspect: NetStream. Comm.cs 115 V3022 Expression 'sendResp' is always true. Comm.cs 1096 V3130 Priority of the '&&' operator is higher than that of the '||' operator. Possible missing parentheses. MainLogic.cs 879 V3024 An odd precise comparison: oldVal != newVal. Consider using a comparison with defined precision: Math.Abs(A - B) > Epsilon. MainLogic.cs 1534

pavel-pimenov commented 5 years ago

ScadaAdmin.sln

V3114 IDisposable object 'engine' is not disposed before method returns. AppData.cs 153 V3063 A part of conditional expression is always true if it is evaluated: table != null. FrmCloneCnls.cs 147 V3073 Not all IDisposable members are properly disposed. Call 'Dispose' when disposing 'FrmSelectColor' class. Inspect: textBrush. FrmSelectColor.cs 39 V3130 Priority of the '&&' operator is higher than that of the '||' operator. Possible missing parentheses. FrmReplace.cs 450 V3073 Not all IDisposable members are properly disposed. Call 'Dispose' when disposing 'FrmServerStatus' class. Inspect: client. FrmServerStatus.cs 38 V3022 Expression '!saveOccured' is always true. FrmTable.cs 351 V3130 Priority of the '&&' operator is higher than that of the '||' operator. Possible missing parentheses. FrmUploadConfig.cs 411 V3130 Priority of the '&&' operator is higher than that of the '||' operator. Possible missing parentheses. FrmUploadConfig.cs 419

pavel-pimenov commented 5 years ago

ScadaWebCommon5

V3127 Two similar code fragments were found. Perhaps, this is a typo and 'nextDate' variable should be used instead of 'curDate' ClientApiSvc.cs 380 V3095 The 'userData' object was used before it was verified against null. Check lines: 185, 187. UserMonitor.cs 185 V3043 The code's operational logic does not correspond with its formatting. The statement is indented to the right, but it is always executed. It is possible that curly brackets are missing. UserData.cs 351

pavel-pimenov commented 5 years ago

ScadaScheme.sln V3073 Not all IDisposable members are properly disposed. Call 'Dispose' when disposing 'FrmFontDialog' class. Inspect: textBrush. FrmFontDialog.cs 37 V3054 Potentially unsafe double-checked locking. Use volatile variable(s) or synchronization primitives to avoid this. Editor.cs 930 V3002 The switch statement does not cover all values of the 'PointerModes' enum: Select. SchemeEditorSvc.cs 275 V3063 A part of conditional expression is always true if it is evaluated: selection != null. FrmMain.cs 387

2mik commented 5 years ago

Thanks. Will check this warnings in case of modify corresponding classes. After brief view of them I can say that part of them are meaningless, others make sense.