mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Want comments regarding patch
@ 2006-12-28 18:41 Daniel Marjamäki
  2006-12-28 18:53 ` Arjan van de Ven
  2006-12-28 20:07 ` Horst H. von Brand
  0 siblings, 2 replies; 9+ messages in thread
From: Daniel Marjamäki @ 2006-12-28 18:41 UTC (permalink / raw)
  To: linux-kernel

Hello all!

I sent a patch with this content:

-       for (i = 0; i < MAX_PIRQS; i++)
-               pirq_entries[i] = -1;
+       memset(pirq_entries, -1, sizeof(pirq_entries));

I'd like to know if you have any comments to this change. It was of
course my intention to make the code shorter, simpler and faster.

I've discussed this with Ingo Molnar and here's our conversation:

INGO:

hm, i'm not sure i like this - the '-1' in the memset is for a byte,
while the pirq_entries are word sized. It should work because the bytes
happen to be 0xff for the word too, but this is encodes an assumption,
and were we ever to change that value it could break silently. gcc ought
to be able to figure out the best way to initialize the array.


DANIEL:

Thank you for the comments.

I understand your point, it's good. But I personally still like my
method better.
For me -1 is just as valid as an argument as 0. As you note however,
it assumes that the next developer understands the encoding of
negative numbers. A developer who doesn't know the encoding could be
very confused. Would my patch be ok if I used '0xff' instead of '-1'?

With version 3.3.6 (gcc) there's quite a big difference in the
assembly code (between 'for' and 'memset').

INGO:

0xff might be better, but i'm still uneasy about it ... No other piece
of code within the kernel does this.

could you post the patch and the reasoning to
linux-kernel@vger.kernel.org as well? That way others can chime in as
well.

^ permalink raw reply	[flat|nested] 9+ messages in thread
[parent not found: <7x8ul-7NU-7@gated-at.bofh.it>]

end of thread, other threads:[~2006-12-30 11:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-28 18:41 Want comments regarding patch Daniel Marjamäki
2006-12-28 18:53 ` Arjan van de Ven
2006-12-28 23:52   ` Jan Engelhardt
2006-12-29  6:57     ` Daniel Marjamäki
2006-12-29 10:13       ` Jan Engelhardt
2006-12-28 20:07 ` Horst H. von Brand
     [not found] <7x8ul-7NU-7@gated-at.bofh.it>
     [not found] ` <7x8E5-80F-13@gated-at.bofh.it>
     [not found]   ` <7xdkq-7tB-25@gated-at.bofh.it>
     [not found]     ` <7xjSQ-1fR-13@gated-at.bofh.it>
     [not found]       ` <7xn0j-6rY-7@gated-at.bofh.it>
2006-12-30  0:00         ` Bodo Eggert
2006-12-30 11:07           ` Jan Engelhardt
2006-12-30 11:42             ` Arjan van de Ven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®