-------- Forwarded Message --------
Subject:        [nuttx] [PATCH] doubt about fwrite
Date:   Sun, 22 Dec 2019 18:30:04 -0800 (PST)
From:   wei peng <alvin.pe...@gmail.com>
Reply-To:       nu...@googlegroups.com
To:     NuttX <nu...@googlegroups.com>



hi~
  I connected the target board to terminal via "telnet" , in some cases the terminal will be frozen. Here are detailed steps:

1. Enable "CONFIG_IOB_DEBUG"[necessary].
2. New two terminals and connect to target board via "telnet".
3. Input "dmesg" command,and the terminal will show information
   *continuously*.[two terminals are same][necessary]
4. Close one of  the terminals,and the other one will be frozen.but the
   system is work on.

I debug the system and repaired the bug,the file named commit.txt is  detailed steps.
--
You received this message because you are subscribed to the Google Groups "NuttX" group. To unsubscribe from this group and stop receiving emails from it, send an email to nuttx+unsubscr...@googlegroups.com <mailto:nuttx+unsubscr...@googlegroups.com>. To view this discussion on the web visit https://groups.google.com/d/msgid/nuttx/6774458a-9e68-4dcb-b83d-cfaeb9e7a857%40googlegroups.com <https://groups.google.com/d/msgid/nuttx/6774458a-9e68-4dcb-b83d-cfaeb9e7a857%40googlegroups.com?utm_medium=email&utm_source=footer>.
diff --git a/nuttx/include/stdio.h b/nuttx/include/stdio.h
index 9a13052..033acbb 100755
--- a/nuttx/include/stdio.h
+++ b/nuttx/include/stdio.h
@@ -161,7 +161,7 @@ FAR FILE *freopen(FAR const char *path, FAR const char 
*mode,
 int    fseek(FAR FILE *stream, long int offset, int whence);
 int    fsetpos(FAR FILE *stream, FAR fpos_t *pos);
 long   ftell(FAR FILE *stream);
-size_t fwrite(FAR const void *ptr, size_t size, size_t n_items,
+ssize_t fwrite(FAR const void *ptr, size_t size, size_t n_items,
          FAR FILE *stream);
 FAR char *gets(FAR char *s);
 FAR char *gets_s(FAR char *s, rsize_t n);

diff --git a/nuttx/libs/libc/stdio/lib_fwrite.c 
b/nuttx/libs/libc/stdio/lib_fwrite.c
index 6426b70..4713fa0 100755
--- a/nuttx/libs/libc/stdio/lib_fwrite.c
+++ b/nuttx/libs/libc/stdio/lib_fwrite.c
@@ -52,7 +52,7 @@
  * Name: fwrite
  ****************************************************************************/
 
-size_t fwrite(FAR const void *ptr, size_t size, size_t n_items,
+ssize_t fwrite(FAR const void *ptr, size_t size, size_t n_items,
               FAR FILE *stream)
 {
   size_t  full_size = n_items * (size_t)size;
@@ -67,6 +67,8 @@ size_t fwrite(FAR const void *ptr, size_t size, size_t 
n_items,
       /* Return the number of full items written */
 
       items_written = bytes_written / size;
+    }else{
+       items_written = bytes_written;
     }
 
   return items_written;


diff --git a/apps/nshlib/nsh_fsutils.c b/apps/nshlib/nsh_fsutils.c
index f6545d6..3eb2e7f 100755
--- a/apps/nshlib/nsh_fsutils.c
+++ b/apps/nshlib/nsh_fsutils.c
@@ -98,7 +98,7 @@ int nsh_catfile(FAR struct nsh_vtbl_s *vtbl, FAR const char 
*cmd,
 
   /* And just dump it byte for byte into stdout */
 
-  for (;;)
+  while (ret >= 0)
     {
       int nbytesread = read(fd, buffer, IOBUFFERSIZE);




Reply via email to