This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new b99a96a7d0 stream: Exchange name of lib_rawsostream.c and 
lib_rawoutstream.c
b99a96a7d0 is described below

commit b99a96a7d0ecc1dc2c9d9ed046f6967897909f17
Author: Huang Qi <[email protected]>
AuthorDate: Wed Mar 1 16:42:46 2023 +0800

    stream: Exchange name of lib_rawsostream.c and lib_rawoutstream.c
    
    Signed-off-by: Huang Qi <[email protected]>
---
 libs/libc/stream/lib_rawoutstream.c | 69 +++++++++++++++++--------------------
 libs/libc/stream/lib_rawsostream.c  | 69 ++++++++++++++++++++-----------------
 2 files changed, 69 insertions(+), 69 deletions(-)

diff --git a/libs/libc/stream/lib_rawoutstream.c 
b/libs/libc/stream/lib_rawoutstream.c
index 7b2d255f42..e895067743 100644
--- a/libs/libc/stream/lib_rawoutstream.c
+++ b/libs/libc/stream/lib_rawoutstream.c
@@ -37,53 +37,46 @@
  ****************************************************************************/
 
 /****************************************************************************
- * Name: rawsostream_putc
+ * Name: rawoutstream_puts
  ****************************************************************************/
 
-static void rawsostream_putc(FAR struct lib_sostream_s *this, int ch)
+static int rawoutstream_puts(FAR struct lib_outstream_s *this,
+                             FAR const void *buf, int len)
 {
-  FAR struct lib_rawsostream_s *rthis = (FAR struct lib_rawsostream_s *)this;
-  char buffer = ch;
-  int nwritten;
-  int errcode;
+  FAR struct lib_rawoutstream_s *rthis =
+                                (FAR struct lib_rawoutstream_s *)this;
+  int nwritten = 0;
+  int ret = 0;
 
-  DEBUGASSERT(this && rthis->fd >= 0);
-
-  /* Loop until the character is successfully transferred or until an
-   * irrecoverable error occurs.
-   */
-
-  do
+  while (nwritten != len)
     {
-      nwritten = _NX_WRITE(rthis->fd, &buffer, 1);
-      if (nwritten == 1)
+      ret = _NX_WRITE(rthis->fd, (FAR const char *)buf + nwritten,
+                      len - nwritten);
+      if (ret <= 0)
         {
-          this->nput++;
-          return;
-        }
+          if (_NX_GETERRNO(ret) == EINTR)
+            {
+              continue;
+            }
 
-      /* 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().
-       */
+          break;
+        }
 
-      errcode = _NX_GETERRNO(nwritten);
-      DEBUGASSERT(nwritten < 0);
+      this->nput += ret;
+      nwritten   += ret;
     }
-  while (errcode == EINTR);
+
+  return nwritten > 0 ? nwritten : ret;
 }
 
 /****************************************************************************
- * Name: rawsostream_seek
+ * Name: rawoutstream_putc
  ****************************************************************************/
 
-static off_t rawsostream_seek(FAR struct lib_sostream_s *this, off_t offset,
-                              int whence)
+static void rawoutstream_putc(FAR struct lib_outstream_s *this, int ch)
 {
-  FAR struct lib_rawsostream_s *mthis = (FAR struct lib_rawsostream_s *)this;
-
-  DEBUGASSERT(this);
-  return _NX_SEEK(mthis->fd, offset, whence);
+  char tmp = ch;
+  rawoutstream_puts(this, &tmp, 1);
 }
 
 /****************************************************************************
@@ -91,14 +84,14 @@ static off_t rawsostream_seek(FAR struct lib_sostream_s 
*this, off_t offset,
  ****************************************************************************/
 
 /****************************************************************************
- * Name: lib_rawsostream
+ * Name: lib_rawoutstream
  *
  * Description:
  *   Initializes a stream for use with a file descriptor.
  *
  * Input Parameters:
  *   outstream - User allocated, uninitialized instance of struct
- *               lib_rawsostream_s to be initialized.
+ *               lib_rawoutstream_s to be initialized.
  *   fd        - User provided file/socket descriptor (must have been opened
  *               for write access).
  *
@@ -107,11 +100,11 @@ static off_t rawsostream_seek(FAR struct lib_sostream_s 
*this, off_t offset,
  *
  ****************************************************************************/
 
-void lib_rawsostream(FAR struct lib_rawsostream_s *outstream, int fd)
+void lib_rawoutstream(FAR struct lib_rawoutstream_s *outstream, int fd)
 {
-  outstream->public.putc  = rawsostream_putc;
-  outstream->public.flush = lib_snoflush;
-  outstream->public.seek  = rawsostream_seek;
+  outstream->public.putc  = rawoutstream_putc;
+  outstream->public.puts  = rawoutstream_puts;
+  outstream->public.flush = lib_noflush;
   outstream->public.nput  = 0;
   outstream->fd           = fd;
 }
diff --git a/libs/libc/stream/lib_rawsostream.c 
b/libs/libc/stream/lib_rawsostream.c
index 7cfded60e4..468fbcd7e3 100644
--- a/libs/libc/stream/lib_rawsostream.c
+++ b/libs/libc/stream/lib_rawsostream.c
@@ -37,46 +37,53 @@
  ****************************************************************************/
 
 /****************************************************************************
- * Name: rawoutstream_puts
+ * Name: rawsostream_putc
  ****************************************************************************/
 
-static int rawoutstream_puts(FAR struct lib_outstream_s *this,
-                             FAR const void *buf, int len)
+static void rawsostream_putc(FAR struct lib_sostream_s *this, int ch)
 {
-  FAR struct lib_rawoutstream_s *rthis =
-                                (FAR struct lib_rawoutstream_s *)this;
-  int nwritten = 0;
-  int ret = 0;
+  FAR struct lib_rawsostream_s *rthis = (FAR struct lib_rawsostream_s *)this;
+  char buffer = ch;
+  int nwritten;
+  int errcode;
 
-  while (nwritten != len)
+  DEBUGASSERT(this && rthis->fd >= 0);
+
+  /* Loop until the character is successfully transferred or until an
+   * irrecoverable error occurs.
+   */
+
+  do
     {
-      ret = _NX_WRITE(rthis->fd, (FAR const char *)buf + nwritten,
-                      len - nwritten);
-      if (ret <= 0)
+      nwritten = _NX_WRITE(rthis->fd, &buffer, 1);
+      if (nwritten == 1)
         {
-          if (_NX_GETERRNO(ret) == EINTR)
-            {
-              continue;
-            }
-
-          break;
+          this->nput++;
+          return;
         }
 
-      this->nput += ret;
-      nwritten   += ret;
-    }
+      /* 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().
+       */
 
-  return nwritten > 0 ? nwritten : ret;
+      errcode = _NX_GETERRNO(nwritten);
+      DEBUGASSERT(nwritten < 0);
+    }
+  while (errcode == EINTR);
 }
 
 /****************************************************************************
- * Name: rawoutstream_putc
+ * Name: rawsostream_seek
  ****************************************************************************/
 
-static void rawoutstream_putc(FAR struct lib_outstream_s *this, int ch)
+static off_t rawsostream_seek(FAR struct lib_sostream_s *this, off_t offset,
+                              int whence)
 {
-  char tmp = ch;
-  rawoutstream_puts(this, &tmp, 1);
+  FAR struct lib_rawsostream_s *mthis = (FAR struct lib_rawsostream_s *)this;
+
+  DEBUGASSERT(this);
+  return _NX_SEEK(mthis->fd, offset, whence);
 }
 
 /****************************************************************************
@@ -84,14 +91,14 @@ static void rawoutstream_putc(FAR struct lib_outstream_s 
*this, int ch)
  ****************************************************************************/
 
 /****************************************************************************
- * Name: lib_rawoutstream
+ * Name: lib_rawsostream
  *
  * Description:
  *   Initializes a stream for use with a file descriptor.
  *
  * Input Parameters:
  *   outstream - User allocated, uninitialized instance of struct
- *               lib_rawoutstream_s to be initialized.
+ *               lib_rawsostream_s to be initialized.
  *   fd        - User provided file/socket descriptor (must have been opened
  *               for write access).
  *
@@ -100,11 +107,11 @@ static void rawoutstream_putc(FAR struct lib_outstream_s 
*this, int ch)
  *
  ****************************************************************************/
 
-void lib_rawoutstream(FAR struct lib_rawoutstream_s *outstream, int fd)
+void lib_rawsostream(FAR struct lib_rawsostream_s *outstream, int fd)
 {
-  outstream->public.putc  = rawoutstream_putc;
-  outstream->public.puts  = rawoutstream_puts;
-  outstream->public.flush = lib_noflush;
+  outstream->public.putc  = rawsostream_putc;
+  outstream->public.flush = lib_snoflush;
+  outstream->public.seek  = rawsostream_seek;
   outstream->public.nput  = 0;
   outstream->fd           = fd;
 }

Reply via email to