From 77dae8e058210d64a67b3bab37c1044f3c66cc52 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sat, 18 Feb 2017 14:35:53 +0100 Subject: [PATCH] libopkg: fix pkg_set_int(), pkg_get_int() Fix the return values of pkg_get_int() and pkg_set_int() to properly convert the pointers from/to integer values. Signed-off-by: Jo-Philipp Wich --- libopkg/pkg.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libopkg/pkg.h b/libopkg/pkg.h index 1ecb59e..1299d68 100644 --- a/libopkg/pkg.h +++ b/libopkg/pkg.h @@ -179,12 +179,14 @@ void *pkg_get_raw(const pkg_t *pkg, int id); static inline int pkg_set_int(pkg_t *pkg, int id, int val) { - return (intptr_t) pkg_set_raw(pkg, id, &val, sizeof(val)); + int *res = pkg_set_raw(pkg, id, &val, sizeof(val)); + return res ? *res : 0; } static inline int pkg_get_int(const pkg_t *pkg, int id) { - return (intptr_t) pkg_get_raw(pkg, id); + int *ptr = pkg_get_raw(pkg, id); + return ptr ? *ptr : 0; } char *pkg_set_string(pkg_t *pkg, int id, const char *s); -- 2.30.2