* sizeof
@ 2017-03-07 23:20 Tobin C. Harding
2017-03-08 0:13 ` sizeof Anuz Pratap Singh Tomar
0 siblings, 1 reply; 2+ messages in thread
From: Tobin C. Harding @ 2017-03-07 23:20 UTC (permalink / raw)
To: kernelnewbies
Question relating to the validity/usefulness of patching calls to sizeof.
>From Documentation/process/coding-style.rst
The preferred form for passing a size of a struct is the following:
.. code-block:: c
p = kmalloc(sizeof(*p), ...);
The alternative form where struct name is spelled out hurts readability and
introduces an opportunity for a bug when the pointer variable type is changed
but the corresponding sizeof that is passed to a memory allocator is not.Is the distinction between
Question:
Is a the following a valid/useful patch or just code churn
diff--
- sizeof(struct foo)
+ sizeof(*fp)
---
^ permalink raw reply [flat|nested] 2+ messages in thread
* sizeof
2017-03-07 23:20 sizeof Tobin C. Harding
@ 2017-03-08 0:13 ` Anuz Pratap Singh Tomar
0 siblings, 0 replies; 2+ messages in thread
From: Anuz Pratap Singh Tomar @ 2017-03-08 0:13 UTC (permalink / raw)
To: kernelnewbies
On Tue, Mar 7, 2017 at 11:20 PM, Tobin C. Harding <me@tobin.cc> wrote:
> Question relating to the validity/usefulness of patching calls to sizeof.
>
> >From Documentation/process/coding-style.rst
>
> The preferred form for passing a size of a struct is the following:
>
> .. code-block:: c
>
> p = kmalloc(sizeof(*p), ...);
>
> The alternative form where struct name is spelled out hurts readability and
> introduces an opportunity for a bug when the pointer variable type is
> changed
> but the corresponding sizeof that is passed to a memory allocator is
> not.Is the distinction between
>
>
> Question:
>
> Is a the following a valid/useful patch or just code churn
>
> diff--
>
> - sizeof(struct foo)
> + sizeof(*fp)
>
>
That should depend on consistency of convention in whole file. If there are
multiple instance of this in same file(or whole module), it might not make
sense to change them all.
> ---
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
--
Thank you
Warm Regards
Anuz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20170308/74475c41/attachment-0001.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-08 0:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-07 23:20 sizeof Tobin C. Harding
2017-03-08 0:13 ` sizeof Anuz Pratap Singh Tomar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).