Skip to content
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

[lldb] Fix redundant condition in compression type check (NFC) #94841

Merged
merged 2 commits into from
Jun 10, 2024

Conversation

xgupta
Copy link
Contributor

@xgupta xgupta commented Jun 8, 2024

The else if condition for checking m_compression_type is redundant as it matches with a previous if condition, making the expression always false. Reported by cppcheck as a possible cut-and-paste error.

Caught by cppcheck -
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp:543:35: style: Expression is always false because 'else if' condition matches previous condition at line 535. [multiCondition]

Fix #91222

The `else if` condition for checking `m_compression_type` is redundant as it matches with a previous `if` condition, making the expression always false.
Reported by cppcheck as a possible cut-and-paste error.

Caught by cppcheck -
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp:543:35: style: Expression is always false because 'else if' condition matches previous condition at line 535. [multiCondition]

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

llvmbot commented Jun 8, 2024

@llvm/pr-subscribers-lldb

Author: Shivam Gupta (xgupta)

Changes

The else if condition for checking m_compression_type is redundant as it matches with a previous if condition, making the expression always false. Reported by cppcheck as a possible cut-and-paste error.

Caught by cppcheck -
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp:543:35: style: Expression is always false because 'else if' condition matches previous condition at line 535. [multiCondition]

Fix #91222


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

1 Files Affected:

  • (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (-2)
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index 8a47eed3d7cbe..52bf8533bbd8a 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -540,8 +540,6 @@ bool GDBRemoteCommunication::DecompressPacket() {
         scratchbuf_size = compression_decode_scratch_buffer_size (COMPRESSION_ZLIB);
       else if (m_compression_type == CompressionType::LZMA)
         scratchbuf_size = compression_decode_scratch_buffer_size (COMPRESSION_LZMA);
-      else if (m_compression_type == CompressionType::LZFSE)
-        scratchbuf_size = compression_decode_scratch_buffer_size (COMPRESSION_LZFSE);
       if (scratchbuf_size > 0) {
         m_decompression_scratch = (void*) malloc (scratchbuf_size);
         m_decompression_scratch_type = m_compression_type;

Copy link

github-actions bot commented Jun 8, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

Mhunter15 referenced this pull request Jun 8, 2024
In a real-world case with functions that have many, many
R_RISCV_CALL_PLT relocations due to asan and ubsan
instrumentation, all these can be relaxed by an instruction and
the net result is more than 65536 bytes of reduction in the
output .text section that totals about 1.2MiB in final size.

This changes InputSection to use a 32-bit field for bytesDropped.
The RISCV relaxation keeps track in a 64-bit field and detects
32-bit overflow as it previously detected 16-bit overflow. It
doesn't seem likely that 32-bit overflow will arise, but it's not
inconceivable and it's cheap enough to detect it.

This unfortunately increases the size of InputSection on 64-bit
hosts by a word, but that seems hard to avoid.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D150722
@xgupta xgupta merged commit 0af2e75 into llvm:main Jun 10, 2024
5 checks passed
@xgupta xgupta deleted the fix91222 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/gdb-remote/GDBRemoteCommunication.cpp:543: Possible cut'n'paste error ?
3 participants