Thread (1 message) 1 message, 1 author, 2019-09-03

Re: [PATCH 04/11] General notification queue with user mmap()'able ring buffer [ver #7]

From: David Howells <dhowells@redhat.com>
Date: 2019-09-03 16:37:27
Also in: keyrings, linux-api, linux-block, linux-fsdevel, linux-usb, lkml

Hillf Danton [off-list ref] wrote:
quoted
+	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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help