* [PATCH] Misuse of sizeof
@ 2008-12-13 16:31 Giangiacomo Mariotti
2008-12-13 16:43 ` Frédéric Weisbecker
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Giangiacomo Mariotti @ 2008-12-13 16:31 UTC (permalink / raw)
To: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 92 bytes --]
IMO there's a bug in the use of sizeof in /arch/x86/boot/main.c, it's
also a strange style.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-misuse-of-sizeof.patch --]
[-- Type: text/x-patch; name=0001-misuse-of-sizeof.patch, Size: 844 bytes --]
From 473bf306f25b05b1516164cbbf7bd0831133275a Mon Sep 17 00:00:00 2001
From: MisterIO <mrio@debian-hell.inferis.org>
Date: Sat, 13 Dec 2008 17:19:27 +0100
Subject: [PATCH] misuse of sizeof
---
arch/x86/boot/main.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/boot/main.c b/arch/x86/boot/main.c
index 197421d..ecd87cf 100644
--- a/arch/x86/boot/main.c
+++ b/arch/x86/boot/main.c
@@ -34,8 +34,8 @@ static void copy_boot_params(void)
const struct old_cmdline * const oldcmd =
(const struct old_cmdline *)OLD_CL_ADDRESS;
- 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));
if (!boot_params.hdr.cmd_line_ptr &&
oldcmd->cl_magic == OLD_CL_MAGIC) {
--
1.6.0.4
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] Misuse of sizeof
2008-12-13 16:31 [PATCH] Misuse of sizeof Giangiacomo Mariotti
@ 2008-12-13 16:43 ` Frédéric Weisbecker
2008-12-13 17:33 ` Giangiacomo Mariotti
2008-12-13 16:44 ` Miguel Ojeda
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Frédéric Weisbecker @ 2008-12-13 16:43 UTC (permalink / raw)
To: Giangiacomo Mariotti; +Cc: linux-kernel
2008/12/13 Giangiacomo Mariotti <giangiacomo.mariotti@gmail.com>:
> 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.
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] Misuse of sizeof
2008-12-13 16:43 ` Frédéric Weisbecker
@ 2008-12-13 17:33 ` Giangiacomo Mariotti
0 siblings, 0 replies; 6+ messages in thread
From: Giangiacomo Mariotti @ 2008-12-13 17:33 UTC (permalink / raw)
To: Frédéric Weisbecker; +Cc: linux-kernel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 669 bytes --]
On 12/13/08, Frédéric Weisbecker <fweisbec@gmail.com> wrote:> 2008/12/13 Giangiacomo Mariotti <giangiacomo.mariotti@gmail.com>:>> 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Ç+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Misuse of sizeof
2008-12-13 16:31 [PATCH] Misuse of sizeof Giangiacomo Mariotti
2008-12-13 16:43 ` Frédéric Weisbecker
@ 2008-12-13 16:44 ` Miguel Ojeda
2008-12-13 16:48 ` Gregory Petrosyan
2008-12-13 16:59 ` Roland Dreier
3 siblings, 0 replies; 6+ messages in thread
From: Miguel Ojeda @ 2008-12-13 16:44 UTC (permalink / raw)
To: Giangiacomo Mariotti; +Cc: linux-kernel
On Sat, Dec 13, 2008 at 5:31 PM, Giangiacomo Mariotti
<giangiacomo.mariotti@gmail.com> 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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Misuse of sizeof
2008-12-13 16:31 [PATCH] Misuse of sizeof Giangiacomo Mariotti
2008-12-13 16:43 ` Frédéric Weisbecker
2008-12-13 16:44 ` Miguel Ojeda
@ 2008-12-13 16:48 ` Gregory Petrosyan
2008-12-13 16:59 ` Roland Dreier
3 siblings, 0 replies; 6+ messages in thread
From: Gregory Petrosyan @ 2008-12-13 16:48 UTC (permalink / raw)
To: Giangiacomo Mariotti; +Cc: linux-kernel
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Misuse of sizeof
2008-12-13 16:31 [PATCH] Misuse of sizeof Giangiacomo Mariotti
` (2 preceding siblings ...)
2008-12-13 16:48 ` Gregory Petrosyan
@ 2008-12-13 16:59 ` Roland Dreier
3 siblings, 0 replies; 6+ messages in thread
From: Roland Dreier @ 2008-12-13 16:59 UTC (permalink / raw)
To: Giangiacomo Mariotti; +Cc: linux-kernel
> 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.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-12-13 17:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-13 16:31 [PATCH] Misuse of sizeof Giangiacomo Mariotti
2008-12-13 16:43 ` Frédéric Weisbecker
2008-12-13 17:33 ` Giangiacomo Mariotti
2008-12-13 16:44 ` Miguel Ojeda
2008-12-13 16:48 ` Gregory Petrosyan
2008-12-13 16:59 ` Roland Dreier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox