xiaoxiang781216 commented on code in PR #8685:
URL: https://github.com/apache/nuttx/pull/8685#discussion_r1122618542


##########
libs/libc/stream/lib_rawsostream.c:
##########
@@ -73,6 +73,45 @@ static void rawsostream_putc(FAR struct lib_sostream_s 
*this, int ch)
   while (errcode == EINTR);
 }
 
+/****************************************************************************
+ * Name: rawsostream_puts
+ ****************************************************************************/
+
+static int rawsostream_puts(FAR struct lib_sostream_s *this,
+                            FAR const void *buffer, int len)
+{
+  FAR struct lib_rawsostream_s *rthis = (FAR struct lib_rawsostream_s *)this;
+  int nwritten;
+  int errcode;
+
+  DEBUGASSERT(this && rthis->fd >= 0);
+
+  /* Loop until the buffer is successfully transferred or until an
+   * irrecoverable error occurs.
+   */
+
+  do
+    {
+      nwritten = _NX_WRITE(rthis->fd, buffer, len);
+      if (nwritten >= 0)
+        {
+          this->nput += nwritten;
+          return nwritten;
+        }
+
+      /* The only expected error is EINTR, meaning that the write operation
+       * was awakened by a signal.  Zero would not be a valid return value
+       * from _NX_WRITE().
+       */
+
+      errcode = _NX_GETERRNO(nwritten);

Review Comment:
   nwritten = _NX_GETERRNO(nwritten);
   and remove errcode 



##########
libs/libc/stream/lib_stdoutstream.c:
##########
@@ -64,6 +65,44 @@ static void stdoutstream_putc(FAR struct lib_outstream_s 
*this, int ch)
   while (get_errno() == EINTR);
 }
 
+/****************************************************************************
+ * Name: stdoutstream_puts
+ ****************************************************************************/
+
+static int stdoutstream_puts(FAR struct lib_outstream_s *this,
+                             FAR const void *buffer, int len)
+{
+  FAR struct lib_stdoutstream_s *sthis =
+                               (FAR struct lib_stdoutstream_s *)this;
+  int result;
+  int errcode;
+
+  DEBUGASSERT(this && sthis->stream);
+
+  /* Loop until the buffer is successfully transferred or an irrecoverable
+   * error occurs.
+   */
+
+  do
+    {
+      result = fwrite(buffer, len, 1, sthis->stream);
+      if (result >= 0)
+        {
+          this->nput += result;
+          return result;
+        }
+
+      errcode = _NX_GETERRNO(result);

Review Comment:
   result = _NX_GETERRNO(result);
   and remove errcode 



##########
libs/libc/stream/lib_stdsostream.c:
##########
@@ -63,6 +63,43 @@ static void stdsostream_putc(FAR struct lib_sostream_s 
*this, int ch)
   while (get_errno() == EINTR);
 }
 
+/****************************************************************************
+ * Name: stdsostream_puts
+ ****************************************************************************/
+
+static int stdsostream_puts(FAR struct lib_sostream_s *this,
+                            FAR const void *buffer, int len)
+{
+  FAR struct lib_stdsostream_s *sthis = (FAR struct lib_stdsostream_s *)this;
+  int result;
+  int errcode;
+
+  DEBUGASSERT(this && sthis->stream);
+
+  /* Loop until the character is successfully transferred or an irrecoverable
+   * error occurs.
+   */
+
+  do
+    {
+      result = lib_fwrite(buffer, len, sthis->stream);
+      if (result >= 0)
+        {
+          this->nput += result;
+          return result;
+        }
+
+      errcode = _NX_GETERRNO(result);

Review Comment:
   result = _NX_GETERRNO(result);
   and remove errcode



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