* tty compile warnings
@ 2008-09-01 13:27 Robert Reif
2008-09-01 13:57 ` Alan Cox
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Robert Reif @ 2008-09-01 13:27 UTC (permalink / raw)
To: sparclinux
I have been getting these compile warnings on sparc32 for a few weeks now:
CC drivers/char/n_tty.o
drivers/char/n_tty.c: In function ‘normal_poll’:
drivers/char/n_tty.c:1555: warning: array subscript is above array bounds
drivers/char/n_tty.c:1564: warning: array subscript is above array bounds
drivers/char/n_tty.c: In function ‘read_chan’:
drivers/char/n_tty.c:1269: warning: array subscript is above array bounds
CC drivers/char/tty_ioctl.o
drivers/char/tty_ioctl.c: In function ‘set_termios’:
drivers/char/tty_ioctl.c:533: warning: array subscript is above array bounds
drivers/char/tty_ioctl.c:537: warning: array subscript is above array bounds
drivers/char/tty_ioctl.c: In function ‘tty_mode_ioctl’:
drivers/char/tty_ioctl.c:662: warning: array subscript is above array bounds
drivers/char/tty_ioctl.c:892: warning: array subscript is above array bounds
drivers/char/tty_ioctl.c:896: warning: array subscript is above array bounds
drivers/char/tty_ioctl.c:577: warning: array subscript is above array bounds
drivers/char/tty_ioctl.c:928: warning: array subscript is above array bounds
drivers/char/tty_ioctl.c:934: warning: array subscript is above array bounds
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: tty compile warnings
2008-09-01 13:27 tty compile warnings Robert Reif
@ 2008-09-01 13:57 ` Alan Cox
2008-09-01 15:58 ` Robert Reif
2008-09-03 0:21 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Alan Cox @ 2008-09-01 13:57 UTC (permalink / raw)
To: sparclinux
On Mon, 01 Sep 2008 09:27:14 -0400
Robert Reif <reif@earthlink.net> wrote:
> I have been getting these compile warnings on sparc32 for a few weeks now:
gcc is complaining about some nasty hacks the sparc32 tree does with
termios.
cc_t c_cc[NCCS]; /* control characters */
#ifdef __KERNEL__
#define SIZEOF_USER_TERMIOS sizeof (struct termios) - (2*sizeof (cc_t))
cc_t _x_cc[2]; /* We need them to hold
vmin/vtime */ #endif
struct ktermios {
tcflag_t c_iflag; /* input mode flags */
tcflag_t c_oflag; /* output mode flags */
tcflag_t c_cflag; /* control mode flags */
tcflag_t c_lflag; /* local mode flags */
cc_t c_line; /* line discipline */
cc_t c_cc[NCCS]; /* control characters */
cc_t _x_cc[2]; /* We need them to hold
vmin/vtime */ speed_t c_ispeed; /* input speed */
speed_t c_ospeed; /* output speed */
};
You could try removing _x_cc[2] and changing [NCCS] to [NCCS+2] which
might work depending upon the alignment you get.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: tty compile warnings
2008-09-01 13:27 tty compile warnings Robert Reif
2008-09-01 13:57 ` Alan Cox
@ 2008-09-01 15:58 ` Robert Reif
2008-09-03 0:21 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Robert Reif @ 2008-09-01 15:58 UTC (permalink / raw)
To: sparclinux
[-- Attachment #1: Type: text/plain, Size: 517 bytes --]
Alan Cox wrote:
> You could try removing _x_cc[2] and changing [NCCS] to [NCCS+2] which
> might work depending upon the alignment you get.
>
The following patch compiles without error but I'm a bit confused
about the sizes. VMIN is 16 and VTIME is 17 so user NCCS should
be 16 and kernel NCCS 18 unless there are padding or some legacy
issues here. 17 + 2 + one for c_line = 20 bytes which makes sense for
padding but NCCS is used to copy the control characters which means
an unused control character is copied.
[-- Attachment #2: tty.diff.txt --]
[-- Type: text/plain, Size: 1493 bytes --]
diff --git a/arch/sparc/include/asm/termbits.h b/arch/sparc/include/asm/termbits.h
index d6ca3e2..c154288 100644
--- a/arch/sparc/include/asm/termbits.h
+++ b/arch/sparc/include/asm/termbits.h
@@ -29,10 +29,11 @@ struct termios {
tcflag_t c_cflag; /* control mode flags */
tcflag_t c_lflag; /* local mode flags */
cc_t c_line; /* line discipline */
+#ifndef __KERNEL__
cc_t c_cc[NCCS]; /* control characters */
-#ifdef __KERNEL__
+#else
+ cc_t c_cc[NCCS+2]; /* kernel needs 2 more to hold vmin/vtime */
#define SIZEOF_USER_TERMIOS sizeof (struct termios) - (2*sizeof (cc_t))
- cc_t _x_cc[2]; /* We need them to hold vmin/vtime */
#endif
};
@@ -42,8 +43,7 @@ struct termios2 {
tcflag_t c_cflag; /* control mode flags */
tcflag_t c_lflag; /* local mode flags */
cc_t c_line; /* line discipline */
- cc_t c_cc[NCCS]; /* control characters */
- cc_t _x_cc[2]; /* padding to match ktermios */
+ cc_t c_cc[NCCS+2]; /* control characters */
speed_t c_ispeed; /* input speed */
speed_t c_ospeed; /* output speed */
};
@@ -54,8 +54,7 @@ struct ktermios {
tcflag_t c_cflag; /* control mode flags */
tcflag_t c_lflag; /* local mode flags */
cc_t c_line; /* line discipline */
- cc_t c_cc[NCCS]; /* control characters */
- cc_t _x_cc[2]; /* We need them to hold vmin/vtime */
+ cc_t c_cc[NCCS+2]; /* control characters */
speed_t c_ispeed; /* input speed */
speed_t c_ospeed; /* output speed */
};
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: tty compile warnings
2008-09-01 13:27 tty compile warnings Robert Reif
2008-09-01 13:57 ` Alan Cox
2008-09-01 15:58 ` Robert Reif
@ 2008-09-03 0:21 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2008-09-03 0:21 UTC (permalink / raw)
To: sparclinux
From: Alan Cox <alan@lxorguk.ukuu.org.uk>
Date: Mon, 1 Sep 2008 14:57:29 +0100
> You could try removing _x_cc[2] and changing [NCCS] to [NCCS+2] which
> might work depending upon the alignment you get.
We can't do that kind of change for the "struct termios" case as
changing the array size would change the size of the structure in
userspace. Here, the _x_cc[] thing is only present when __KERNEL__.
I've looked at this issue before, and so far my conclusion is that
ignoring the warnings and teaching other people to do so as well is so
much easier than trying to make this palatable to the compiler and
checking tools.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-09-03 0:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-01 13:27 tty compile warnings Robert Reif
2008-09-01 13:57 ` Alan Cox
2008-09-01 15:58 ` Robert Reif
2008-09-03 0:21 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.