You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/10/14 09:58:36 UTC

[GitHub] [incubator-nuttx] pkarashchenko opened a new pull request, #7310: libs/libc/stdio: fix ungetc operation

pkarashchenko opened a new pull request, #7310:
URL: https://github.com/apache/incubator-nuttx/pull/7310

   ## Summary
   According to https://pubs.opengroup.org/onlinepubs/9699919799 the `ungetc` should not set errno in case of failure. Also `If the value of c equals that of the macro EOF, the operation shall fail and the input stream shall be left unchanged.`
   
   ## Impact
   Improve POSIX compliance
   
   ## Testing
   Pass CI


-- 
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: commits-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] acassis commented on a diff in pull request #7310: libs/libc/stdio: fix ungetc operation

Posted by GitBox <gi...@apache.org>.
acassis commented on code in PR #7310:
URL: https://github.com/apache/incubator-nuttx/pull/7310#discussion_r995838280


##########
libs/libc/stdio/lib_ungetc.c:
##########
@@ -43,19 +43,17 @@ int ungetc(int c, FAR FILE *stream)
   int nungotten;
 #endif
 
-  /* Verify that a non-NULL stream was provided */
+  /* Verify that a non-NULL stream was provided and c is not EOF */
 
-  if (!stream)
+  if (!stream || c == EOF)

Review Comment:
   Initially I was thinking it couldn't never test 'c', but the only way it happen is if 'stream' is NULL, so then everything is fine!



-- 
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: commits-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #7310: libs/libc/stdio: fix ungetc operation

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged PR #7310:
URL: https://github.com/apache/incubator-nuttx/pull/7310


-- 
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: commits-unsubscribe@nuttx.apache.org

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


[GitHub] [incubator-nuttx] acassis commented on a diff in pull request #7310: libs/libc/stdio: fix ungetc operation

Posted by GitBox <gi...@apache.org>.
acassis commented on code in PR #7310:
URL: https://github.com/apache/incubator-nuttx/pull/7310#discussion_r995838280


##########
libs/libc/stdio/lib_ungetc.c:
##########
@@ -43,19 +43,17 @@ int ungetc(int c, FAR FILE *stream)
   int nungotten;
 #endif
 
-  /* Verify that a non-NULL stream was provided */
+  /* Verify that a non-NULL stream was provided and c is not EOF */
 
-  if (!stream)
+  if (!stream || c == EOF)

Review Comment:
   Initially I was thinking it couldn't never test 'c', but the only way it happen is if 'stream' is NULL, so the everything is fine!



-- 
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: commits-unsubscribe@nuttx.apache.org

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