pkarashchenko commented on code in PR #1623:
URL: https://github.com/apache/nuttx-apps/pull/1623#discussion_r1181841342


##########
system/sched_note/note_main.c:
##########
@@ -729,7 +729,9 @@ static void dump_notes(size_t nread)
 
                     for (i = 0; i < count; i++)
                       {
-                        ret += sprintf(&out[ret], " 0x%x", 
note_binary->nbi_data[i]);
+                        snprintf(&out[ret], sizeof(out) - ret,
+                                 " 0x%x", note_binary->nbi_data[i]);
+                        ret += strlen(out);

Review Comment:
   ```suggestion
                           ret += strlen(&out[ret]);
   ```
   or
   ```suggestion
                           ret = strlen(out);
   ```



##########
system/vi/vi.c:
##########
@@ -858,10 +859,13 @@ static void vi_printf(FAR struct vi_s *vi, FAR const char 
*prefix,
 
   /* Expand the prefix message in the scratch buffer */
 
-  len = prefix ? snprintf(vi->scratch, SCRATCH_BUFSIZE, "%s", prefix) : 0;
+  if (prefix != NULL)
+    {
+      len = snprintf(vi->scratch, sizeof(vi->scratch), "%s", prefix);
+    }
 
   va_start(ap, fmt);
-  len += vsnprintf(vi->scratch + len, SCRATCH_BUFSIZE - len, fmt, ap);
+  len += vsnprintf(vi->scratch + len, sizeof(vi->scratch) - len, fmt, ap);

Review Comment:
   most probably can't use `vsnprintf` return value directly.



##########
system/vi/vi.c:
##########
@@ -858,10 +859,13 @@ static void vi_printf(FAR struct vi_s *vi, FAR const char 
*prefix,
 
   /* Expand the prefix message in the scratch buffer */
 
-  len = prefix ? snprintf(vi->scratch, SCRATCH_BUFSIZE, "%s", prefix) : 0;
+  if (prefix != NULL)
+    {
+      len = snprintf(vi->scratch, sizeof(vi->scratch), "%s", prefix);

Review Comment:
   Do we need `Len = MIN(len, sizeof(vi->scratch)));` right after `snprintf` 
here?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to