yangsong8-a1 opened a new pull request, #21801:
URL: https://github.com/apache/nuttx/pull/21801

   ## Summary
   
   Two small static analysis fixes in drivers/serial/pty.c:
   
   - pty_read(): pass `(unsigned char)ch` to iscntrl() instead of `ch & 0xff`
     (MISRA C-2012 Rule 21.13). No behavior change.
   - pty_poll(): in the teardown path, return -EINVAL when `fds->priv` is NULL
     instead of dereferencing it.
   
   ## Impact
   
   pty only. Normal poll setup/teardown and read are unchanged.
   
   ## Testing
   
   Ubuntu 22.04, gcc 13.1. sim:nsh with CONFIG_PSEUDOTERM (SUSv1) and a test
   app (not part of this PR), no new warnings.
   
   | Test | apache/master | This PR |
   |---|---|---|
   | /dev/ptmx open/close with data, 20 times | fails=0 | fails=0 |
   | Slave read with ECHO, input `h\xe9llo\n` | master gets `68 e9 6c 6c 6f 0d 
0d 0a` | same |
   | `file_poll(&f, &fds, false)` on /dev/pty6 with `fds.priv == NULL` | sim 
crashes (SIGSEGV) | returns -22 (-EINVAL) |
   
   ```
   poll: file_open /dev/pty6 -> 0
   poll: teardown with priv == NULL ...
   poll: teardown -> -22 (expect -22)
   ```
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to