Skip to contentSkip to conversation

drivers/char/synclink_gt.c: chars don't have more than 8 bits

PATCH New Adrian Bunk 2 participants 3 messages Aug 26, 2006 – Aug 28, 2006 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

The GNU C compiler (SVN version) spotted the following buggy code in drivers/char/synclink_gt.c:

<-- snip -->

...
static void rx_async(struct slgt_info *info)
{
...

        unsigned char *p;
        unsigned char status;
...
                        if ((status = *(p+1) & (BIT9 + BIT8))) {
                                if (status & BIT9)
                                        icount->parity++;
                                else if (status & BIT8)
                                        icount->frame++;
                                /* discard char if tty control flags say so */
                                if (status & info->ignore_status_mask)
                                        continue;
                                if (status & BIT9)
                                        stat = TTY_PARITY;
                                else if (status & BIT8)
                                        stat = TTY_FRAME;
                        }

...

<-- snip -->

Since there are no bits 8 or 9 in a char this code is currently dead code.

cu
Adrian

Signature · 6 lines
    Gentoo kernels are 42 times more popular than SUSE kernels among
    KLive users  (a service by SUSE contractor Andrea Arcangeli that
    gathers data about kernels from many users worldwide).

       There are three kinds of lies: Lies, Damn Lies, and Statistics.
                                                    Benjamin Disraeli
#1 lore raw
Quoted 4 lines · Adrian Bunk

The GNU C compiler (SVN version) spotted the following buggy code in drivers/char/synclink_gt.c:
...
Since there are no bits 8 or 9 in a char this code is currently
dead code.

Yes, that is a bug.

Status and data come in byte pairs, bits 9 and 8 are referenced from the 16 bit combination.

The code is operating on individual bytes in the buffer, so it should be bits 1 and 0 that are tested.

I will make a patch and post it.

Thanks,
Paul

#2 lore raw

PATCH 1/1 synclink_gt fix receive tty error handling

In reply to Adrian Bunk

Fix receive tty error handling in synclink_gt driver. Adrian reported compiler warning for incorrect bit test against char variable. I determined these and other device specific error bits were incorrectly defined.

drivers/char/synclink_gt.c +7 -7
@@ -391,8 +391,8 @@ static MGSL_PARAMS default_params = {
 #define DESC_LIST_SIZE 4096
 
 #define MASK_PARITY  BIT1
-#define MASK_FRAMING BIT2
-#define MASK_BREAK   BIT3
+#define MASK_FRAMING BIT0
+#define MASK_BREAK   BIT14
 #define MASK_OVERRUN BIT4
 
 #define GSR   0x00 /* global status */
@@ -1800,17 +1800,17 @@ static void rx_async(struct slgt_info *i
 
 			stat = 0;
 
-			if ((status = *(p+1) & (BIT9 + BIT8))) {
-				if (status & BIT9)
+			if ((status = *(p+1) & (BIT1 + BIT0))) {
+				if (status & BIT1)
 					icount->parity++;
-				else if (status & BIT8)
+				else if (status & BIT0)
 					icount->frame++;
 				/* discard char if tty control flags say so */
 				if (status & info->ignore_status_mask)
 					continue;
-				if (status & BIT9)
+				if (status & BIT1)
 					stat = TTY_PARITY;
-				else if (status & BIT8)
+				else if (status & BIT0)
 					stat = TTY_FRAME;
 			}
 			if (tty) {