manual: Fix termios.c example. (Bug 31078)

Message ID 20231120184732.1590032-1-carlos@redhat.com
State Committed
Commit 3cbaacdfd2c11cb726011ef6464dce00c186a2bf
Headers
Series manual: Fix termios.c example. (Bug 31078) |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
redhat-pt-bot/TryBot-32bit success Build for i686
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 warning Patch is already merged
linaro-tcwg-bot/tcwg_glibc_check--master-arm warning Patch is already merged
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 warning Patch is already merged
linaro-tcwg-bot/tcwg_glibc_build--master-arm warning Patch is already merged

Commit Message

Carlos O'Donell Nov. 20, 2023, 6:47 p.m. UTC
  Remove the unused 'char *name;' from the example.

Use write instead of putchar to write input as it is read.

Example tested on x86_64 by compiling and running the example.

Tested by building the manual pdf and reviewing the results.
---
 manual/examples/termios.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Comments

Florian Weimer Nov. 20, 2023, 9:38 p.m. UTC | #1
* Carlos O'Donell:

> Remove the unused 'char *name;' from the example.
>
> Use write instead of putchar to write input as it is read.
>
> Example tested on x86_64 by compiling and running the example.
>
> Tested by building the manual pdf and reviewing the results.

Looks okay.

Reviewed-by: Florian Weimer <fweimer@redhat.com>

Thanks,
Florian
  
Carlos O'Donell Nov. 20, 2023, 9:44 p.m. UTC | #2
On 11/20/23 16:38, Florian Weimer wrote:
> * Carlos O'Donell:
> 
>> Remove the unused 'char *name;' from the example.
>>
>> Use write instead of putchar to write input as it is read.
>>
>> Example tested on x86_64 by compiling and running the example.
>>
>> Tested by building the manual pdf and reviewing the results.
> 
> Looks okay.
> 
> Reviewed-by: Florian Weimer <fweimer@redhat.com>

Pushed. Bug marked fixed. Thank you :-}
  

Patch

diff --git a/manual/examples/termios.c b/manual/examples/termios.c
index 751e57ad71..65bedad9cc 100644
--- a/manual/examples/termios.c
+++ b/manual/examples/termios.c
@@ -34,7 +34,6 @@  void
 set_input_mode (void)
 {
   struct termios tattr;
-  char *name;
 
   /* Make sure stdin is a terminal. */
   if (!isatty (STDIN_FILENO))
@@ -70,7 +69,7 @@  main (void)
       if (c == '\004')		/* @kbd{C-d} */
 	break;
       else
-	putchar (c);
+	write (STDOUT_FILENO, &c, 1);
     }
 
   return EXIT_SUCCESS;