diff options
author | Alexey Kardashevskiy <aik@ozlabs.ru> | 2021-01-27 19:33:49 +1100 |
---|---|---|
committer | Alexey Kardashevskiy <aik@ozlabs.ru> | 2021-02-12 13:41:47 +1100 |
commit | 26d8ba170355c951e53c08c357121d96bdb54076 (patch) | |
tree | 837809aefc4d61889aa803904585f4040ab2d4d4 /lib/libelf/elf32.c | |
parent | 0549fa7d08dc9865e25b2af1a46f8ccbe46fd312 (diff) | |
download | SLOF-26d8ba170355c951e53c08c357121d96bdb54076.zip SLOF-26d8ba170355c951e53c08c357121d96bdb54076.tar.gz SLOF-26d8ba170355c951e53c08c357121d96bdb54076.tar.bz2 |
elf: Compile with -Wextra
-Wextra enables a bunch of rather useful checks which this fixes.
This changes the return value for the case when no ELF headers were found
to avoid (ugly-ish) cast of -1 to unsigned.
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
Changes:
v2:
* cast the return value to (int)
* added missing (long)
Diffstat (limited to 'lib/libelf/elf32.c')
-rw-r--r-- | lib/libelf/elf32.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libelf/elf32.c b/lib/libelf/elf32.c index 64ea386..45b0015 100644 --- a/lib/libelf/elf32.c +++ b/lib/libelf/elf32.c @@ -212,13 +212,13 @@ elf_byteswap_header32(void *file_addr) * file. * @return Return -1 on error, size of file otherwise. */ -long elf_get_file_size32(const void *buffer, const long buffer_size) +long elf_get_file_size32(const void *buffer, const unsigned long buffer_size) { const struct ehdr32 *ehdr = (const struct ehdr32 *) buffer; const uint8_t *buffer_end = buffer + buffer_size; const struct phdr32 *phdr; const struct shdr32 *shdr; - long elf_size = -1; + unsigned long elf_size = 0; uint16_t entsize; unsigned i; @@ -258,5 +258,5 @@ long elf_get_file_size32(const void *buffer, const long buffer_size) if (elf_size > buffer_size) return -1; - return elf_size; + return (long) elf_size; } |