[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] typo in keyboard.c



On Sun, 2010-05-23 at 11:21 +0100, Alan Hourihane wrote:
> On Sun, 2010-05-23 at 09:22 +0200, Helmut Karlowski wrote:
> > There's a typo in line 160 in keyboard.c:
> > 
> > static char makes[MAKES_BLEN + 1 * 2];
> > 
> > should be:
> > 
> > static char makes[MAKES_BLEN * 2 + 1];
> > 
> > or even:
> > 
> > static char makes[MAKES_BLEN * 2 - 1];
> > 
> > This may cause severe problems. I recommend not to use kernels with this  
> > error.
> > 
> > There is a good chance that this also causes eiffel-bug.
> > 
> > I've committed the fix to my branch.
> 
> Helmut,
> 
> I've pulled in this fix and I agree it could cause some unwanted
> behaviour, but where is the makes[] structure actually used ?
> 
> It seems to be filled in during ikbd_scan(), but I can't see where
> makes[] is actually used anywhere else to make use of that data ?

Seems to me as though it was a partial bit of code that never gets used.
And in fact removing it cleans up a few ifdefs from the MILAN code.

Attached patch.

Alan.
Index: keyboard.c
===================================================================
RCS file: /mint/freemint/sys/keyboard.c,v
retrieving revision 1.99
diff -u -r1.99 keyboard.c
--- keyboard.c	23 May 2010 10:13:42 -0000	1.99
+++ keyboard.c	23 May 2010 10:44:33 -0000
@@ -153,8 +153,6 @@
 short	kbd_mpixels = 8;	/* mouse pixel steps */
 short	kbd_mpixels_fine = 1;	/* mouse pixel steps in 'fine' mode */
 struct	cad_def cad[3];		/* for halt, warm and cold resp. */
-#define MAKES_BLEN	16
-static char makes[MAKES_BLEN * 2 + 1];
 
 /* Auxiliary variables for ikbd_scan() */
 static	short cad_lock;		/* semaphore to avoid scheduling shutdown() twice */
@@ -1050,11 +1048,7 @@
 			 * ClrHome and Insert must be handled as other keys.
 			 */
 			if ((scan != CLRHOME) && (scan != INSERT))
-#ifndef MILAN
-				goto keepscan;
-#else
 				continue;
-#endif
 		}
 
 		/* Here we handle keys of `system wide' meaning. These are:
@@ -1118,13 +1112,7 @@
 							}
 						}
 					}
-
-#ifndef MILAN
-					goto keepscan;
-#else
 					continue;
-#endif
-// 					goto keepscan;
 				}
 				/* Function keys */
 				case 0x003b ... 0x0044:
@@ -1141,13 +1129,7 @@
 
 						kbdclick(scan);
 					}
-
-#ifndef MILAN
-					goto keepscan;
-#else
 					continue;
-#endif
-// 					goto keepscan;
 				}
 				/* This is in case the keyboard has real F11-F20 keys on it */
 				case 0x0054 ... 0x005d:
@@ -1161,13 +1143,7 @@
 
 						kbdclick(scan);
 					}
-
-#ifndef MILAN
-					goto keepscan;
-#else
 					continue;
-#endif
-// 					goto keepscan;
 				}
 			}
 		}
@@ -1220,13 +1196,7 @@
 						addroottimeout(ROOT_TIMEOUT, (void _cdecl (*)(PROC *))alt_help, 1);
 						kbdclick(scan);
 					}
-
-#ifndef MILAN
-					goto keepscan;
-#else
 					continue;
-#endif
-// 					goto keepscan;
 				}
 				/* Alt/Numpad generates ASCII codes like in TOS 2.0x.
 				 */
@@ -1340,41 +1310,7 @@
 		}
 #ifndef MILAN
 		set_keyrepeat_timeout(make);
-keepscan:
 #endif
-#ifndef MILAN
-		if (make)
-		{
-			int i;
-			for (i = 0; i < MAKES_BLEN * 2; i += 2)
-			{
-				if (!makes[i])
-				{
-					makes[i    ] = 1;
-					makes[i + 1] = scan;
-					break;
-				}
-			}
-		}
-		else
-		{
-			int i;
-			for (i = 0; i < MAKES_BLEN * 2; i += 2)
-			{
-				if (makes[i] && makes[i+1] == scan)
-				{
-					do
-					{
-						makes[i]   = makes[i+2];
-						makes[i+1] = makes[i+3];
-						i += 2;
-					} while (i < MAKES_BLEN);
-				}
-			}
-		}
-#endif
-// again:
-
 	} while (scanb_head != scanb_tail);
 
 	ikbd_to = NULL;
@@ -1872,7 +1808,6 @@
 void
 init_keybd(void)
 {
-	int i;
 	ushort delayrate;
 
 	/* Call the underlying XBIOS to get some defaults.
@@ -1882,10 +1817,6 @@
 	 * key_tables.h
 	 */
 
-	i = 0;
-	while (i < MAKES_BLEN)
-		makes[i++] = 0, makes[i++] = 0;
-
 # ifndef WITHOUT_TOS
 	tos_keytab = TRAP_Keytbl(-1, -1, -1);
 # endif