Skip to contentSkip to conversation

Patch for strncmp use in s390 in 2.5

PATCH Pete Zaitcev 3 participants 5 messages May 28, 2003 1 message not in the archive s390

lore
Share & tools
lore
#0 lore raw

Martin & others:

I didn't see this posted before. Sorry if I missed it. It's a harmless buglet which causes false positives with correctness checking tools, and so annoys me.

Cheers,
-- Pete

arch/s390/kernel/setup.c +3 -3
@@ -165,15 +165,15 @@
 static int __init conmode_setup(char *str)
 {
 #if defined(CONFIG_SCLP_CONSOLE)
-	if (strncmp(str, "hwc", 4) == 0 || strncmp(str, "sclp", 5) == 0)
+	if (strncmp(str, "hwc", 3) == 0 || strncmp(str, "sclp", 4) == 0)
                 SET_CONSOLE_SCLP;
 #endif
 #if defined(CONFIG_TN3215_CONSOLE)
-	if (strncmp(str, "3215", 5) == 0)
+	if (strncmp(str, "3215", 4) == 0)
 		SET_CONSOLE_3215;
 #endif
 #if defined(CONFIG_TN3270_CONSOLE)
-	if (strncmp(str, "3270", 5) == 0)
+	if (strncmp(str, "3270", 4) == 0)
 		SET_CONSOLE_3270;
 #endif
         return 1;
#1 lore raw
Quoted 8 lines · Pete Zaitcev

Martin & others:

I didn't see this posted before. Sorry if I missed it. It's a harmless buglet which causes false positives with correctness checking tools, and so annoys me.

Cheers,
-- Pete

Maybe it should be changed to memcmp() with the null-byte included in the length since the compare length is already defined in the code. This should reduce the overhead at the same time it gets rid of the false positive.

[SNIPPED...]

Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips). Why is the government concerned about the lunatic fringe? Think about it.

#2 lore raw

Patch for strncmp use in s390 (sclp)

In reply to Pete Zaitcev

This one is different from the one in setup.c, being an actual bug.

-- Pete

drivers/s390/char/sclp_tty.c +1 -1
@@ -500,7 +500,7 @@
 		memcpy(sclp_tty->flip.char_buf_ptr, buf, count);
 		if (count < 2 ||
 		    (strncmp ((const char *) buf + count - 2, "^n", 2) &&
-		     strncmp ((const char *) buf + count - 2, "\0252n", 2))) {
+		     strncmp ((const char *) buf + count - 2, "\252n", 2))) {
 			sclp_tty->flip.char_buf_ptr[count] = '\n';
 			count++;
 		} else
#3 lore raw
In reply to Pete Zaitcev
Quoted 3 lines · Pete Zaitcev

I didn't see this posted before. Sorry if I missed it. It's a harmless buglet which causes false positives with correctness checking tools, and so annoys me.

Are you sure it's harmless? Your patch changes the meaning from an exact match to a prefix match. I think it's intended to be an exact match, but I don't know why it doesn't just use strcmp().

Richard Braakman

#5 lore raw
In reply to a message not in the archive
Quoted 7 lines
Quoted 3 lines

I didn't see this posted before. Sorry if I missed it. It's a harmless buglet which causes false positives with correctness checking tools, and so annoys me.

Are you sure it's harmless? Your patch changes the meaning from an exact match to a prefix match. I think it's intended to be an exact match, but I don't know why it doesn't just use strcmp().

The buglet is harmless. Now, the fix perhaps not. I think it may be better to replace it with strcmp, too.

-- Pete