From c3aa9d606bdac2b24709515b2bb61579f345255d Mon Sep 17 00:00:00 2001 From: Zhou Kang Date: Wed, 5 Jul 2023 03:21:13 +0000 Subject: [PATCH] cleancode for elf_set_symbolic_link --- src/elf_hugepage.c | 9 ++++----- src/elf_hugepage.h | 2 +- src/main.c | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/elf_hugepage.c b/src/elf_hugepage.c index 8bfd141..9c13dab 100644 --- a/src/elf_hugepage.c +++ b/src/elf_hugepage.c @@ -36,11 +36,10 @@ #endif #define OS_SPECIFIC_MASK (0xffffffffU ^ OS_SPECIFIC_FLAG_SYMBOLIC_LINK ^ OS_SPECIFIC_FLAG_HUGEPAGE) -void _elf_set_aot(elf_file_t *ef, bool state) +void _elf_set_symbolic_link(elf_file_t *ef, bool state) { if (state) { ef->hdr->e_flags |= OS_SPECIFIC_FLAG_SYMBOLIC_LINK; - ef->hdr->e_flags |= OS_SPECIFIC_FLAG_HUGEPAGE; } else { ef->hdr->e_flags &= OS_SPECIFIC_MASK; } @@ -61,10 +60,10 @@ void elf_set_hugepage(elf_link_t *elf_link) } } - _elf_set_aot(ef, true); + ef->hdr->e_flags |= OS_SPECIFIC_FLAG_HUGEPAGE; } -int elf_set_aot(char *path, bool state) +int elf_set_symbolic_link(char *path, bool state) { // this memory will free by process exit elf_file_t *ef = malloc(sizeof(elf_file_t)); @@ -78,7 +77,7 @@ int elf_set_aot(char *path, bool state) return -1; } - _elf_set_aot(ef, state); + _elf_set_symbolic_link(ef, state); close(ef->fd); // This process is a oneshot process. The release of variable ef depends diff --git a/src/elf_hugepage.h b/src/elf_hugepage.h index 8ca53b3..94f1b90 100644 --- a/src/elf_hugepage.h +++ b/src/elf_hugepage.h @@ -5,6 +5,6 @@ #include "elf_link_common.h" void elf_set_hugepage(elf_link_t *elf_link); -int elf_set_aot(char *path, bool state); +int elf_set_symbolic_link(char *path, bool state); #endif /* _ELF_HUGEPAGE_H */ diff --git a/src/main.c b/src/main.c index f106651..d276985 100644 --- a/src/main.c +++ b/src/main.c @@ -51,14 +51,14 @@ int main(int argc, char *argv[]) SI_LOG_ERR("get realpath fail: %s\n", optarg); return -1; } - return elf_set_aot(tmp, true); + return elf_set_symbolic_link(tmp, true); case 'u': str_ret = realpath(optarg, tmp); if (!str_ret) { SI_LOG_ERR("get realpath fail: %s\n", optarg); return -1; } - return elf_set_aot(tmp, false); + return elf_set_symbolic_link(tmp, false); case 'h': elf_link->hook_func = true; SI_LOG_INFO("hook func\n"); -- Gitee