linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 02/12] kdb: Replace strncmp with str_has_prefix
@ 2019-07-29 15:13 Chuhong Yuan
  2019-07-30 10:05 ` Daniel Thompson
  0 siblings, 1 reply; 2+ messages in thread
From: Chuhong Yuan @ 2019-07-29 15:13 UTC (permalink / raw)
  Cc: Jason Wessel, Daniel Thompson, kgdb-bugreport, linux-kernel,
	Chuhong Yuan

strncmp(str, const, len) is error-prone.
We had better use newly introduced
str_has_prefix() instead of it.

Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
---
 kernel/debug/kdb/kdb_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index 9ecfa37c7fbf..4567fe998c30 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -830,7 +830,7 @@ static void parse_grep(const char *str)
 	cp++;
 	while (isspace(*cp))
 		cp++;
-	if (strncmp(cp, "grep ", 5)) {
+	if (!str_has_prefix(cp, "grep ")) {
 		kdb_printf("invalid 'pipe', see grephelp\n");
 		return;
 	}
-- 
2.20.1


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

* Re: [PATCH 02/12] kdb: Replace strncmp with str_has_prefix
  2019-07-29 15:13 [PATCH 02/12] kdb: Replace strncmp with str_has_prefix Chuhong Yuan
@ 2019-07-30 10:05 ` Daniel Thompson
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Thompson @ 2019-07-30 10:05 UTC (permalink / raw)
  To: Chuhong Yuan; +Cc: Jason Wessel, kgdb-bugreport, linux-kernel

On Mon, Jul 29, 2019 at 11:13:59PM +0800, Chuhong Yuan wrote:
> strncmp(str, const, len) is error-prone.
> We had better use newly introduced
> str_has_prefix() instead of it.
> 
> Signed-off-by: Chuhong Yuan <hslester96@gmail.com>

Acked-by: Daniel Thompson <daniel.thompson@linaro.org>


> ---
>  kernel/debug/kdb/kdb_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
> index 9ecfa37c7fbf..4567fe998c30 100644
> --- a/kernel/debug/kdb/kdb_main.c
> +++ b/kernel/debug/kdb/kdb_main.c
> @@ -830,7 +830,7 @@ static void parse_grep(const char *str)
>  	cp++;
>  	while (isspace(*cp))
>  		cp++;
> -	if (strncmp(cp, "grep ", 5)) {
> +	if (!str_has_prefix(cp, "grep ")) {
>  		kdb_printf("invalid 'pipe', see grephelp\n");
>  		return;
>  	}
> -- 
> 2.20.1
> 

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

end of thread, other threads:[~2019-07-30 10:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-29 15:13 [PATCH 02/12] kdb: Replace strncmp with str_has_prefix Chuhong Yuan
2019-07-30 10:05 ` Daniel Thompson

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).