[Lldb-commits] [lldb] [lldb] Fix redundant condition in Target.cpp (PR #91882)
via lldb-commits
lldb-commits at lists.llvm.org
Mon May 13 09:01:07 PDT 2024
https://github.com/aabhinavg updated https://github.com/llvm/llvm-project/pull/91882
>From 9b4160975efe059f39a842689b1f750a10453203 Mon Sep 17 00:00:00 2001
From: aabhinavg <tiwariabhinavak at gmail.com>
Date: Sun, 12 May 2024 12:42:59 +0530
Subject: [PATCH 1/2] Fix redundant condition in Target.cpp
This commit addresses issue #87244, where a redundant condition was found in the Target.cpp file.
Static analyzer cppcheck flagged the issue in the Target.cpp file
---
lldb/source/Target/Target.cpp | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 82f3040e539a3..fe87728a33dc8 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -841,12 +841,14 @@ static bool CheckIfWatchpointsSupported(Target *target, Status &error) {
if (!num_supported_hardware_watchpoints)
return true;
- if (num_supported_hardware_watchpoints == 0) {
- error.SetErrorStringWithFormat(
- "Target supports (%u) hardware watchpoint slots.\n",
- *num_supported_hardware_watchpoints);
- return false;
- }
+ // If num_supported_hardware_watchpoints is zero, set an
+ //error message and return false.
+
+ error.SetErrorStringWithFormat(
+ "Target supports (%u) hardware watchpoint slots.\n",
+ *num_supported_hardware_watchpoints);
+ return false;
+
return true;
}
>From 421b4eed4c8bbcc2777fcbee1bf6c27786a393de Mon Sep 17 00:00:00 2001
From: aabhinavg <tiwariabhinavak at gmail.com>
Date: Mon, 13 May 2024 21:25:58 +0530
Subject: [PATCH 2/2] Revert "Fix redundant condition in Target.cpp"
This reverts commit 9b4160975efe059f39a842689b1f750a10453203.
The CheckIfWatchpointsSupported function is refactored to maintain the intended behavior as described below:
1. If we can't detect hardware watchpoints, assume they are supported.
2. If we can detect hardware watchpoints and there are more than 0, return true.
3. If we can detect hardware watchpoints but there are 0 of them, set an error message and return false.
fix #87244
---
lldb/source/Target/Target.cpp | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index fe87728a33dc8..77731167995e1 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -841,14 +841,12 @@ static bool CheckIfWatchpointsSupported(Target *target, Status &error) {
if (!num_supported_hardware_watchpoints)
return true;
- // If num_supported_hardware_watchpoints is zero, set an
- //error message and return false.
-
- error.SetErrorStringWithFormat(
- "Target supports (%u) hardware watchpoint slots.\n",
- *num_supported_hardware_watchpoints);
- return false;
-
+ if (*num_supported_hardware_watchpoints == 0) {
+ error.SetErrorStringWithFormat(
+ "Target supports (%u) hardware watchpoint slots.\n",
+ *num_supported_hardware_watchpoints);
+ return false;
+ }
return true;
}
More information about the lldb-commits
mailing list