lkml.org 
[lkml]   [2019]   [Jan]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] x86/mm/mem_encrypt_identity : fix error useage to sizeof
From
Date
On 15/01/2019 11:13, Thomas Gleixner wrote:
> On Mon, 7 Jan 2019, peng.hao2@zte.com.cn wrote:
>
>>>> Fix error usage to sizeof. It should not use sizeof to pointer.
>>>
>>> .... because?
>>>
>>> The commit message needs to explain what the potential issue could be
>>> and why it doesn't matter in this case.
>> I see the definition of pte_t may be more than sizeof(unsigned long).
>> So I think sizeof(pte_t) is safer.
>
> What exactly is the difference between:
>
> pte_t *p;
>
> sizeof(*p)
>
> and
>
> sizeof(pte_t)
>
> and what is safer about the latter?

Please note that the current code is using sizeof(p) instead of sizeof(*p).

And this is really different for X86_32 PAE.


Juergen

>
> Answer: No difference and nothing is safer because it's exactly the same.
>
> In general we use sizeof(*p) simply because when the data type of p changes
> you don't have to update the code, it just works and stays correct.
>
> Thanks,
>
> tglx
>

\
 
 \ /
  Last update: 2019-01-15 11:22    [W:0.046 / U:12.836 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site