[Lldb-commits] [PATCH] D130939: [LLDB][NFC] Fix potential div by 0 "count" can be zero potentially causing div by 0

Slava Gurevich via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Aug 2 14:00:13 PDT 2022


fixathon added a comment.

The function has a void return type, with no way to communicate its success/failure status. Perhaps the right thing to do is to mod the function to return error Status, in addition to adding the assert (or some runtime check that works for all build flavors)?



================
Comment at: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp:2483
             ((float)num_packets) / duration<float>(total_time).count();
         auto average_per_packet = total_time / num_packets;
         const duration<float> standard_deviation =
----------------
DavidSpickett wrote:
> This could have the same issue if `num_packets` parameter is 0.
This instance of **average_per_packet** variable is not even being used anywhere in the code, in its local scope. Same for **packets_per_second** just above it.
These 2 could possibly just be deleted?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130939/new/

https://reviews.llvm.org/D130939



More information about the lldb-commits mailing list