2022-10-11 01:33:45

by Li Zetao

[permalink] [raw]
Subject: [PATCH -next v4 1/2] x86/boot: Remove unused variables

Gcc report warning as follows:

arch/x86/boot/compressed/efi.c: In function ‘efi_get_system_table’:
arch/x86/boot/compressed/efi.c:62:23: warning: unused variable ‘et’
[-Wunused-variable]

arch/x86/boot/compressed/efi.c: In function ‘efi_get_conf_table’:
arch/x86/boot/compressed/efi.c:134:13: warning: unused variable
‘ret’ [-Wunused-variable]

arch/x86/boot/compressed/acpi.c: In function ‘__efi_get_rsdp_addr’:
arch/x86/boot/compressed/acpi.c:27:13: warning: unused variable
‘ret’ [-Wunused-variable]

arch/x86/boot/compressed/acpi.c: In function ‘efi_get_rsdp_addr’:
arch/x86/boot/compressed/acpi.c:55:22: warning: unused variable
‘nr_tables’ [-Wunused-variable]

arch/x86/boot/compressed/sev.c: In function ‘enforce_vmpl0’:
arch/x86/boot/compressed/sev.c:256:13: error: unused variable ‘err’
[-Werror=unused-variable]

Fix these warnings by removing unused variables.

Fixes: 58f3e6b71f42 ("x86/compressed/acpi: Move EFI system table lookup to helper")
Fixes: 61c14ceda840 ("x86/compressed/acpi: Move EFI config table lookup to helper")
Fixes: dee602dd5d14 ("x86/compressed/acpi: Move EFI vendor table lookup to helper")
Fixes: f9d230e893e8 ("x86/boot: Correct RSDP parsing with 32-bit EFI")
Fixes: 81cc3df9a90e ("x86/sev: Check the VMPL level")
Signed-off-by: Li Zetao <[email protected]>
---
v1 -> v2: Remove unused variables "et" in efi_get_system_table(), "ret" in
efi_get_conf_table(), "ret" in __efi_get_rsdp_addr() and "nr_tables" in
efi_get_rsdp_addr()
v2 -> v3: None
v3 -> v4: Put this patch in front

arch/x86/boot/compressed/acpi.c | 2 --
arch/x86/boot/compressed/efi.c | 2 --
arch/x86/boot/compressed/sev.c | 1 -
3 files changed, 5 deletions(-)

diff --git a/arch/x86/boot/compressed/acpi.c b/arch/x86/boot/compressed/acpi.c
index 9caf89063e77..21febd9f21ab 100644
--- a/arch/x86/boot/compressed/acpi.c
+++ b/arch/x86/boot/compressed/acpi.c
@@ -24,7 +24,6 @@ __efi_get_rsdp_addr(unsigned long cfg_tbl_pa, unsigned int cfg_tbl_len)
{
#ifdef CONFIG_EFI
unsigned long rsdp_addr;
- int ret;

/*
* Search EFI system tables for RSDP. Preferred is ACPI_20_TABLE_GUID to
@@ -52,7 +51,6 @@ static acpi_physical_address efi_get_rsdp_addr(void)
unsigned long cfg_tbl_pa = 0;
unsigned int cfg_tbl_len;
unsigned long systab_pa;
- unsigned int nr_tables;
enum efi_type et;
int ret;

diff --git a/arch/x86/boot/compressed/efi.c b/arch/x86/boot/compressed/efi.c
index 6edd034b0b30..6ffd22710ed2 100644
--- a/arch/x86/boot/compressed/efi.c
+++ b/arch/x86/boot/compressed/efi.c
@@ -59,7 +59,6 @@ unsigned long efi_get_system_table(struct boot_params *bp)
{
unsigned long sys_tbl_pa;
struct efi_info *ei;
- enum efi_type et;

/* Get systab from boot params. */
ei = &bp->efi_info;
@@ -131,7 +130,6 @@ int efi_get_conf_table(struct boot_params *bp, unsigned long *cfg_tbl_pa,
{
unsigned long sys_tbl_pa;
enum efi_type et;
- int ret;

if (!cfg_tbl_pa || !cfg_tbl_len)
return -EINVAL;
diff --git a/arch/x86/boot/compressed/sev.c b/arch/x86/boot/compressed/sev.c
index c93930d5ccbd..b9451761a69a 100644
--- a/arch/x86/boot/compressed/sev.c
+++ b/arch/x86/boot/compressed/sev.c
@@ -253,7 +253,6 @@ void do_boot_stage2_vc(struct pt_regs *regs, unsigned long exit_code)
static void enforce_vmpl0(void)
{
u64 attrs;
- int err;

/*
* RMPADJUST modifies RMP permissions of a lesser-privileged (numerically
--
2.34.1


2022-10-11 21:23:21

by Nick Desaulniers

[permalink] [raw]
Subject: Re: [PATCH -next v4 1/2] x86/boot: Remove unused variables

On Mon, Oct 10, 2022 at 6:32 PM Li Zetao <[email protected]> wrote:
>
> Gcc report warning as follows:
>
> arch/x86/boot/compressed/efi.c: In function ‘efi_get_system_table’:
> arch/x86/boot/compressed/efi.c:62:23: warning: unused variable ‘et’
> [-Wunused-variable]
>
> arch/x86/boot/compressed/efi.c: In function ‘efi_get_conf_table’:
> arch/x86/boot/compressed/efi.c:134:13: warning: unused variable
> ‘ret’ [-Wunused-variable]
>
> arch/x86/boot/compressed/acpi.c: In function ‘__efi_get_rsdp_addr’:
> arch/x86/boot/compressed/acpi.c:27:13: warning: unused variable
> ‘ret’ [-Wunused-variable]
>
> arch/x86/boot/compressed/acpi.c: In function ‘efi_get_rsdp_addr’:
> arch/x86/boot/compressed/acpi.c:55:22: warning: unused variable
> ‘nr_tables’ [-Wunused-variable]
>
> arch/x86/boot/compressed/sev.c: In function ‘enforce_vmpl0’:
> arch/x86/boot/compressed/sev.c:256:13: error: unused variable ‘err’
> [-Werror=unused-variable]
>
> Fix these warnings by removing unused variables.
>
> Fixes: 58f3e6b71f42 ("x86/compressed/acpi: Move EFI system table lookup to helper")
> Fixes: 61c14ceda840 ("x86/compressed/acpi: Move EFI config table lookup to helper")
> Fixes: dee602dd5d14 ("x86/compressed/acpi: Move EFI vendor table lookup to helper")
> Fixes: f9d230e893e8 ("x86/boot: Correct RSDP parsing with 32-bit EFI")
> Fixes: 81cc3df9a90e ("x86/sev: Check the VMPL level")
> Signed-off-by: Li Zetao <[email protected]>

Thanks for the patch!
Reviewed-by: Nick Desaulniers <[email protected]>

> ---
> v1 -> v2: Remove unused variables "et" in efi_get_system_table(), "ret" in
> efi_get_conf_table(), "ret" in __efi_get_rsdp_addr() and "nr_tables" in
> efi_get_rsdp_addr()
> v2 -> v3: None
> v3 -> v4: Put this patch in front
>
> arch/x86/boot/compressed/acpi.c | 2 --
> arch/x86/boot/compressed/efi.c | 2 --
> arch/x86/boot/compressed/sev.c | 1 -
> 3 files changed, 5 deletions(-)
>
> diff --git a/arch/x86/boot/compressed/acpi.c b/arch/x86/boot/compressed/acpi.c
> index 9caf89063e77..21febd9f21ab 100644
> --- a/arch/x86/boot/compressed/acpi.c
> +++ b/arch/x86/boot/compressed/acpi.c
> @@ -24,7 +24,6 @@ __efi_get_rsdp_addr(unsigned long cfg_tbl_pa, unsigned int cfg_tbl_len)
> {
> #ifdef CONFIG_EFI
> unsigned long rsdp_addr;
> - int ret;
>
> /*
> * Search EFI system tables for RSDP. Preferred is ACPI_20_TABLE_GUID to
> @@ -52,7 +51,6 @@ static acpi_physical_address efi_get_rsdp_addr(void)
> unsigned long cfg_tbl_pa = 0;
> unsigned int cfg_tbl_len;
> unsigned long systab_pa;
> - unsigned int nr_tables;
> enum efi_type et;
> int ret;
>
> diff --git a/arch/x86/boot/compressed/efi.c b/arch/x86/boot/compressed/efi.c
> index 6edd034b0b30..6ffd22710ed2 100644
> --- a/arch/x86/boot/compressed/efi.c
> +++ b/arch/x86/boot/compressed/efi.c
> @@ -59,7 +59,6 @@ unsigned long efi_get_system_table(struct boot_params *bp)
> {
> unsigned long sys_tbl_pa;
> struct efi_info *ei;
> - enum efi_type et;
>
> /* Get systab from boot params. */
> ei = &bp->efi_info;
> @@ -131,7 +130,6 @@ int efi_get_conf_table(struct boot_params *bp, unsigned long *cfg_tbl_pa,
> {
> unsigned long sys_tbl_pa;
> enum efi_type et;
> - int ret;
>
> if (!cfg_tbl_pa || !cfg_tbl_len)
> return -EINVAL;
> diff --git a/arch/x86/boot/compressed/sev.c b/arch/x86/boot/compressed/sev.c
> index c93930d5ccbd..b9451761a69a 100644
> --- a/arch/x86/boot/compressed/sev.c
> +++ b/arch/x86/boot/compressed/sev.c
> @@ -253,7 +253,6 @@ void do_boot_stage2_vc(struct pt_regs *regs, unsigned long exit_code)
> static void enforce_vmpl0(void)
> {
> u64 attrs;
> - int err;
>
> /*
> * RMPADJUST modifies RMP permissions of a lesser-privileged (numerically
> --
> 2.34.1
>


--
Thanks,
~Nick Desaulniers

2022-10-11 21:57:48

by Nick Desaulniers

[permalink] [raw]
Subject: Re: [PATCH -next v4 1/2] x86/boot: Remove unused variables

On Mon, Oct 10, 2022 at 6:32 PM Li Zetao <[email protected]> wrote:
>
> diff --git a/arch/x86/boot/compressed/sev.c b/arch/x86/boot/compressed/sev.c
> index c93930d5ccbd..b9451761a69a 100644
> --- a/arch/x86/boot/compressed/sev.c
> +++ b/arch/x86/boot/compressed/sev.c
> @@ -253,7 +253,6 @@ void do_boot_stage2_vc(struct pt_regs *regs, unsigned long exit_code)
> static void enforce_vmpl0(void)
> {
> u64 attrs;
> - int err;

Just a thought but you could initialize attrs now on the same line.

I also ended up testing the whole series, so:

Tested-by: Nick Desaulniers <[email protected]>
--
Thanks,
~Nick Desaulniers