2008-12-13 16:31:19

by Giangiacomo Mariotti

[permalink] [raw]
Subject: [PATCH] Misuse of sizeof

IMO there's a bug in the use of sizeof in /arch/x86/boot/main.c, it's
also a strange style.


Attachments:
(No filename) (92.00 B)
0001-misuse-of-sizeof.patch (844.00 B)
Download all attachments

2008-12-13 16:43:52

by Frederic Weisbecker

[permalink] [raw]
Subject: Re: [PATCH] Misuse of sizeof

2008/12/13 Giangiacomo Mariotti <[email protected]>:
> IMO there's a bug in the use of sizeof in /arch/x86/boot/main.c, it's
> also a strange style.
>

Hi,

No this is not a bug, sizeof is a unary operator which can be used
with or without parenthesis :-)

Note: don't forget to put your Signed-off-by and some explanations
along your patches.
Also, not all maintainers accept patches as attachment.

2008-12-13 16:45:18

by Miguel Ojeda

[permalink] [raw]
Subject: Re: [PATCH] Misuse of sizeof

On Sat, Dec 13, 2008 at 5:31 PM, Giangiacomo Mariotti
<[email protected]> wrote:
> IMO there's a bug in the use of sizeof in /arch/x86/boot/main.c, it's
> also a strange style.
>

It is not a bug. You don't need to use parenthesis when used on
variables. See 6.5.3.4.

2008-12-13 16:56:30

by Gregory Petrosyan

[permalink] [raw]
Subject: Re: [PATCH] Misuse of sizeof

On Sat, Dec 13, 2008 at 05:31:06PM +0100, Giangiacomo Mariotti wrote:
> IMO there's a bug in the use of sizeof in /arch/x86/boot/main.c, it's
> also a strange style.

> - BUILD_BUG_ON(sizeof boot_params != 4096);
> - memcpy(&boot_params.hdr, &hdr, sizeof hdr);
> + BUILD_BUG_ON(sizeof(boot_params) != 4096);
> + memcpy(&boot_params.hdr, &hdr, sizeof(hdr));

The 'sizeof xxx' style is perfectly valid.

Gregory

2008-12-13 16:59:21

by Roland Dreier

[permalink] [raw]
Subject: Re: [PATCH] Misuse of sizeof

> IMO there's a bug in the use of sizeof in /arch/x86/boot/main.c, it's
> also a strange style.

Style is of course a matter of opinion, but sizeof is an operator, not a
function, and as far as I can see, there's no bug in how it is used even
without your patch.

- R.

2008-12-13 17:33:37

by Giangiacomo Mariotti

[permalink] [raw]
Subject: Re: [PATCH] Misuse of sizeof

On 12/13/08, Frédéric Weisbecker <[email protected]> wrote:> 2008/12/13 Giangiacomo Mariotti <[email protected]>:>> IMO there's a bug in the use of sizeof in /arch/x86/boot/main.c, it's>> also a strange style.>>>> Hi,>> No this is not a bug, sizeof is a unary operator which can be used> with or without parenthesis :-)>> Note: don't forget to put your Signed-off-by and some explanations> along your patches.> Also, not all maintainers accept patches as attachment.>You're right, I was wrong.????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?