masayuki2009 edited a comment on pull request #425:
URL: 
https://github.com/apache/incubator-nuttx-apps/pull/425#issuecomment-717815230


   > > Done, both rebase to the latest master.
   > 
   > @xiaoxiang781216
   > I think you pushed the commit to 
https://github.com/xiaoxiang781216/incubator-nuttx-apps/tree/fclose
   > However, this PR is from 
https://github.com/apache/incubator-nuttx-apps/tree/fclose
   
   @xiaoxiang781216 
   
   I tried 
   https://github.com/xiaoxiang781216/incubator-nuttx-apps/tree/fclose
   and
   https://github.com/xiaoxiang781216/incubator-nuttx/tree/fclose3
   with stm32f4discovery:usbnsh
   
   Then start terminal program on Ubuntu 18.04
   $ picocom -b 115200 /dev/ttyACM0
   
   However, lib_fwrite() always fails.
   
   ```
   (gdb) where                                                                  
                                                                                
                                   
   #0  lib_fwrite (ptr=ptr@entry=0x8011590 <g_nshgreeting>, count=29, 
stream=stream@entry=0x200012fc) at stdio/lib_libfwrite.c:81                     
                                             
   #1  0x0800f12a in fputs (s=0x8011590 <g_nshgreeting> "\nNuttShell (NSH) 
NuttX-8.2.0\n", stream=0x200012fc) at stdio/lib_fputs.c:171                     
                                        
   #2  0x08005b40 in nsh_session (pstate=0x10000bd0, login=<optimized out>, 
argc=1, argv=0x10000b88) at nsh_session.c:106                                   
                                       
   #3  0x080058ce in nsh_consolemain (argc=argc@entry=1, 
argv=argv@entry=0x10000b88) at nsh_usbconsole.c:334                             
                                                          
   #4  0x080057b8 in nsh_main (argc=1, argv=0x10000b88) at nsh_main.c:168       
                                                                                
                                   
   #5  0x08003252 in nxtask_startup (entrypt=0x800578d <nsh_main>, 
entrypt@entry=0x20000188 <inited>, argc=1, argv=0x10000b88) at 
sched/task_startup.c:165                                         
   #6  0x08001cdc in nxtask_start () at task/task_start.c:144                   
                                                                                
                                   
   #7  0x00000000 in ?? () 
   
   
   ssize_t lib_fwrite(FAR const void *ptr, size_t count, FAR FILE *stream)      
                                                                                
                                   
   #ifndef CONFIG_STDIO_DISABLE_BUFFERING                                       
                                                                                
                                   
   {                                                                            
                                                                                
                                   
     FAR const unsigned char *start = ptr;                                      
                                                                                
                                   
     FAR const unsigned char *src   = ptr;                                      
                                                                                
                                   
     ssize_t ret = ERROR;                                                       
                                                                                
                                   
     unsigned char *dest;                                                       
                                                                                
                                   
                                                                                
                                                                                
                                   
     /* Make sure that writing to this stream is allowed */                     
                                                                                
                                   
                                                                                
                                                                                
                                   
     if (stream == NULL)                                                        
                                                                                
                                   
       {                                                                        
                                                                                
                                   
         set_errno(EBADF);                                                      
                                                                                
                                   
         return ret;                                                            
                                                                                
                                   
       }                                                                        
                                                                                
                                   
                                                                                
                                                                                
                                   
     /* Check if write access is permitted */                                   
                                                                                
                                   
                                                                                
                                                                                
                                   
     if ((stream->fs_oflags & O_WROK) == 0)                                     
                                                                                
                                   
       {                                                                        
                                                                                
                                   
   =>    set_errno(EBADF);                                                      
                                                                                
                                   
         goto errout;                                                           
                                                                                
                                   
       }                         
   ```
   


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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to