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


##########
libs/libc/stream/lib_stdoutstream.c:
##########
@@ -64,6 +65,43 @@ 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;
+
+  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;
+        }
+
+      result = _NX_GETERRNO(result);
+
+      /* EINTR (meaning that fputc was interrupted by a signal) is the only
+       * recoverable error.
+       */
+    }
+  while (result == EINTR);

Review Comment:
   ```suggestion
     while (result == -EINTR);
   ```



##########
libs/libc/stream/lib_stdsostream.c:
##########
@@ -63,6 +63,42 @@ 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;
+
+  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;
+        }
+
+      result = _NX_GETERRNO(result);

Review Comment:
   ```suggestion
         result = _NX_GETERRVAL(result);
   ```



##########
libs/libc/stream/lib_stdsostream.c:
##########
@@ -63,6 +63,42 @@ 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;
+
+  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;
+        }
+
+      result = _NX_GETERRNO(result);
+
+      /* EINTR (meaning that fputc was interrupted by a signal) is the only
+       * recoverable error.
+       */
+    }
+  while (result == EINTR);

Review Comment:
   ```suggestion
     while (result == -EINTR);
   ```



##########
libs/libc/stream/lib_rawsostream.c:
##########
@@ -73,6 +73,44 @@ 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;
+
+  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().
+       */
+
+      nwritten = _NX_GETERRNO(nwritten);

Review Comment:
   ```suggestion
         nwritten = _NX_GETERRVAL(nwritten);
   ```



##########
libs/libc/stream/lib_rawinstream.c:
##########
@@ -66,6 +66,33 @@ static int rawinstream_getc(FAR struct lib_instream_s *this)
   return EOF;
 }
 
+/****************************************************************************
+ * Name: rawinstream_getc
+ ****************************************************************************/
+
+static int rawinstream_gets(FAR struct lib_instream_s *this,
+                            FAR void *buffer, int len)
+{
+  FAR struct lib_rawinstream_s *rthis = (FAR struct lib_rawinstream_s *)this;
+  int nread;
+
+  DEBUGASSERT(this && rthis->fd >= 0);
+
+  /* Attempt to read one character */
+
+  nread = _NX_READ(rthis->fd, buffer, len);
+  if (nread >= 0)
+    {
+      this->nget += nread;
+    }
+  else
+    {
+      nread = _NX_GETERRNO(nread);

Review Comment:
   ```suggestion
         nread = _NX_GETERRVAL(nread);
   ```



##########
libs/libc/stream/lib_stdinstream.c:
##########
@@ -52,6 +53,33 @@ static int stdinstream_getc(FAR struct lib_instream_s *this)
   return ret;
 }
 
+/****************************************************************************
+ * Name: stdinstream_gets
+ ****************************************************************************/
+
+static int stdinstream_gets(FAR struct lib_instream_s *this,
+                            FAR void *buffer, int len)
+{
+  FAR struct lib_stdinstream_s *sthis = (FAR struct lib_stdinstream_s *)this;
+  int nread = 0;
+
+  DEBUGASSERT(this);
+
+  /* Get the buffer from the incoming stream */
+
+  nread = fread(buffer, len, 1, sthis->stream);
+  if (nread >= 0)
+    {
+      this->nget += nread;
+    }
+  else
+    {
+      nread = _NX_GETERRNO(nread);

Review Comment:
   ```suggestion
         nread = _NX_GETERRVAL(nread);
   ```



##########
libs/libc/stream/lib_rawsostream.c:
##########
@@ -73,6 +73,44 @@ 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;
+
+  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().
+       */
+
+      nwritten = _NX_GETERRNO(nwritten);
+      DEBUGASSERT(nwritten < 0);
+    }
+  while (nwritten == EINTR);

Review Comment:
   ```suggestion
     while (nwritten == -EINTR);
   ```



##########
libs/libc/stream/lib_stdoutstream.c:
##########
@@ -64,6 +65,43 @@ 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;
+
+  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;
+        }
+
+      result = _NX_GETERRNO(result);

Review Comment:
   ```suggestion
         result = _NX_GETERRVAL(result);
   ```



##########
libs/libc/stream/lib_rawsistream.c:
##########
@@ -66,6 +66,33 @@ static int rawsistream_getc(FAR struct lib_sistream_s *this)
   return EOF;
 }
 
+/****************************************************************************
+ * Name: rawsistream_gets
+ ****************************************************************************/
+
+static int rawsistream_gets(FAR struct lib_instream_s *this,
+                            FAR void *buffer, int len)
+{
+  FAR struct lib_rawsistream_s *rthis = (FAR struct lib_rawsistream_s *)this;
+  int nread;
+
+  DEBUGASSERT(this && rthis->fd >= 0);
+
+  /* Attempt to read a buffer */
+
+  nread = _NX_READ(rthis->fd, buffer, len);
+  if (nread >= 0)
+    {
+      this->nget += nread;
+    }
+  else
+    {
+      nread = _NX_GETERRNO(nread);

Review Comment:
   ```suggestion
         nread = _NX_GETERRVAL(nread);
   ```



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