mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org,
	Andy Shevchenko <andy@kernel.org>
Subject: Re: [PATCH v1 1/1] string: Group str_has_prefix() and strstarts()
Date: Mon, 14 Jul 2025 22:24:58 -0700	[thread overview]
Message-ID: <202507142224.28276C2D8@keescook> (raw)
In-Reply-To: <20250711085514.1294428-1-andriy.shevchenko@linux.intel.com>

On Fri, Jul 11, 2025 at 11:55:14AM +0300, Andy Shevchenko wrote:
> The two str_has_prefix() and strstarts() are about the same
> with a slight difference on what they return. Group them in
> the header.

It seems more like strstarts should just be a macro around
str_has_prefix() != 0?

-Kees

> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  include/linux/string.h | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/include/linux/string.h b/include/linux/string.h
> index 01621ad0f598..fdd3442c6bcb 100644
> --- a/include/linux/string.h
> +++ b/include/linux/string.h
> @@ -345,16 +345,6 @@ extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos,
>  
>  int ptr_to_hashval(const void *ptr, unsigned long *hashval_out);
>  
> -/**
> - * strstarts - does @str start with @prefix?
> - * @str: string to examine
> - * @prefix: prefix to look for.
> - */
> -static inline bool strstarts(const char *str, const char *prefix)
> -{
> -	return strncmp(str, prefix, strlen(prefix)) == 0;
> -}
> -
>  size_t memweight(const void *ptr, size_t bytes);
>  
>  /**
> @@ -562,4 +552,14 @@ static __always_inline size_t str_has_prefix(const char *str, const char *prefix
>  	return strncmp(str, prefix, len) == 0 ? len : 0;
>  }
>  
> +/**
> + * strstarts - does @str start with @prefix?
> + * @str: string to examine
> + * @prefix: prefix to look for.
> + */
> +static inline bool strstarts(const char *str, const char *prefix)
> +{
> +	return strncmp(str, prefix, strlen(prefix)) == 0;
> +}
> +
>  #endif /* _LINUX_STRING_H_ */
> -- 
> 2.47.2
> 

-- 
Kees Cook

  reply	other threads:[~2025-07-15  5:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-11  8:55 Andy Shevchenko
2025-07-15  5:24 ` Kees Cook [this message]
2025-07-15  6:52   ` Andy Shevchenko
2025-07-15  6:53     ` Andy Shevchenko
2025-07-17 23:40 ` Kees Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202507142224.28276C2D8@keescook \
    --to=kees@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=andy@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®