diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2006-10-10 22:57:07 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2006-10-10 22:57:07 +0000 |
commit | e245a66054cac00f2916fbc9436d926ea2cf4d1c (patch) | |
tree | b36a56e3bede31be2c78a76e0bfe7db73670587a /src/stty.c | |
parent | 489ff7f0cdaa63403aefcce778ea7214dc4e6808 (diff) | |
download | coreutils-e245a66054cac00f2916fbc9436d926ea2cf4d1c.tar.xz |
* src/ls.c (quote_name): Use initializer rather than memset to
initialize an object to zero. This is easier to read and is less
likely to introduce an runtime error due to a mixup. It causes
gcc -W to issue a warning, but you can work around this by
appending -Wno-missing-field-initializers.
* src/pathchk.c (portable_chars_only): Likewise.
* src/shred.c (main): Likewise.
* src/stty.c (main): Likewise.
* src/tr.c (card_of_complement): Likewise.
* src/wc.c (wc): Likewise.
Diffstat (limited to 'src/stty.c')
-rw-r--r-- | src/stty.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/stty.c b/src/stty.c index 9e1ba0a7c..33a821d25 100644 --- a/src/stty.c +++ b/src/stty.c @@ -729,7 +729,10 @@ settings, CHAR is taken literally, or coded as in ^c, 0x37, 0177 or\n\ int main (int argc, char **argv) { - struct termios mode; + /* Initialize to all zeroes so there is no risk memcmp will report a + spurious difference in an uninitialized portion of the structure. */ + struct termios mode = { 0, }; + enum output_type output_type; int optc; int argi = 0; @@ -840,9 +843,6 @@ main (int argc, char **argv) else device_name = _("standard input"); - /* Initialize to all zeroes so there is no risk memcmp will report a - spurious difference in an uninitialized portion of the structure. */ - memset (&mode, 0, sizeof (mode)); if (tcgetattr (STDIN_FILENO, &mode)) error (EXIT_FAILURE, errno, "%s", device_name); @@ -1002,7 +1002,9 @@ main (int argc, char **argv) if (require_set_attr) { - struct termios new_mode; + /* Initialize to all zeroes so there is no risk memcmp will report a + spurious difference in an uninitialized portion of the structure. */ + struct termios new_mode = { 0, }; if (tcsetattr (STDIN_FILENO, TCSADRAIN, &mode)) error (EXIT_FAILURE, errno, "%s", device_name); @@ -1014,9 +1016,6 @@ main (int argc, char **argv) this partial failure, get the current terminal attributes and compare them to the requested ones. */ - /* Initialize to all zeroes so there is no risk memcmp will report a - spurious difference in an uninitialized portion of the structure. */ - memset (&new_mode, 0, sizeof (new_mode)); if (tcgetattr (STDIN_FILENO, &new_mode)) error (EXIT_FAILURE, errno, "%s", device_name); |