* Re:[PATCH] x86/mm/mem_encrypt_identity : fix error useage to sizeof
[not found] <201901071946365174691@zte.com.cn>
@ 2019-01-15 10:13 ` Thomas Gleixner
2019-01-15 10:21 ` [PATCH] " Juergen Gross
0 siblings, 1 reply; 5+ messages in thread
From: Thomas Gleixner @ 2019-01-15 10:13 UTC (permalink / raw)
To: peng.hao2; +Cc: bp, dave.hansen, peterz, luto, x86, linux-kernel
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?
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/mm/mem_encrypt_identity : fix error useage to sizeof
2019-01-15 10:13 ` Re:[PATCH] x86/mm/mem_encrypt_identity : fix error useage to sizeof Thomas Gleixner
@ 2019-01-15 10:21 ` Juergen Gross
2019-01-15 10:25 ` Thomas Gleixner
0 siblings, 1 reply; 5+ messages in thread
From: Juergen Gross @ 2019-01-15 10:21 UTC (permalink / raw)
To: Thomas Gleixner, peng.hao2
Cc: bp, dave.hansen, peterz, luto, x86, linux-kernel
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
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/mm/mem_encrypt_identity : fix error useage to sizeof
2019-01-15 10:21 ` [PATCH] " Juergen Gross
@ 2019-01-15 10:25 ` Thomas Gleixner
2019-01-15 10:35 ` Juergen Gross
2019-01-15 10:35 ` Thomas Gleixner
0 siblings, 2 replies; 5+ messages in thread
From: Thomas Gleixner @ 2019-01-15 10:25 UTC (permalink / raw)
To: Juergen Gross; +Cc: peng.hao2, bp, dave.hansen, peterz, luto, x86, linux-kernel
On Tue, 15 Jan 2019, Juergen Gross wrote:
> 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).
Ooops. That's wrong indeed, but we should not change it to sizeof(pte_t)
and change it to sizeof(*p) instead.
Thanks,
tglx
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/mm/mem_encrypt_identity : fix error useage to sizeof
2019-01-15 10:25 ` Thomas Gleixner
@ 2019-01-15 10:35 ` Juergen Gross
2019-01-15 10:35 ` Thomas Gleixner
1 sibling, 0 replies; 5+ messages in thread
From: Juergen Gross @ 2019-01-15 10:35 UTC (permalink / raw)
To: Thomas Gleixner
Cc: peng.hao2, bp, dave.hansen, peterz, luto, x86, linux-kernel
On 15/01/2019 11:25, Thomas Gleixner wrote:
> On Tue, 15 Jan 2019, Juergen Gross wrote:
>> 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).
>
> Ooops. That's wrong indeed, but we should not change it to sizeof(pte_t)
> and change it to sizeof(*p) instead.
And that's what the patch does.
Juergen
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/mm/mem_encrypt_identity : fix error useage to sizeof
2019-01-15 10:25 ` Thomas Gleixner
2019-01-15 10:35 ` Juergen Gross
@ 2019-01-15 10:35 ` Thomas Gleixner
1 sibling, 0 replies; 5+ messages in thread
From: Thomas Gleixner @ 2019-01-15 10:35 UTC (permalink / raw)
To: Juergen Gross; +Cc: peng.hao2, bp, dave.hansen, peterz, luto, x86, linux-kernel
On Tue, 15 Jan 2019, Thomas Gleixner wrote:
> On Tue, 15 Jan 2019, Juergen Gross wrote:
> > 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).
>
> Ooops. That's wrong indeed, but we should not change it to sizeof(pte_t)
> and change it to sizeof(*p) instead.
Which is what the patch actually does. Just the above reply:
> > >> So I think sizeof(pte_t) is safer.
confused the hell out of me. -ENOTENOUGHCOFFEE
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-01-15 10:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <201901071946365174691@zte.com.cn>
2019-01-15 10:13 ` Re:[PATCH] x86/mm/mem_encrypt_identity : fix error useage to sizeof Thomas Gleixner
2019-01-15 10:21 ` [PATCH] " Juergen Gross
2019-01-15 10:25 ` Thomas Gleixner
2019-01-15 10:35 ` Juergen Gross
2019-01-15 10:35 ` Thomas Gleixner
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).