You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/04/22 02:58:36 UTC

[GitHub] [incubator-nuttx-apps] xiaoxiang781216 commented on a diff in pull request #1151: system/ping: Guard against division by zero when calculating the RTT.

xiaoxiang781216 commented on code in PR #1151:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1151#discussion_r855729647


##########
system/ping/ping.c:
##########
@@ -242,10 +242,17 @@ static void ping_result(FAR const struct ping_result_s *result)
                    result->extra / USEC_PER_MSEC);
             if (result->nreplies > 0)
               {
-                long avg = priv->tsum / result->nreplies;
-                long long tempnum = priv->tsum2 / result->nreplies -
+                long tmdev = 0;
+                long avg = 0;
+                long long tempnum = 0;
+
+                if (priv->tsum > 0)

Review Comment:
   But, I don't see tsum used as divider. BTW, should we modify ping6 too?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org