Skip to contentSkip to conversation

cpu: microcode: Add comma to 0

PATCH In review Jules Irenge 3 participants 5 messages Nov 26, 2019 – Nov 27, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpu: microcode: Add comma to 0

Add "," after 0
Because memory for the struct is being cleared
and elements after "," are missing on purpose
as they are being cleared to

Recommended by Boris Petkov

---
 arch/x86/kernel/cpu/microcode/amd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/microcode/amd.c +1 -1
index a0e52bd00ecc..04ee649f4acb 100644
@@ -418,7 +418,7 @@ static int __apply_microcode_amd(struct microcode_amd *mc)
 static bool
 apply_microcode_early_amd(u32 cpuid_1_eax, void *ucode, size_t size, bool save_patch)
 {
-	struct cont_desc desc = { 0 };
+	struct cont_desc desc = { 0, };
 	u8 (*patch)[PATCH_MAX_SIZE];
 	struct microcode_amd *mc;
 	u32 rev, dummy, *new_rev;
Signature · 1 line
2.23.0
#1 lore raw
Quoted 17 lines · Jules Irenge

Add "," after 0
Because memory for the struct is being cleared
and elements after "," are missing on purpose
as they are being cleared to

Recommended by Boris Petkov

---
 arch/x86/kernel/cpu/microcode/amd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/microcode/amd.c +0 -0
index a0e52bd00ecc..04ee649f4acb 100644

arch/x86/kernel/cpu/microcode/amd.c static int __apply_microcode_amd(struct microcode_amd *mc) · line 421

Quoted 5 lines
arch/x86/kernel/cpu/microcode/amd.c +1 -1
@@ -418,7 +418,7 @@ static int __apply_microcode_amd(struct microcode_amd *mc)
 static bool
 apply_microcode_early_amd(u32 cpuid_1_eax, void *ucode, size_t size, bool save_patch)
 {
-	struct cont_desc desc = { 0 };
+	struct cont_desc desc = { 0, };

This is 100% unnecessary - " = { }" is enough of a structure initializer.

Thanks,

Ingo

maintainer
#2 lore raw
Quoted 15 lines · Ingo Molnar
Quoted 12 lines · Jules Irenge

Add "," after 0
Because memory for the struct is being cleared
and elements after "," are missing on purpose
as they are being cleared to

Recommended by Boris Petkov

---
 arch/x86/kernel/cpu/microcode/amd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

arch/x86/kernel/cpu/microcode/amd.c static int __apply_microcode_amd(struct microcode_amd *mc) · line 421

Quoted 10 lines
arch/x86/kernel/cpu/microcode/amd.c +1 -1
index a0e52bd00ecc..04ee649f4acb 100644
@@ -418,7 +418,7 @@ static int __apply_microcode_amd(struct microcode_amd *mc)
 static bool
 apply_microcode_early_amd(u32 cpuid_1_eax, void *ucode, size_t size, bool save_patch)
 {
-	struct cont_desc desc = { 0 };
+	struct cont_desc desc = { 0, };

This is 100% unnecessary - " = { }" is enough of a structure initializer.

That was my initial thought but empty initializers are not ISO C compliant, I've been told.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#3 lore raw
Quoted 29 lines · Borislav Petkov
Quoted 15 lines · Ingo Molnar
Quoted 12 lines · Jules Irenge

Add "," after 0
Because memory for the struct is being cleared
and elements after "," are missing on purpose
as they are being cleared to

Recommended by Boris Petkov

---
 arch/x86/kernel/cpu/microcode/amd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

arch/x86/kernel/cpu/microcode/amd.c static int __apply_microcode_amd(struct microcode_amd *mc) · line 421

Quoted 10 lines
arch/x86/kernel/cpu/microcode/amd.c +1 -1
index a0e52bd00ecc..04ee649f4acb 100644
@@ -418,7 +418,7 @@ static int __apply_microcode_amd(struct microcode_amd *mc)
 static bool
 apply_microcode_early_amd(u32 cpuid_1_eax, void *ucode, size_t size, bool save_patch)
 {
-	struct cont_desc desc = { 0 };
+	struct cont_desc desc = { 0, };

This is 100% unnecessary - " = { }" is enough of a structure initializer.

Quoted 2 lines

That was my initial thought but empty initializers are not ISO C compliant, I've been told.

Yeah, but the kernel isn't ISO C, and the hive mind has spoken in favor of the shortest variant:

dagon:~/tip> git grep '= { }' | wc -l
647

dagon:~/tip> git grep '= { 0, }' | wc -l
231

dagon:~/tip> git grep '= { NULL, }' | wc -l
38

:-)

Thanks,

Ingo

maintainer
#4 lore raw
Quoted 6 lines · Ingo Molnar

Yeah, but the kernel isn't ISO C, and the hive mind has spoken in favor of the shortest variant:

dagon:~/tip> git grep '= { }' | wc -l
647

Quoted 7 lines

dagon:~/tip> git grep '= { 0, }' | wc -l
231

dagon:~/tip> git grep '= { NULL, }' | wc -l
38

:-)

Ok then, keeping it as is.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette