[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
Mon Aug 1 13:57:32 PDT 2022


fixathon created this revision.
Herald added a project: All.
fixathon requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130939

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp


Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -2536,7 +2536,9 @@
                           (1024.0 * 1024.0);
         float packets_per_second =
             ((float)packet_count) / duration<float>(total_time).count();
-        const auto average_per_packet = total_time / packet_count;
+        const auto average_per_packet = packet_count > 0
+                                            ? total_time / packet_count
+                                            : duration<float>::zero();
 
         if (json) {
           strm.Format("{0}\n     {{\"send_size\" : {1,6}, \"recv_size\" : "


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130939.449120.patch
Type: text/x-patch
Size: 848 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220801/b3788ab6/attachment.bin>


More information about the lldb-commits mailing list