Skip to content

[lldb] Remove redundant condition in watch mask check (NFC) #94842

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2024

Conversation

xgupta
Copy link
Contributor

@xgupta xgupta commented Jun 8, 2024

This issue is reported by cppcheck as a pointless test in the watch mask check. The else if condition is opposite to the previous if condition, making the expression always true.

Caught by cppcheck -
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp:509:25: style: Expression is always true because 'else if' condition is opposite to previous condition at line 505. [multiCondition]

Fix #91223

This issue is reported by cppcheck as a pointless test in the watch mask check.
The `else if` condition is opposite to the previous `if` condition, making the expression always true.

Caught by cppcheck -
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp:509:25: style: Expression is always true because 'else if' condition is opposite to previous condition at line 505. [multiCondition]

Fix llvm#91223
@xgupta xgupta requested a review from JDevlieghere as a code owner June 8, 2024 05:53
@llvmbot llvmbot added the lldb label Jun 8, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 8, 2024

@llvm/pr-subscribers-lldb

Author: Shivam Gupta (xgupta)

Changes

This issue is reported by cppcheck as a pointless test in the watch mask check. The else if condition is opposite to the previous if condition, making the expression always true.

Caught by cppcheck -
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp:509:25: style: Expression is always true because 'else if' condition is opposite to previous condition at line 505. [multiCondition]

Fix #91223


Full diff: https://github.com/llvm/llvm-project/pull/94842.diff

1 Files Affected:

  • (modified) lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp (+1-1)
diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
index 5ad2f7a8e9455..4668c25eab083 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
@@ -506,7 +506,7 @@ uint32_t NativeRegisterContextLinux_arm::SetHardwareWatchpoint(
       return LLDB_INVALID_INDEX32;
     else if (watch_mask <= 0x02)
       size = 2;
-    else if (watch_mask <= 0x04)
+    else
       size = 4;
 
     addr = addr & (~0x03);

@xgupta xgupta merged commit 30bfab3 into llvm:main Jun 10, 2024
7 checks passed
@xgupta xgupta deleted the fix91233 branch June 12, 2024 16:22
@HerrCai0907 HerrCai0907 mentioned this pull request Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp:509: Pointless test ?
3 participants