Tuesday 21 September 2010 15:48:33 Ralph Corderoy napisaĆ(a):
Hi Janusz,
"0x%0x\n", __func__, it_status);
"0x%0x\n", __func__, it_status);
dev_warn(dev, "%s: format %#x not found\n", __func__,
dev_warn(icd->dev.parent, "Format %#x not found\n",
Two bytes could be saved with consistent use of %#x. :-)
...
In the first two cases, I intended to keep the "0x" prepended even if 0. Am I missing something?
No, I didn't realise that was the intent. I agree, if you want zero to come out as "0x0" then you have to supply your own "0x".
In next iteration, I'll probably use "0x%.8x" when printing 32-bit register values. What do you think?
I'm probably more used to seeing "0x%08x", which is what I used to use myself, but either gives the same result. I stopped using it because I found that the shape of the word is as relevant with hex as it is with English.
0 0x80 0x800080 0x00000000 0x00000080 0x00800080
With the first line I can instantly see it's
Zero. 128 with the top-three bytes all zero. Three bytes with the top byte zero.
With the second line I have to scan the 0 digits carefully, looking for non-zeroes.
Fair enough, I'll convert them to "%#x".
Thanks, Janusz