pkarashchenko commented on code in PR #8946:
URL: https://github.com/apache/nuttx/pull/8946#discussion_r1157076843


##########
libs/libc/string/lib_strerror.c:
##########
@@ -392,5 +399,12 @@ FAR char *strerror(int errnum)
 #else
   UNUSED(errnum);
 #endif
-  return "Unknown error";
+#ifdef CONFIG_LIBC_STRERROR_ERRNUM
+  if (snprintf(s_err, sizeof(s_err), STRERROR_UNKNOWN " %d", errnum) > 0)

Review Comment:
   ditto



##########
libs/libc/netdb/lib_gaistrerror.c:
##########
@@ -105,5 +116,12 @@ FAR const char *gai_strerror(int errnum)
     }
   while (ndxlow <= ndxhi);
 #endif
-  return "Unknown error";
+#ifdef CONFIG_LIBC_GAISTRERROR_ERRNUM
+  if (snprintf(s_err, sizeof(s_err), STRERROR_UNKNOWN " %d", errnum) > 0)

Review Comment:
   I think it is better to
   ```suggestion
     if (snprintf(s_err, sizeof(s_err), STRERROR_UNKNOWN " %d", errnum) < 
sizeof(s_err))
   ```
   as `-1` is unlikely to be returned with current usage, but overflow is 
better thing to catch



##########
libs/libc/string/lib_strerror.c:
##########
@@ -392,5 +399,12 @@ FAR char *strerror(int errnum)
 #else
   UNUSED(errnum);
 #endif
-  return "Unknown error";
+#ifdef CONFIG_LIBC_STRERROR_ERRNUM

Review Comment:
   let's place this block under `#else` of `ifdef CONFIG_LIBC_STRERROR`



-- 
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