From: Jo-Philipp Wich Date: Sat, 18 Feb 2017 13:35:53 +0000 (+0100) Subject: libopkg: fix pkg_set_int(), pkg_get_int() X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=77dae8e058210d64a67b3bab37c1044f3c66cc52;p=oweals%2Fopkg-lede.git 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 --- 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);