xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xen/serial: Fix incorrect length of strncmp for dtuart
@ 2016-06-06 21:29 Jiandi An
  2016-06-07  7:29 ` Jan Beulich
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jiandi An @ 2016-06-06 21:29 UTC (permalink / raw)
  To: xen-devel
  Cc: sstabellini, wei.liu2, George.Dunlap, andrew.cooper3, anjiandi,
	ian.jackson, tim, jbeulich, shankerd

In serial_parse_handler(), length of strncmp for dtuart should have been
6, not 5.

Signed-off-by: Jiandi An <anjiandi@codeaurora.org>
---
 xen/drivers/char/serial.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/drivers/char/serial.c b/xen/drivers/char/serial.c
index c583a48..0fc5ced 100644
--- a/xen/drivers/char/serial.c
+++ b/xen/drivers/char/serial.c
@@ -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;
-- 
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
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] xen/serial: Fix incorrect length of strncmp for dtuart
  2016-06-06 21:29 [PATCH] xen/serial: Fix incorrect length of strncmp for dtuart Jiandi An
@ 2016-06-07  7:29 ` Jan Beulich
  2016-06-07  7:58   ` Wei Liu
  2016-06-07 10:11 ` Stefano Stabellini
  2016-06-08  5:30 ` Philipp Hahn
  2 siblings, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2016-06-07  7:29 UTC (permalink / raw)
  To: wei.liu2, Jiandi An
  Cc: tim, sstabellini, George.Dunlap, andrew.cooper3, ian.jackson,
	xen-devel, shankerd

>>> On 06.06.16 at 23:29, <anjiandi@codeaurora.org> wrote:
> In serial_parse_handler(), length of strncmp for dtuart should have been
> 6, not 5.
> 
> Signed-off-by: Jiandi An <anjiandi@codeaurora.org>

Reviewed-by: Jan Beulich <jbeulich@suse.com>

Wei - trivial enough for inclusion in 4.7, I would think?

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] xen/serial: Fix incorrect length of strncmp for dtuart
  2016-06-07  7:29 ` Jan Beulich
@ 2016-06-07  7:58   ` Wei Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Wei Liu @ 2016-06-07  7:58 UTC (permalink / raw)
  To: Jan Beulich
  Cc: tim, sstabellini, wei.liu2, George.Dunlap, andrew.cooper3,
	Jiandi An, ian.jackson, xen-devel, shankerd

On Tue, Jun 07, 2016 at 01:29:34AM -0600, Jan Beulich wrote:
> >>> On 06.06.16 at 23:29, <anjiandi@codeaurora.org> wrote:
> > In serial_parse_handler(), length of strncmp for dtuart should have been
> > 6, not 5.
> > 
> > Signed-off-by: Jiandi An <anjiandi@codeaurora.org>
> 
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> 
> Wei - trivial enough for inclusion in 4.7, I would think?
> 

Release-acked-by: Wei Liu <wei.liu2@citrix.com>

> Jan
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] xen/serial: Fix incorrect length of strncmp for dtuart
  2016-06-06 21:29 [PATCH] xen/serial: Fix incorrect length of strncmp for dtuart Jiandi An
  2016-06-07  7:29 ` Jan Beulich
@ 2016-06-07 10:11 ` Stefano Stabellini
  2016-06-08  5:30 ` Philipp Hahn
  2 siblings, 0 replies; 5+ messages in thread
From: Stefano Stabellini @ 2016-06-07 10:11 UTC (permalink / raw)
  To: Jiandi An
  Cc: tim, sstabellini, wei.liu2, George.Dunlap, andrew.cooper3,
	ian.jackson, xen-devel, jbeulich, shankerd

On Mon, 6 Jun 2016, Jiandi An wrote:
> In serial_parse_handler(), length of strncmp for dtuart should have been
> 6, not 5.
> 
> Signed-off-by: Jiandi An <anjiandi@codeaurora.org>

Acked-by: Stefano Stabellini <sstabellini@kernel.org>


>  xen/drivers/char/serial.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/xen/drivers/char/serial.c b/xen/drivers/char/serial.c
> index c583a48..0fc5ced 100644
> --- a/xen/drivers/char/serial.c
> +++ b/xen/drivers/char/serial.c
> @@ -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;
> -- 
> 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
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] xen/serial: Fix incorrect length of strncmp for dtuart
  2016-06-06 21:29 [PATCH] xen/serial: Fix incorrect length of strncmp for dtuart Jiandi An
  2016-06-07  7:29 ` Jan Beulich
  2016-06-07 10:11 ` Stefano Stabellini
@ 2016-06-08  5:30 ` Philipp Hahn
  2 siblings, 0 replies; 5+ messages in thread
From: Philipp Hahn @ 2016-06-08  5:30 UTC (permalink / raw)
  To: xen-devel, anjiandi

[-- Attachment #1: Type: text/plain, Size: 1034 bytes --]

Hello,

Am 06.06.2016 um 23:29 schrieb Jiandi An:
> In serial_parse_handler(), length of strncmp for dtuart should have been
> 6, not 5.
> 
> Signed-off-by: Jiandi An <anjiandi@codeaurora.org>
> ---
>  xen/drivers/char/serial.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/xen/drivers/char/serial.c b/xen/drivers/char/serial.c
> index c583a48..0fc5ced 100644
> --- a/xen/drivers/char/serial.c
> +++ b/xen/drivers/char/serial.c
> @@ -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


[-- Attachment #2: check-strncmp.c --]
[-- Type: text/x-csrc, Size: 325 bytes --]

#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;
}

[-- Attachment #3: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-06-08  5:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-06 21:29 [PATCH] xen/serial: Fix incorrect length of strncmp for dtuart Jiandi An
2016-06-07  7:29 ` Jan Beulich
2016-06-07  7:58   ` Wei Liu
2016-06-07 10:11 ` Stefano Stabellini
2016-06-08  5:30 ` Philipp Hahn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).