Skip to contentSkip to conversation

x86/mm/mem_encrypt_identity : fix error useage to sizeof

PATCH Thomas Gleixner 2 participants 5 messages Jan 15, 2019 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 8 lines · On Mon, 7 Jan 2019, [email protected] wrote:
Quoted 6 lines
Quoted 1 line

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

#2 lore raw
Quoted 17 lines · Thomas Gleixner
Quoted 8 lines · On Mon, 7 Jan 2019, [email protected] wrote:
Quoted 6 lines
Quoted 1 line

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)
Quoted 5 lines

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

Quoted 10 lines

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

#3 lore raw
Quoted 18 lines · Juergen Gross
Quoted 17 lines · Thomas Gleixner
Quoted 8 lines · On Mon, 7 Jan 2019, [email protected] wrote:
Quoted 6 lines
Quoted 1 line

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)
Quoted 7 lines
Quoted 5 lines

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

#4 lore raw
Quoted 21 lines · Thomas Gleixner
Quoted 20 lines · Juergen Gross
Quoted 19 lines · Thomas Gleixner
Quoted 8 lines · On Mon, 7 Jan 2019, [email protected] wrote:
Quoted 6 lines
Quoted 1 line

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

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

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

#5 lore raw
In reply to Thomas Gleixner
Quoted 21 lines · Thomas Gleixner
Quoted 20 lines · Juergen Gross
Quoted 19 lines · Thomas Gleixner
Quoted 8 lines · On Mon, 7 Jan 2019, [email protected] wrote:
Quoted 6 lines
Quoted 1 line

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

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

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:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

So I think sizeof(pte_t) is safer.

confused the hell out of me. -ENOTENOUGHCOFFEE