Gary-Hobson commented on code in PR #8755:
URL: https://github.com/apache/nuttx/pull/8755#discussion_r1133461607


##########
drivers/syslog/ramlog.c:
##########
@@ -286,84 +296,42 @@ static int ramlog_addchar(FAR struct ramlog_dev_s *priv, 
char ch)
 
   flags = enter_critical_section();
 
-  /* Calculate the write index AFTER the next byte is written */
-
-  nexthead = priv->rl_head + 1;
-  if (nexthead >= priv->rl_bufsize)
-    {
-      nexthead = 0;
-    }
+  /* Calculate the size in the buffer */
 
-  /* Would the next write overflow the circular buffer? */
+  space = (int)priv->rl_head - (int)priv->rl_tail >= 0 ?
+          priv->rl_bufsize - (priv->rl_head - priv->rl_tail) - 1:
+          priv->rl_tail - priv->rl_head - 1;
 
-  if (nexthead == priv->rl_tail)
+  if (len > space)

Review Comment:
   len > rl_bufsize already included in len > space



-- 
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-unsubscr...@nuttx.apache.org

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

Reply via email to