strncmp errors?
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 10 lines · Joe Perches
Quoted 9 lines · Heiko Carstens
Quoted 8 lines · Joe Perches
Typically, strncmp uses the length of the second
argument as the maximum comparison length.
Perhaps these strncmp uses should be modified?arch/s390/kernel/vdso.c: if (strncmp(s, "on", 3)== 0)arch/s390/kernel/vdso.c: else if (strncmp(s, "off", 4)== 0)arch/s390/kernel/setup.c: if (strncmp(str, "hwc", 4)== 0 ||strncmp(str, "sclp", 5)== 0)arch/s390/kernel/setup.c: if (strncmp(str, "3215", 5)== 0)arch/s390/kernel/setup.c: if (strncmp(str, "3270", 5)== 0)
Quoted 8 lines
Quoted 1 line
Why do you think we have errors in here?
Other uses of strncmp in the same file.
$ grep strncmp arch/s390/kernel/setup.c if (strncmp(str, "hwc", 4) == 0 || strncmp(str, "sclp", 5) == 0) if (strncmp(str, "3215", 5) == 0) if (strncmp(str, "3270", 5) == 0)
These are all NULL terminated.
Quoted 2 lines
if (strncmp(ptr + 8, "3270", 4) == 0) {
} else if (strncmp(ptr + 8, "3215", 4) == 0) {These are not.
Quoted 1 line
if (!strncmp(p, "off", 3))
This one is NULL terminated.
Quoted 5 lines
Quoted 2 lines
The only thing I can see is that the length parameter is superfluous and that we could have used strcmp instead.
If that's what's appropriate, isn't
that what should actually be used?
So everything is correct. Can't see a reason to change anything here, except for cleanup reasons. But it's not worth the test effort to verify if not something breaks in a subtle manner.