Skip to content

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h:89: possible && and || mixup ? #89195

@dcb314

Description

@dcb314

Source code analyser cppcheck says:

trunk/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h:89:11: warning: Identical inner 'if' condition is always true. [identicalInnerCondition]
trunk/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h:91:16: warning: Identical inner 'if' condition is always true. [identicalInnerCondition]

Source code is

if (!has_class_name && !has_interpreter_dict && !script_obj) {
  if (!has_class_name)
    return create_error("Missing script class name.");
  else if (!has_interpreter_dict)
    return create_error("Invalid script interpreter dictionary.");
  else
    return create_error("Missing scripting object.");

I think the original coder wanted something like:

if (!has_class_name || !has_interpreter_dict || !script_obj) {
  if (!has_class_name)
    return create_error("Missing script class name.");
  else if (!has_interpreter_dict)
    return create_error("Invalid script interpreter dictionary.");
  else
    return create_error("Missing scripting object.");

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions