[PATCH] perf jvmti: Remove unnecessary ret variable in jvmti_write_code

From: Luo Yifan
Date: Tue Nov 12 2024 - 01:01:53 EST


Following the approach in the jvmti_write_debug_info function, just
remove the ret variable from jvmti_write_code function. It's safe since
we don’t really care about the return value of fwrite_unlocked. This
change makes the code cleaner and more compiler-friendly.

Signed-off-by: Luo Yifan <luoyifan@xxxxxxxxxxxxxxxxxxxx>
---
tools/perf/jvmti/jvmti_agent.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/tools/perf/jvmti/jvmti_agent.c b/tools/perf/jvmti/jvmti_agent.c
index 526dcaf9f..9b49a880b 100644
--- a/tools/perf/jvmti/jvmti_agent.c
+++ b/tools/perf/jvmti/jvmti_agent.c
@@ -363,7 +363,6 @@ jvmti_write_code(void *agent, char const *sym,
struct jr_code_load rec;
size_t sym_len;
FILE *fp = agent;
- int ret = -1;

/* don't care about 0 length function, no samples */
if (size == 0)
@@ -400,7 +399,7 @@ jvmti_write_code(void *agent, char const *sym,
*/
rec.code_index = code_generation++;

- ret = fwrite_unlocked(&rec, sizeof(rec), 1, fp);
+ fwrite_unlocked(&rec, sizeof(rec), 1, fp);
fwrite_unlocked(sym, sym_len, 1, fp);

if (code)
@@ -408,9 +407,7 @@ jvmti_write_code(void *agent, char const *sym,

funlockfile(fp);

- ret = 0;
-
- return ret;
+ return 0;
}

int
--
2.27.0