From dc8c34487f06884dc4d200a7190464ce68d9f039 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Wed, 27 Apr 2016 12:16:37 -0700 Subject: [PATCH] Speed dropped_percent() common case, ensure dropped>0 returns >0%. --- firmware/common/message.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/firmware/common/message.hpp b/firmware/common/message.hpp index 6dc511723..f1b20a4e6 100644 --- a/firmware/common/message.hpp +++ b/firmware/common/message.hpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "baseband_packet.hpp" #include "ert_packet.hpp" @@ -429,7 +430,12 @@ struct CaptureConfig { } size_t dropped_percent() const { - return baseband_bytes_dropped * 100U / baseband_bytes_received; + if( baseband_bytes_dropped == 0 ) { + return 0; + } else { + const size_t percent = baseband_bytes_dropped * 100U / baseband_bytes_received; + return std::max(1U, percent); + } } };