libopkg: fix pkg_set_int(), pkg_get_int()
[oweals/opkg-lede.git] / libopkg / pkg.h
index 1ecb59e7558ba88dd3a06cc8a5a6a3635a7aecdb..1299d684d67f6c7427f0c3160d0be5bccaa788bf 100644 (file)
@@ -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);