lkml.org 
[lkml]   [2019]   [Sep]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 04/11] General notification queue with user mmap()'able ring buffer [ver #7]
Date
Hillf Danton <hdanton@sina.com> wrote:

> > + for (i = 0; i < wf->nr_filters; i++) {
> > + wt = &wf->filters[i];
> > + if (n->type == wt->type &&
> > + (wt->subtype_filter[n->subtype >> 5] &
> > + (1U << (n->subtype & 31))) &&
>
> Replace the pure numbers with something easier to understand.

How about the following:

static bool filter_watch_notification(const struct watch_filter *wf,
const struct watch_notification *n)
{
const struct watch_type_filter *wt;
unsigned int st_bits = sizeof(wt->subtype_filter[0]) * 8;
unsigned int st_index = n->subtype / st_bits;
unsigned int st_bit = 1U << (n->subtype % st_bits);
int i;

if (!test_bit(n->type, wf->type_filter))
return false;

for (i = 0; i < wf->nr_filters; i++) {
wt = &wf->filters[i];
if (n->type == wt->type &&
(wt->subtype_filter[st_index] & st_bit) &&
(n->info & wt->info_mask) == wt->info_filter)
return true;
}

return false; /* If there is a filter, the default is to reject. */
}

David

\
 
 \ /
  Last update: 2019-09-03 18:37    [W:0.275 / U:8.632 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site