lkml.org 
[lkml]   [2018]   [Dec]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [for-next][PATCH 23/24] string.h: Add strncmp_prefix() helper macro
On Fri, Dec 21, 2018 at 2:20 PM Joe Perches <joe@perches.com> wrote:
>
> Using
>
> static inline bool str_has_prefix(const char *str, const char prefix[])
> {
> return !strncmp(str, prefix, strlen(prefix));
> }
>
> eliminates the strlen with gcc 4.8 (oldest I still have)

Ok, that looks like the right thing to do.

Side note: in the kernel we disable the whole "unsigned vs signed"
pointer warning entirely, exactly because of the "char *" vs "unsigned
char *" problem.

Linus

\
 
 \ /
  Last update: 2018-12-21 23:30    [W:1.104 / U:0.000 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site