lkml.org 
[lkml]   [2009]   [Dec]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4/4] tracing/filters: Fix MATCH_EBD_ONLY filter matching
>>  static int regex_match_end(char *str, struct regex *r, int len)
>> {
>> - char *ptr = strstr(str, r->pattern);
>> + int strlen = len - 1;
>>
>> - if (ptr && (ptr[r->len] == 0))
>> + if (strlen >= r->len &&
>> + !memcmp(str + strlen - r->len, r->pattern, r->len))
>
> Please use memcmp() == 0, I've seen too many bugs with !*cmp as well as
> with *cmp, because humans tend to think instinctively when reading this
> that ! is not a match. With "== 0" we think that "==" is a match and
> "!=" is a miss.
>

Though I sometimes don't care much about this, I do
think memcmp() == 0 is better.



\
 
 \ /
  Last update: 2009-12-14 02:11    [W:0.027 / U:0.524 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site