You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/11/25 13:41:59 UTC

[nuttx] 02/02: stream: replace the stream function pointer with a macro

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

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

commit 377bf976131a434c104e6fe2706d0dec33a319ec
Author: yinshengkai <yi...@xiaomi.com>
AuthorDate: Fri Nov 25 17:19:45 2022 +0800

    stream: replace the stream function pointer with a macro
    
    Signed-off-by: yinshengkai <yi...@xiaomi.com>
---
 binfmt/libelf/libelf_coredump.c |  4 ++--
 libs/libc/hex2bin/lib_hex2bin.c | 10 +++++-----
 libs/libc/misc/lib_kbddecode.c  |  8 ++++----
 libs/libc/misc/lib_slcddecode.c | 10 +++++-----
 libs/libc/stdio/lib_libvscanf.c | 34 +++++++++++++++++-----------------
 5 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/binfmt/libelf/libelf_coredump.c b/binfmt/libelf/libelf_coredump.c
index 014621aca5..2bee8a23fd 100644
--- a/binfmt/libelf/libelf_coredump.c
+++ b/binfmt/libelf/libelf_coredump.c
@@ -61,7 +61,7 @@
 
 static int elf_flush(FAR struct elf_dumpinfo_s *cinfo)
 {
-  return cinfo->stream->flush(cinfo->stream);
+  return lib_stream_flush(cinfo->stream);
 }
 
 /****************************************************************************
@@ -81,7 +81,7 @@ static int elf_emit(FAR struct elf_dumpinfo_s *cinfo,
 
   while (total > 0)
     {
-      ret = cinfo->stream->puts(cinfo->stream, ptr, total);
+      ret = lib_stream_puts(cinfo->stream, ptr, total);
       if (ret < 0)
         {
           break;
diff --git a/libs/libc/hex2bin/lib_hex2bin.c b/libs/libc/hex2bin/lib_hex2bin.c
index 495b69deea..5149304735 100644
--- a/libs/libc/hex2bin/lib_hex2bin.c
+++ b/libs/libc/hex2bin/lib_hex2bin.c
@@ -247,17 +247,17 @@ static int readstream(FAR struct lib_instream_s *instream,
 
   /* Skip until the beginning of line start code is encountered */
 
-  ch = instream->get(instream);
+  ch = lib_stream_getc(instream);
   while (ch != RECORD_STARTCODE && ch != EOF)
     {
-      ch = instream->get(instream);
+      ch = lib_stream_getc(instream);
     }
 
   /* Skip over the startcode */
 
   if (ch != EOF)
     {
-      ch = instream->get(instream);
+      ch = lib_stream_getc(instream);
     }
 
   /* Then read, verify, and buffer until the end of line is encountered */
@@ -286,7 +286,7 @@ static int readstream(FAR struct lib_instream_s *instream,
 
       /* Read the next character from the input stream */
 
-      ch = instream->get(instream);
+      ch = lib_stream_getc(instream);
     }
 
   /* Some error occurred: Unexpected EOF, line too long, or bad character in
@@ -563,7 +563,7 @@ int hex2bin(FAR struct lib_instream_s *instream,
 
             if (address != expected)
               {
-                off_t pos = outstream->seek(outstream,
+                off_t pos = lib_stream_seek(outstream,
                                             address - baseaddr, SEEK_SET);
                 if (pos == (off_t)-1)
                   {
diff --git a/libs/libc/misc/lib_kbddecode.c b/libs/libc/misc/lib_kbddecode.c
index 36658433fb..dac910a988 100644
--- a/libs/libc/misc/lib_kbddecode.c
+++ b/libs/libc/misc/lib_kbddecode.c
@@ -139,7 +139,7 @@ int kbd_decode(FAR struct lib_instream_s *stream,
 
   /* No, ungotten characters.  Check for the beginning of an ESC sequence. */
 
-  ch = stream->get(stream);
+  ch = lib_stream_getc(stream);
   if (ch == EOF)
     {
       /* End of file/stream */
@@ -163,7 +163,7 @@ int kbd_decode(FAR struct lib_instream_s *stream,
 
   /* Check for ESC-[ */
 
-  ch = stream->get(stream);
+  ch = lib_stream_getc(stream);
   if (ch == EOF)
     {
       /* End of file/stream.  Return the escape character now.  We will
@@ -189,7 +189,7 @@ int kbd_decode(FAR struct lib_instream_s *stream,
 
   /* Get and verify the special keyboard data to decode */
 
-  ch = stream->get(stream);
+  ch = lib_stream_getc(stream);
   if (ch == EOF)
     {
       /* End of file/stream.  Unget everything and return the ESC character.
@@ -216,7 +216,7 @@ int kbd_decode(FAR struct lib_instream_s *stream,
 
   /* Check for the final semicolon */
 
-  ch = stream->get(stream);
+  ch = lib_stream_getc(stream);
   if (ch == EOF)
     {
       /* End of file/stream.  Unget everything and return the ESC character.
diff --git a/libs/libc/misc/lib_slcddecode.c b/libs/libc/misc/lib_slcddecode.c
index 70c23a60ad..6ff5580ea6 100644
--- a/libs/libc/misc/lib_slcddecode.c
+++ b/libs/libc/misc/lib_slcddecode.c
@@ -177,7 +177,7 @@ enum slcdret_e slcd_decode(FAR struct lib_instream_s *stream,
 
   /* No, ungotten characters.  Get the next character from the buffer. */
 
-  ch = stream->get(stream);
+  ch = lib_stream_getc(stream);
   if (ch == EOF)
     {
       /* End of file/stream (or perhaps an I/O error) */
@@ -201,7 +201,7 @@ enum slcdret_e slcd_decode(FAR struct lib_instream_s *stream,
 
   /* Get the next character from the buffer */
 
-  ch = stream->get(stream);
+  ch = lib_stream_getc(stream);
   if (ch == EOF)
     {
       /* End of file/stream.  Return the escape character now.  We will
@@ -230,7 +230,7 @@ enum slcdret_e slcd_decode(FAR struct lib_instream_s *stream,
 
   /* Get the next character from the buffer */
 
-  ch = stream->get(stream);
+  ch = lib_stream_getc(stream);
   if (ch == EOF)
     {
       /* End of file/stream.  Return the ESC now; return the following
@@ -278,7 +278,7 @@ enum slcdret_e slcd_decode(FAR struct lib_instream_s *stream,
 
       /* Get the next character from the buffer */
 
-      ch = stream->get(stream);
+      ch = lib_stream_getc(stream);
       if (ch == EOF)
         {
           /* End of file/stream.  Return the ESC now; return the following
@@ -311,7 +311,7 @@ enum slcdret_e slcd_decode(FAR struct lib_instream_s *stream,
 
       /* Get the next character from the buffer */
 
-      ch = stream->get(stream);
+      ch = lib_stream_getc(stream);
       if (ch == EOF)
         {
           /* End of file/stream.  Return the ESC now; return the following
diff --git a/libs/libc/stdio/lib_libvscanf.c b/libs/libc/stdio/lib_libvscanf.c
index 12416632eb..0be28b5aaf 100644
--- a/libs/libc/stdio/lib_libvscanf.c
+++ b/libs/libc/stdio/lib_libvscanf.c
@@ -256,7 +256,7 @@ int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc,
 
   /* Get first character, we keep always the next character in c */
 
-  c = obj->get(obj);
+  c = lib_stream_getc(obj);
 
   while (fmt_char(fmt))
     {
@@ -266,7 +266,7 @@ int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc,
         {
           while (isspace(c))
             {
-              c = obj->get(obj);
+              c = lib_stream_getc(obj);
             }
         }
 
@@ -366,7 +366,7 @@ int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc,
 
               while (isspace(c))
                 {
-                  c = obj->get(obj);
+                  c = lib_stream_getc(obj);
                 }
 
               /* But we only perform the data conversion is we still have
@@ -390,7 +390,7 @@ int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc,
                         }
 
                       fwidth++;
-                      c = obj->get(obj);
+                      c = lib_stream_getc(obj);
                     }
 
                   if (!noassign)
@@ -445,7 +445,7 @@ int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc,
                         }
 
                       fwidth++;
-                      c = obj->get(obj);
+                      c = lib_stream_getc(obj);
                     }
 
                   if (!fwidth)
@@ -509,7 +509,7 @@ int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc,
                         }
 
                       fwidth++;
-                      c = obj->get(obj);
+                      c = lib_stream_getc(obj);
                     }
 
                   if (fwidth != width)
@@ -582,7 +582,7 @@ int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc,
 
               while (isspace(c))
                 {
-                  c = obj->get(obj);
+                  c = lib_stream_getc(obj);
                 }
 
               /* But we only perform the data conversion if we still have
@@ -641,7 +641,7 @@ int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc,
                           if (!stopconv)
                             {
                               tmp[fwidth++] = c;
-                              c = obj->get(obj);
+                              c = lib_stream_getc(obj);
                             }
                         }
 
@@ -691,7 +691,7 @@ int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc,
                           if (!stopconv)
                             {
                               tmp[fwidth++] = c;
-                              c = obj->get(obj);
+                              c = lib_stream_getc(obj);
                             }
                         }
 
@@ -716,7 +716,7 @@ int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc,
                           if (!stopconv)
                             {
                               tmp[fwidth++] = c;
-                              c = obj->get(obj);
+                              c = lib_stream_getc(obj);
                             }
                         }
 
@@ -741,7 +741,7 @@ int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc,
                           if (!stopconv)
                             {
                               tmp[fwidth++] = c;
-                              c = obj->get(obj);
+                              c = lib_stream_getc(obj);
                             }
                         }
 
@@ -796,7 +796,7 @@ int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc,
                           if (!stopconv)
                             {
                               tmp[fwidth++] = c;
-                              c = obj->get(obj);
+                              c = lib_stream_getc(obj);
                             }
                         }
                       break;
@@ -954,7 +954,7 @@ int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc,
 
               while (isspace(c))
                 {
-                  c = obj->get(obj);
+                  c = lib_stream_getc(obj);
                 }
 
               /* But we only perform the data conversion is we still have
@@ -1038,7 +1038,7 @@ int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc,
                       if (!stopconv)
                         {
                           tmp[fwidth++] = c;
-                          c = obj->get(obj);
+                          c = lib_stream_getc(obj);
                         }
                     }
 
@@ -1168,7 +1168,7 @@ int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc,
                 }
               else
                 {
-                  c = obj->get(obj);
+                  c = lib_stream_getc(obj);
                 }
             }
 
@@ -1188,7 +1188,7 @@ int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc,
 
           while (isspace(c))
             {
-              c = obj->get(obj);
+              c = lib_stream_getc(obj);
             }
 #endif
 
@@ -1201,7 +1201,7 @@ int lib_vscanf(FAR struct lib_instream_s *obj, FAR int *lastc,
           else
             {
               fmt++;
-              c = obj->get(obj);
+              c = lib_stream_getc(obj);
             }
         }
       else