summaryrefslogtreecommitdiff
path: root/src/objdump.c
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2022-03-27 21:08:36 +0200
committerMark Wielaard <mark@klomp.org>2022-03-30 16:40:05 +0200
commitdec6d82cf2e9c79b9b45a29de5ea2d8f25cc633b (patch)
tree2bc33be084fe10b7b404f9c05800a3bfcc9e92c4 /src/objdump.c
parent4a22e01277e37540d753e3513c4df3bd2b6e1246 (diff)
downloadelfutils-dec6d82cf2e9c79b9b45a29de5ea2d8f25cc633b.tar.gz
Introduce error_exit as a noreturn variant of error (EXIT_FAILURE, ...)
error (EXIT_FAILURE, ...) should be noreturn but on some systems it isn't. This may cause warnings about code that should not be reachable. So have an explicit error_exit wrapper that is noreturn (because it calls exit explicitly). Use error_exit in all tools under the src directory. https://bugzilla.redhat.com/show_bug.cgi?id=2068692 Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'src/objdump.c')
-rw-r--r--src/objdump.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/objdump.c b/src/objdump.c
index f7ea6c92..b32de17d 100644
--- a/src/objdump.c
+++ b/src/objdump.c
@@ -100,8 +100,8 @@ static int handle_elf (Elf *elf, const char *prefix, const char *fname,
#define INTERNAL_ERROR(fname) \
- error (EXIT_FAILURE, 0, _("%s: INTERNAL ERROR %d (%s): %s"), \
- fname, __LINE__, PACKAGE_VERSION, elf_errmsg (-1))
+ error_exit (0, _("%s: INTERNAL ERROR %d (%s): %s"), \
+ fname, __LINE__, PACKAGE_VERSION, elf_errmsg (-1))
/* List of sections which should be used. */
@@ -255,7 +255,7 @@ process_file (const char *fname, bool more_than_one)
INTERNAL_ERROR (fname);
if (close (fd) != 0)
- error (EXIT_FAILURE, errno, _("while close `%s'"), fname);
+ error_exit (errno, _("while close `%s'"), fname);
return result;
}
@@ -267,7 +267,7 @@ process_file (const char *fname, bool more_than_one)
INTERNAL_ERROR (fname);
if (close (fd) != 0)
- error (EXIT_FAILURE, errno, _("while close `%s'"), fname);
+ error_exit (errno, _("while close `%s'"), fname);
return result;
}
@@ -684,7 +684,7 @@ show_disasm (Ebl *ebl, const char *fname, uint32_t shstrndx)
{
DisasmCtx_t *ctx = disasm_begin (ebl, ebl->elf, NULL /* XXX TODO */);
if (ctx == NULL)
- error (EXIT_FAILURE, 0, _("cannot disassemble"));
+ error_exit (0, _("cannot disassemble"));
Elf_Scn *scn = NULL;
while ((scn = elf_nextscn (ebl->elf, scn)) != NULL)
@@ -755,8 +755,7 @@ handle_elf (Elf *elf, const char *prefix, const char *fname,
/* Get the backend for this object file type. */
Ebl *ebl = ebl_openbackend (elf);
if (ebl == NULL)
- error (EXIT_FAILURE, 0,
- _("cannot create backend for elf file"));
+ error_exit (0, _("cannot create backend for elf file"));
printf ("%s: elf%d-%s\n\n",
fname, gelf_getclass (elf) == ELFCLASS32 ? 32 : 64,
@@ -777,8 +776,7 @@ handle_elf (Elf *elf, const char *prefix, const char *fname,
/* Get the section header string table index. */
size_t shstrndx;
if (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0)
- error (EXIT_FAILURE, 0,
- _("cannot get section header string table index"));
+ error_exit (0, _("cannot get section header string table index"));
int result = 0;
if (print_disasm)