]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
stty: portability: accommodate CIL
authorJim Meyering <meyering@redhat.com>
Tue, 12 Jun 2012 14:13:43 +0000 (16:13 +0200)
committerJim Meyering <meyering@redhat.com>
Tue, 12 Jun 2012 14:32:12 +0000 (16:32 +0200)
* src/stty.c (main): Declare locals "mode" and "new_mode" to be static
to ensure that each is initialized to zero, *including* all padding.
While gcc clears padding of a local automatic initialized to "{ 0, }",
CIL does not, and the C99 standard is not clear on this issue.
Reported by Edward Schwartz.  See http://bugs.gnu.org/11675 for details.

THANKS.in
src/stty.c

index b9a6c64af1f7ecbfd05fd32d3fd6a9b8c75b8e3f..51b2c7dda7f7b9c9bd120c0efde5a3e0e05d864c 100644 (file)
--- a/THANKS.in
+++ b/THANKS.in
@@ -172,6 +172,7 @@ Doug Coleman                        coleman@iarc1.ece.utexas.edu
 Doug McLaren                        dougmc@comco.com
 Dragos Harabor                      dharabor@us.oracle.com
 Duncan Roe                          duncanr@optimation.com.au
+Edward Schwartz                     edmcman@cmu.edu
 Edward Welbourne                    eddy@opera.com
 Edzer Pebesma                       Edzer.Pebesma@rivm.nl
 Egmont Koblinger                    egmont@uhulinux.hu
index a3fc3dd3983a4ad0742261135db2e3c054036914..83b502cbc436f1e1d52bf07b005ac4352e3e9f2c 100644 (file)
@@ -730,7 +730,7 @@ main (int argc, char **argv)
 {
   /* 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, };
+  static struct termios mode;
 
   enum output_type output_type;
   int optc;
@@ -1003,7 +1003,7 @@ main (int argc, char **argv)
     {
       /* 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, };
+      static struct termios new_mode;
 
       if (tcsetattr (STDIN_FILENO, TCSADRAIN, &mode))
         error (EXIT_FAILURE, errno, "%s", device_name);