td_var: avoid arithmetic on a pointer to void cast (#1096)
authorCheng Li <cheng.li@rutgers.edu>
Thu, 8 Oct 2020 18:22:34 +0000 (11:22 -0700)
committerCheng Li <chenglii@cs.rutgers.edu>
Thu, 8 Oct 2020 18:28:56 +0000 (11:28 -0700)
Issue 1096 shows that a compiler complains an `arithmetic on a pointer to
void` error when `-Wpointer-arith` is turned on in Makefile. Although
there are many violating instances, we only fix the one in `parse.h`
because it is shared across many core source code files. This patch fixes
the `arithmetic on a pointer to void` issue by casting it to a uintptr_t
type first and perform manipulation, and then cast it back to void* type.

Signed-off-by: Cheng Li <chenglii@cs.rutgers.edu>
parse.h

diff --git a/parse.h b/parse.h
index 1d2cbf74f424089cc77214fc6c640e4df8b6de11..e6663ed484ed343b096ebc33a28a52560f642aea 100644 (file)
--- a/parse.h
+++ b/parse.h
@@ -125,7 +125,7 @@ static inline void *td_var(void *to, const struct fio_option *o,
        else
                ret = to;
 
-       return ret + offset;
+       return (void *) ((uintptr_t) ret + offset);
 }
 
 static inline int parse_is_percent(unsigned long long val)