Skip to content

Commit 2ba3fe7

Browse files
xguptaShivam Gupta
and
Shivam Gupta
authored
[lldb] Fix incorrect uses of logical operator in 'if' condition check (NFC) (#94779)
The condition checking for missing class name, interpreter dictionary, and script object incorrectly used logical AND (&&), which could never be true to enter the 'if' block. This commit uses separate if conditions for each class name, interpreter dictionary, and script object. Cought by cppcheck - lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h:89:11: warning: Identical inner 'if' condition is always true. [identicalInnerCondition] lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h:91:16: warning: Identical inner 'if' condition is always true. [identicalInnerCondition] Fix #89195 --------- Co-authored-by: Shivam Gupta <[email protected]>
1 parent f8006a5 commit 2ba3fe7

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,15 @@ class ScriptedPythonInterface : virtual public ScriptedInterface {
8585
bool has_class_name = !class_name.empty();
8686
bool has_interpreter_dict =
8787
!(llvm::StringRef(m_interpreter.GetDictionaryName()).empty());
88-
if (!has_class_name && !has_interpreter_dict && !script_obj) {
89-
if (!has_class_name)
90-
return create_error("Missing script class name.");
91-
else if (!has_interpreter_dict)
92-
return create_error("Invalid script interpreter dictionary.");
93-
else
94-
return create_error("Missing scripting object.");
95-
}
88+
89+
if (!has_class_name)
90+
return create_error("Missing script class name.");
91+
92+
if (!has_interpreter_dict)
93+
return create_error("Invalid script interpreter dictionary.");
94+
95+
if (!script_obj)
96+
return create_error("Missing scripting object.");
9697

9798
Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN,
9899
Locker::FreeLock);

0 commit comments

Comments
 (0)