2022-09-20 08:18:09

by Zeng Heng

[permalink] [raw]
Subject: [PATCH -next 0/3] tools: objtool: fix unused parameter warning

A patch series about fix unused-parameter compile warning in objtool.

Zeng Heng (3):
tools: objtool: fix unused parameter warning in elf.c
tools: objtool: fix unused-parameter warning in check.c
tools: objtool: fix unused-parameter warning in special.c

tools/objtool/arch/x86/special.c | 3 +--
tools/objtool/check.c | 26 ++++++++++++-------------
tools/objtool/elf.c | 4 ++--
tools/objtool/include/objtool/special.h | 3 +--
4 files changed, 16 insertions(+), 20 deletions(-)

--
2.25.1


2022-09-20 08:18:10

by Zeng Heng

[permalink] [raw]
Subject: [PATCH -next 1/3] tools: objtool: fix unused parameter warning in elf.c

Remove unused function parameter of internal function
'elf_rebuild_reloc_section'.

There is no logic changes.

Signed-off-by: Zeng Heng <[email protected]>
---
tools/objtool/elf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index c25e957c1e52..356af4d16d3f 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -1224,7 +1224,7 @@ static int elf_rebuild_rela_reloc_section(struct section *sec)
return 0;
}

-static int elf_rebuild_reloc_section(struct elf *elf, struct section *sec)
+static int elf_rebuild_reloc_section(struct section *sec)
{
switch (sec->sh.sh_type) {
case SHT_REL: return elf_rebuild_rel_reloc_section(sec);
@@ -1302,7 +1302,7 @@ int elf_write(struct elf *elf)
}

if (sec->base &&
- elf_rebuild_reloc_section(elf, sec)) {
+ elf_rebuild_reloc_section(sec)) {
WARN("elf_rebuild_reloc_section");
return -1;
}
--
2.25.1

2022-09-20 08:34:42

by Zeng Heng

[permalink] [raw]
Subject: [PATCH -next 3/3] tools: objtool: fix unused-parameter warning in special.c

Remove unused parameters of function
'arch_support_alt_relocation'.

There is no logic changes.

Signed-off-by: Zeng Heng <[email protected]>
---
tools/objtool/arch/x86/special.c | 3 +--
tools/objtool/check.c | 2 +-
tools/objtool/include/objtool/special.h | 3 +--
3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/tools/objtool/arch/x86/special.c b/tools/objtool/arch/x86/special.c
index 7c97b7391279..2524156f0f23 100644
--- a/tools/objtool/arch/x86/special.c
+++ b/tools/objtool/arch/x86/special.c
@@ -39,8 +39,7 @@ void arch_handle_alternative(unsigned short feature, struct special_alt *alt)
}

bool arch_support_alt_relocation(struct special_alt *special_alt,
- struct instruction *insn,
- struct reloc *reloc)
+ struct instruction *insn)
{
/*
* The x86 alternatives code adjusts the offsets only when it
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index cee5436b3bf9..1f755700c036 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1645,7 +1645,7 @@ static int handle_group_alt(struct objtool_file *file,
*/
alt_reloc = insn_reloc(file, insn);
if (alt_reloc &&
- !arch_support_alt_relocation(special_alt, insn, alt_reloc)) {
+ !arch_support_alt_relocation(special_alt, insn)) {

WARN_FUNC("unsupported relocation in alternatives section",
insn->sec, insn->offset);
diff --git a/tools/objtool/include/objtool/special.h b/tools/objtool/include/objtool/special.h
index dc4721e19002..fc184be6cd9f 100644
--- a/tools/objtool/include/objtool/special.h
+++ b/tools/objtool/include/objtool/special.h
@@ -35,8 +35,7 @@ int special_get_alts(struct elf *elf, struct list_head *alts);
void arch_handle_alternative(unsigned short feature, struct special_alt *alt);

bool arch_support_alt_relocation(struct special_alt *special_alt,
- struct instruction *insn,
- struct reloc *reloc);
+ struct instruction *insn);
struct reloc *arch_find_switch_table(struct objtool_file *file,
struct instruction *insn);
#endif /* _SPECIAL_H */
--
2.25.1

2022-09-20 08:49:25

by Zeng Heng

[permalink] [raw]
Subject: [PATCH -next 2/3] tools: objtool: fix unused-parameter warning in check.c

Remove unused parameters of internal functions.

There is no logic changes.

Signed-off-by: Zeng Heng <[email protected]>
---
tools/objtool/check.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 7f2a867f8f85..cee5436b3bf9 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -268,8 +268,7 @@ static void init_cfi_state(struct cfi_state *cfi)
cfi->drap_offset = -1;
}

-static void init_insn_state(struct objtool_file *file, struct insn_state *state,
- struct section *sec)
+static void init_insn_state(struct insn_state *state, struct section *sec)
{
memset(state, 0, sizeof(*state));
init_cfi_state(&state->cfi);
@@ -2446,7 +2445,7 @@ static bool is_fentry_call(struct instruction *insn)
return false;
}

-static bool has_modified_stack_frame(struct instruction *insn, struct insn_state *state)
+static bool has_modified_stack_frame(struct insn_state *state)
{
struct cfi_state *cfi = &state->cfi;
int i;
@@ -2491,9 +2490,8 @@ static bool has_valid_stack_frame(struct insn_state *state)
return false;
}

-static int update_cfi_state_regs(struct instruction *insn,
- struct cfi_state *cfi,
- struct stack_op *op)
+static int update_cfi_state_regs(struct cfi_state *cfi,
+ struct stack_op *op)
{
struct cfi_reg *cfa = &cfi->cfa;

@@ -2602,7 +2600,7 @@ static int update_cfi_state(struct instruction *insn,

if (cfi->type == UNWIND_HINT_TYPE_REGS ||
cfi->type == UNWIND_HINT_TYPE_REGS_PARTIAL)
- return update_cfi_state_regs(insn, cfi, op);
+ return update_cfi_state_regs(cfi, op);

switch (op->dest.type) {

@@ -3015,7 +3013,7 @@ static int update_cfi_state(struct instruction *insn,
* and replacement) into a single shared CFI array which can be used to detect
* conflicts and nicely feed a linear array of ORC entries to the unwinder.
*/
-static int propagate_alt_cfi(struct objtool_file *file, struct instruction *insn)
+static int propagate_alt_cfi(struct instruction *insn)
{
struct cfi_state **alt_cfi;
int group_off;
@@ -3249,7 +3247,7 @@ static int validate_sibling_call(struct objtool_file *file,
struct instruction *insn,
struct insn_state *state)
{
- if (has_modified_stack_frame(insn, state)) {
+ if (has_modified_stack_frame(state)) {
WARN_FUNC("sibling call from callable instruction with modified stack frame",
insn->sec, insn->offset);
return 1;
@@ -3284,7 +3282,7 @@ static int validate_return(struct symbol *func, struct instruction *insn, struct
return 1;
}

- if (func && has_modified_stack_frame(insn, state)) {
+ if (func && has_modified_stack_frame(state)) {
WARN_FUNC("return with modified stack frame",
insn->sec, insn->offset);
return 1;
@@ -3405,7 +3403,7 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,

insn->visited |= visited;

- if (propagate_alt_cfi(file, insn))
+ if (propagate_alt_cfi(insn))
return 1;

if (!insn->ignore_alts && !list_empty(&insn->alts)) {
@@ -3567,7 +3565,7 @@ static int validate_unwind_hints(struct objtool_file *file, struct section *sec)
if (!file->hints)
return 0;

- init_insn_state(file, &state, sec);
+ init_insn_state(&state, sec);

if (sec) {
insn = find_insn(file, sec, 0);
@@ -3930,7 +3928,7 @@ static int validate_section(struct objtool_file *file, struct section *sec)
if (func->type != STT_FUNC)
continue;

- init_insn_state(file, &state, sec);
+ init_insn_state(&state, sec);
set_func_state(&state.cfi);

warnings += validate_symbol(file, sec, func, &state);
--
2.25.1