[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 9/9] dump: Consolidate elf note function
From: |
Janosch Frank |
Subject: |
[PATCH v2 9/9] dump: Consolidate elf note function |
Date: |
Thu, 10 Mar 2022 11:08:54 +0000 |
Just like with the other write functions let's move the 32/64 bit elf
handling to a function to improve readability.
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
dump/dump.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/dump/dump.c b/dump/dump.c
index 5542adf7b8..ae8ec527de 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -510,6 +510,20 @@ static void write_elf_loads(DumpState *s, Error **errp)
}
}
+static void write_elf_notes(DumpState *s, Error **errp)
+{
+ ERRP_GUARD();
+
+ if (dump_is_64bit(s)) {
+ write_elf64_notes(fd_write_vmcore, s, errp);
+ } else {
+ write_elf32_notes(fd_write_vmcore, s, errp);
+ }
+ if (*errp) {
+ return;
+ }
+}
+
/* write elf header, PT_NOTE and elf note to vmcore. */
static void dump_begin(DumpState *s, Error **errp)
{
@@ -569,13 +583,8 @@ static void dump_begin(DumpState *s, Error **errp)
}
}
- if (dump_is_64bit(s)) {
- /* write notes to vmcore */
- write_elf64_notes(fd_write_vmcore, s, errp);
- } else {
- /* write notes to vmcore */
- write_elf32_notes(fd_write_vmcore, s, errp);
- }
+ /* write notes to vmcore */
+ write_elf_notes(s, errp);
}
static int get_next_block(DumpState *s, GuestPhysBlock *block)
--
2.32.0
- [PATCH v2 0/9] dump: Cleanup and consolidation, Janosch Frank, 2022/03/10
- [PATCH v2 5/9] dump: Add more offset variables, Janosch Frank, 2022/03/10
- [PATCH v2 8/9] dump: Cleanup dump_begin write functions, Janosch Frank, 2022/03/10
- [PATCH v2 6/9] dump: Introduce dump_is_64bit() helper function, Janosch Frank, 2022/03/10
- [PATCH v2 7/9] dump: Consolidate phdr note writes, Janosch Frank, 2022/03/10
- [PATCH v2 9/9] dump: Consolidate elf note function,
Janosch Frank <=
- [PATCH v2 2/9] dump: Remove the sh_info variable, Janosch Frank, 2022/03/10
- [PATCH v2 4/9] dump: Remove the section if when calculating the memory offset, Janosch Frank, 2022/03/10
- [PATCH v2 3/9] dump: Introduce shdr_num to decrease complexity, Janosch Frank, 2022/03/10
- [PATCH v2 1/9] dump: Use ERRP_GUARD(), Janosch Frank, 2022/03/10