* [PATCH] arch/x86/boot: sizeof macro
@ 2017-12-29 18:30 Saidgani Musaev
2017-12-29 18:41 ` Andy Shevchenko
0 siblings, 1 reply; 8+ messages in thread
From: Saidgani Musaev @ 2017-12-29 18:30 UTC (permalink / raw)
To: hpa; +Cc: tglx, x86, linux-kernel, Saidgani Musaev
---
arch/x86/boot/memory.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
index d9c28c8..7df2b28 100644
--- a/arch/x86/boot/memory.c
+++ b/arch/x86/boot/memory.c
@@ -26,7 +26,7 @@ static int detect_memory_e820(void)
initregs(&ireg);
ireg.ax = 0xe820;
- ireg.cx = sizeof buf;
+ ireg.cx = sizeof(buf);
ireg.edx = SMAP;
ireg.di = (size_t)&buf;
--
2.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] arch/x86/boot: sizeof macro
2017-12-29 18:30 [PATCH] arch/x86/boot: sizeof macro Saidgani Musaev
@ 2017-12-29 18:41 ` Andy Shevchenko
2017-12-29 19:34 ` hacku
2017-12-29 19:46 ` Ingo Molnar
0 siblings, 2 replies; 8+ messages in thread
From: Andy Shevchenko @ 2017-12-29 18:41 UTC (permalink / raw)
To: Saidgani Musaev
Cc: H. Peter Anvin, Thomas Gleixner, x86, Linux Kernel Mailing List
On Fri, Dec 29, 2017 at 8:30 PM, Saidgani Musaev <cpu808694@gmail.com> wrote:
No changelog, no explanation why...
No SoB tag...
> - ireg.cx = sizeof buf;
> + ireg.cx = sizeof(buf);
sizeof is operator, not a function.
So, what are you trying to achieve?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] arch/x86/boot: sizeof macro
2017-12-29 18:41 ` Andy Shevchenko
@ 2017-12-29 19:34 ` hacku
2017-12-29 19:46 ` Ingo Molnar
1 sibling, 0 replies; 8+ messages in thread
From: hacku @ 2017-12-29 19:34 UTC (permalink / raw)
To: Andy Shevchenko
Cc: H. Peter Anvin, Thomas Gleixner, x86, Linux Kernel Mailing List
Coding style for sizeof . If you check this file with checkpatch.pl you
will see warning on this line. Yes, sorry I didn't mark this change as a
coding style issue.
best regards,
Saidgani.
On 12/29/2017 07:41 PM, Andy Shevchenko wrote:
> On Fri, Dec 29, 2017 at 8:30 PM, Saidgani Musaev <cpu808694@gmail.com> wrote:
>
> No changelog, no explanation why...
> No SoB tag...
>
>> - ireg.cx = sizeof buf;
>> + ireg.cx = sizeof(buf);
> sizeof is operator, not a function.
> So, what are you trying to achieve?
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] arch/x86/boot: sizeof macro
2017-12-29 18:41 ` Andy Shevchenko
2017-12-29 19:34 ` hacku
@ 2017-12-29 19:46 ` Ingo Molnar
2017-12-31 11:48 ` Andy Shevchenko
1 sibling, 1 reply; 8+ messages in thread
From: Ingo Molnar @ 2017-12-29 19:46 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Saidgani Musaev, H. Peter Anvin, Thomas Gleixner, x86,
Linux Kernel Mailing List
* Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> On Fri, Dec 29, 2017 at 8:30 PM, Saidgani Musaev <cpu808694@gmail.com> wrote:
>
> No changelog, no explanation why...
> No SoB tag...
>
> > - ireg.cx = sizeof buf;
> > + ireg.cx = sizeof(buf);
>
> sizeof is operator, not a function.
> So, what are you trying to achieve?
That's true, but in the kernel coding style we use it as a function:
triton:~/tip> git grep 'sizeof(' | wc -l
116570
triton:~/tip> git grep 'sizeof [:alnum:]' | wc -l
177
Thanks,
Ingo
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] arch/x86/boot: sizeof macro
2017-12-29 19:46 ` Ingo Molnar
@ 2017-12-31 11:48 ` Andy Shevchenko
2017-12-31 16:33 ` Joe Perches
2018-01-06 11:50 ` Ingo Molnar
0 siblings, 2 replies; 8+ messages in thread
From: Andy Shevchenko @ 2017-12-31 11:48 UTC (permalink / raw)
To: Ingo Molnar
Cc: Saidgani Musaev, H. Peter Anvin, Thomas Gleixner, x86,
Linux Kernel Mailing List
On Fri, Dec 29, 2017 at 9:46 PM, Ingo Molnar <mingo@kernel.org> wrote:
> * Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
>> > - ireg.cx = sizeof buf;
>> > + ireg.cx = sizeof(buf);
>>
>> sizeof is operator, not a function.
>> So, what are you trying to achieve?
>
> That's true, but in the kernel coding style we use it as a function:
Yeah, the question is do we need to change all those 177 occurrences at all?
Or perhaps it might be an opportunity during some other changes to
certain users...
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] arch/x86/boot: sizeof macro
2017-12-31 11:48 ` Andy Shevchenko
@ 2017-12-31 16:33 ` Joe Perches
2018-01-06 11:50 ` Ingo Molnar
1 sibling, 0 replies; 8+ messages in thread
From: Joe Perches @ 2017-12-31 16:33 UTC (permalink / raw)
To: Andy Shevchenko, Ingo Molnar
Cc: Saidgani Musaev, H. Peter Anvin, Thomas Gleixner, x86,
Linux Kernel Mailing List
On Sun, 2017-12-31 at 13:48 +0200, Andy Shevchenko wrote:
> On Fri, Dec 29, 2017 at 9:46 PM, Ingo Molnar <mingo@kernel.org> wrote:
> > * Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> > > > - ireg.cx = sizeof buf;
> > > > + ireg.cx = sizeof(buf);
> > >
> > > sizeof is operator, not a function.
> > > So, what are you trying to achieve?
> >
> > That's true, but in the kernel coding style we use it as a function:
>
> Yeah, the question is do we need to change all those 177 occurrences at all?
There's actually around 900, for ~100:1 ratio
$ git grep -P "\bsizeof\s+\w" -- "*.[ch]" | wc -l
907
$ git grep -P "\bsizeof\s*\(" -- "*.[ch]" | wc -l
117203
About half of these occurrences are in 3 paths
and their actual uses of sizeof without and with
parenthesis are:
drivers/infiniband/ 212:3696
drivers/media/ 111:5058
drivers/usb/ 121:2006
> Or perhaps it might be an opportunity during some other changes to
> certain users...
Perhaps best that way.
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] arch/x86/boot: sizeof macro
2017-12-31 11:48 ` Andy Shevchenko
2017-12-31 16:33 ` Joe Perches
@ 2018-01-06 11:50 ` Ingo Molnar
2018-01-08 21:44 ` H. Peter Anvin
1 sibling, 1 reply; 8+ messages in thread
From: Ingo Molnar @ 2018-01-06 11:50 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Saidgani Musaev, H. Peter Anvin, Thomas Gleixner, x86,
Linux Kernel Mailing List
* Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> On Fri, Dec 29, 2017 at 9:46 PM, Ingo Molnar <mingo@kernel.org> wrote:
> > * Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
>
> >> > - ireg.cx = sizeof buf;
> >> > + ireg.cx = sizeof(buf);
> >>
> >> sizeof is operator, not a function.
> >> So, what are you trying to achieve?
> >
> > That's true, but in the kernel coding style we use it as a function:
>
> Yeah, the question is do we need to change all those 177 occurrences at all?
> Or perhaps it might be an opportunity during some other changes to
> certain users...
We probably don't want to change then, and my point was that 99.8% of the current
usage is as a 'function':
triton:~/tip> git grep 'sizeof(' | wc -l
116570
triton:~/tip> git grep 'sizeof [:alnum:]' | wc -l
177
i.e. your patch moves it in the exact wrong direction.
Thanks,
Ingo
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] arch/x86/boot: sizeof macro
2018-01-06 11:50 ` Ingo Molnar
@ 2018-01-08 21:44 ` H. Peter Anvin
0 siblings, 0 replies; 8+ messages in thread
From: H. Peter Anvin @ 2018-01-08 21:44 UTC (permalink / raw)
To: Ingo Molnar, Andy Shevchenko
Cc: Saidgani Musaev, Thomas Gleixner, x86, Linux Kernel Mailing List
On 01/06/18 03:50, Ingo Molnar wrote:
>
> We probably don't want to change then, and my point was that 99.8% of the current
> usage is as a 'function':
>
> triton:~/tip> git grep 'sizeof(' | wc -l
> 116570
>
> triton:~/tip> git grep 'sizeof [:alnum:]' | wc -l
> 177
>
> i.e. your patch moves it in the exact wrong direction.
>
The bottom test is bogus as it is fairly common to do "sizeof *foo" in
addition to "sizeof foo":
: tazenda 139 ; git grep -P 'sizeof\s*[^\(\s]' | wc -l
2085
... but it certainly doesn't change the fact that the kernel coding
style is quite unambiguous. However, I don't think it makes any sense
to patch just for the sake of patching.
I personally like the additional visual clarification (backed by
compiler assertion) that the argument is specifically an object, not a
type ("sizeof type" is invalid), but that's not the prevalent use in
kernel code.
-hpa
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-01-08 21:48 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-29 18:30 [PATCH] arch/x86/boot: sizeof macro Saidgani Musaev
2017-12-29 18:41 ` Andy Shevchenko
2017-12-29 19:34 ` hacku
2017-12-29 19:46 ` Ingo Molnar
2017-12-31 11:48 ` Andy Shevchenko
2017-12-31 16:33 ` Joe Perches
2018-01-06 11:50 ` Ingo Molnar
2018-01-08 21:44 ` H. Peter Anvin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.