xen/serial: Fix incorrect length of strncmp for dtuart
PATCH 1/1 xen/serial: Fix incorrect length of strncmp for dtuart
In serial_parse_handler(), length of strncmp for dtuart should have been 6, not 5.
--- xen/drivers/char/serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/char/serial.c +1 -1
@@ -310,7 +310,7 @@ int __init serial_parse_handle(char *conf) goto common; } -if ( !strncmp (conf,"dtuart" ,5 ) ) +if ( !strncmp (conf,"dtuart" ,6 ) ) { handle =SERHND_DTUART ; goto common;
Signature · 9 lines
Jiandi An Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 06.06.16 at 23:29, <[email protected]> wrote:
In
serial_parse_handler(), length of strncmp for dtuart should have been 6, not 5.Signed-off-by Jiandi An <[email protected]>
Wei - trivial enough for inclusion in 4.7, I would think?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 10 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 06.06.16 at 23:29, <[email protected]> wrote:
In
serial_parse_handler(), length of strncmp for dtuart should have been 6, not 5.Signed-off-by Jiandi An <[email protected]>Reviewed-by Jan Beulich <[email protected]>Wei - trivial enough for inclusion in 4.7, I would think?
Quoted 2 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 4 lines · Jiandi An
In
serial_parse_handler(), length of strncmp for dtuart should have been 6, not 5.Signed-off-by Jiandi An <[email protected]>
Quoted 21 lines
xen/drivers/char/serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/drivers/char/serial.c +1
-1@@ -310,7 +310,7 @@ int __init serial_parse_handle(char *conf) goto common; } -if ( !strncmp (conf,"dtuart" ,5 ) ) +if ( !strncmp (conf,"dtuart" ,6 ) ) { handle =SERHND_DTUART ; goto common;Signature · 3 lines
Jiandi An Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Hello,
Am 06.06.2016 um 23:29 schrieb Jiandi An:
Quoted 13 lines
In
serial_parse_handler(), length of strncmp for dtuart should have been 6, not 5.Signed-off-by Jiandi An <[email protected]>--- xen/drivers/char/serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/drivers/char/serial.c +0
-0
xen/drivers/char/serial.c int __init serial_parse_handle(char *conf) · line 313
Quoted 5 lines
xen/drivers/char/serial.c +1
-1@@ -310,7 +310,7 @@ int __init serial_parse_handle(char *conf) goto common; } -if ( !strncmp (conf,"dtuart" ,5 ) ) +if ( !strncmp (conf,"dtuart" ,6 ) )
Do you really want to check for a prefix, that it that conf starts with "dtuart"?
If you want to check for an exact string match, you need to include the trailing \0!
In that case just use "strcmp()" as there is (AFAIK) not reason to use the n-variant as one of your string is a constant already and thus the comparison will terminate when the \0 of that const-string is reached.
Philipp
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
static const char *confs[] = {
"dtuar",
"dtuart",
"dtuartx",
NULL
};int main(void) {
int i;
for (i = 0; confs[i]; i++) {
const char *conf = confs[i];
printf("%s\t%d\t%d\n", conf, strncmp(conf, "dtuart", 5), strncmp(conf, "dtuart", 6));
}
return 0;
}_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel