From 5160f4107989fb90e8260ed955c43bf222f32957 Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Wed, 29 Sep 2021 12:13:59 +0000 Subject: [PATCH] zdump: PTR_(SUB|ADD) cast result to void pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This cast makes the macros easier to use without getting compiler warnings. e.g. dfo_elf.c: In function 'dfo_elf_init': dfo_elf.c:343:20: warning: assignment to 'Elf64_Phdr *' from incompatible pointer type 'char *' [-Wincompatible-pointer-types] 343 | phdrs_load = PTR_ADD(phdr_notes, sizeof(Elf64_Phdr) * phdrs_notes_count); Reviewed-by: Alexander Egorenkov Signed-off-by: Marc Hartmayer Signed-off-by: Jan Höppner --- zdump/zg.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zdump/zg.h b/zdump/zg.h index dcab7c44..2229f23c 100644 --- a/zdump/zg.h +++ b/zdump/zg.h @@ -140,8 +140,8 @@ static inline u32 zg_csum_partial(const void *buf, int len, u32 sum) /* * Pointer atrithmetic */ -#define PTR_SUB(x, y) (((char *) (x)) - ((unsigned long) (y))) -#define PTR_ADD(x, y) (((char *) (x)) + ((unsigned long) (y))) +#define PTR_SUB(x, y) ((void *)(((char *) (x)) - ((unsigned long) (y)))) +#define PTR_ADD(x, y) ((void *)(((char *) (x)) + ((unsigned long) (y)))) #define PTR_DIFF(x, y) ((unsigned long)PTR_SUB(x, y)) /*