Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1278452

Re: [PATCH] HID: debug: improve hid_debug_event()

From Rasmus Villemoes <linux@rasmusvillemoes.dk>
Newsgroups linux.kernel
Subject Re: [PATCH] HID: debug: improve hid_debug_event()
Date 2015-11-26 22:10 +0100
Message-ID <qzbXI-22g-13@gated-at.bofh.it> (permalink)
References <qyl35-86O-37@gated-at.bofh.it> <qyP19-2J1-31@gated-at.bofh.it>
Organization D03

Show all headers | View raw


On Wed, Nov 25 2015, Joe Perches <joe@perches.com> wrote:

>>  	spin_lock_irqsave(&hdev->debug_list_lock, flags);
>>  	list_for_each_entry(list, &hdev->debug_list, node) {
>> -		for (i = 0; i < strlen(buf); i++)
>> +		for (i = 0; buf[i]; i++)
>>  			list->hid_debug_buf[(list->tail + i) % HID_DEBUG_BUFSIZE] =
>>  				buf[i];
>>  		list->tail = (list->tail + i) % HID_DEBUG_BUFSIZE;
>
> trivia:
>
> The code might look nicer if (list->tail + i) % HID_DEBUG_BUFSIZE
> was stored into a temporary.

Maybe.

> Maybe use an if >= BUFSIZE to avoid a %

Nah, that would likely be worse; both a cmov and a conditional jump are
probably more expensive than a simple '& 0x1ff' which the % should compile to
(provided the expression is unsigned).

Rasmus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] HID: debug: improve hid_debug_event() Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-11-24 13:40 +0100
  Re: [PATCH] HID: debug: improve hid_debug_event() Joe Perches <joe@perches.com> - 2015-11-25 21:40 +0100
    Re: [PATCH] HID: debug: improve hid_debug_event() Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-11-26 22:10 +0100
  Re: [PATCH] HID: debug: improve hid_debug_event() Jiri Kosina <jikos@kernel.org> - 2015-11-27 00:10 +0100

csiph-web