[SLOF] [PATCH slof 03/13] elf: Compile with -Wextra
Alexey Kardashevskiy
aik at ozlabs.ru
Wed Jan 27 19:57:42 AEDT 2021
-Wextra enables a bunch of rather useful checks which this fixes.
Signed-off-by: Alexey Kardashevskiy <aik at ozlabs.ru>
---
include/libelf.h | 6 +++---
lib/libelf/elf.c | 2 +-
lib/libelf/elf32.c | 4 ++--
lib/libelf/elf64.c | 6 +++---
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/include/libelf.h b/include/libelf.h
index 48ff4d7beb68..29a4d049a096 100644
--- a/include/libelf.h
+++ b/include/libelf.h
@@ -96,9 +96,9 @@ void elf_relocate64(void *file_addr, signed long offset);
int elf_forth_claim(void *addr, long size);
-long elf_get_file_size(const void *buffer, const long buffer_size);
-long elf_get_file_size32(const void *buffer, const long buffer_size);
-long elf_get_file_size64(const void *buffer, const long buffer_size);
+long elf_get_file_size(const void *buffer, const unsigned long buffer_size);
+long elf_get_file_size32(const void *buffer, const unsigned long buffer_size);
+long elf_get_file_size64(const void *buffer, const unsigned long buffer_size);
#ifdef __BIG_ENDIAN__
#define elf64_to_cpu(x, ehdr) ((ehdr)->ei_data == ELFDATA2MSB ? (x) : bswap_64(x))
diff --git a/lib/libelf/elf.c b/lib/libelf/elf.c
index d3684545aef7..f6a052ef3c9e 100644
--- a/lib/libelf/elf.c
+++ b/lib/libelf/elf.c
@@ -202,7 +202,7 @@ elf_get_base_addr(void *file_addr)
* buffer larger than the size of the file
* @return The size of the ELF image or < 0 for error
*/
-long elf_get_file_size(const void *buffer, const long buffer_size)
+long elf_get_file_size(const void *buffer, const unsigned long buffer_size)
{
const struct ehdr *ehdr = (const struct ehdr *)buffer;
diff --git a/lib/libelf/elf32.c b/lib/libelf/elf32.c
index 64ea386a96da..b213a6f9ca17 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 = -1;
uint16_t entsize;
unsigned i;
diff --git a/lib/libelf/elf64.c b/lib/libelf/elf64.c
index 0f302679f784..eb4cc3a7eab3 100644
--- a/lib/libelf/elf64.c
+++ b/lib/libelf/elf64.c
@@ -389,7 +389,7 @@ elf_apply_all_rela64(void *file_addr, signed long offset, struct shdr64 *shdrs,
struct rela *relaentry;
struct sym64 *symtabentry;
uint32_t symbolidx;
- int i;
+ unsigned i;
/* If the referenced section has not been allocated, then it has
* not been loaded and thus does not need to be relocated. */
@@ -481,13 +481,13 @@ uint32_t elf_get_eflags_64(void *file_addr)
* file.
* @return Return -1 on error, size of file otherwise.
*/
-long elf_get_file_size64(const void *buffer, const long buffer_size)
+long elf_get_file_size64(const void *buffer, const unsigned long buffer_size)
{
const struct ehdr64 *ehdr = (const struct ehdr64 *) buffer;
const uint8_t *buffer_end = buffer + buffer_size;
const struct phdr64 *phdr;
const struct shdr64 *shdr;
- long elf_size = -1;
+ unsigned elf_size = (unsigned)-1;
uint16_t entsize;
unsigned i;
--
2.17.1
More information about the SLOF
mailing list