From: Michael Tremer Date: Sun, 15 Sep 2024 04:12:44 +0000 (+0000) Subject: util: Rename JSON function to add integers to int64 X-Git-Tag: 0.9.30~1188 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6f2fb4e2bc798439ef74869a04e0b5fc167b95fa;p=pakfire.git util: Rename JSON function to add integers to int64 Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/include/pakfire/util.h b/src/libpakfire/include/pakfire/util.h index 701b1375a..41095531e 100644 --- a/src/libpakfire/include/pakfire/util.h +++ b/src/libpakfire/include/pakfire/util.h @@ -89,7 +89,7 @@ struct json_object* pakfire_json_parse(struct pakfire_ctx* ctx, const char* buffer, const size_t length); struct json_object* pakfire_json_parse_from_file(struct pakfire_ctx* ctx, const char* path); int pakfire_json_add_string(struct json_object* json, const char* name, const char* value); -int pakfire_json_add_integer(struct json_object* json, const char* name, int64_t value); +int pakfire_json_add_int64(struct json_object* json, const char* name, int64_t value); int pakfire_json_add_double(struct json_object* json, const char* name, double value); int pakfire_json_add_string_array(struct json_object* json, const char* name, char** array); diff --git a/src/libpakfire/package.c b/src/libpakfire/package.c index ad5d0f3f4..41f3a9e85 100644 --- a/src/libpakfire/package.c +++ b/src/libpakfire/package.c @@ -2292,7 +2292,7 @@ static int pakfire_package_add_build_metadata(struct pakfire_package* pkg, // Write build host time_t build_time = pakfire_package_get_num(pkg, PAKFIRE_PKG_BUILD_TIME, 0); if (build_time) { - r = pakfire_json_add_integer(object, "time", build_time); + r = pakfire_json_add_int64(object, "time", build_time); if (r) goto ERROR; } @@ -2459,7 +2459,7 @@ struct json_object* pakfire_package_to_json(struct pakfire_package* pkg) { // Installed package size unsigned long long installsize = pakfire_package_get_num(pkg, PAKFIRE_PKG_INSTALLSIZE, 0); - r = pakfire_json_add_integer(md, "size", (uint64_t)installsize); + r = pakfire_json_add_int64(md, "size", (uint64_t)installsize); if (r) goto ERROR; diff --git a/src/libpakfire/util.c b/src/libpakfire/util.c index 406d5d937..7f4afc438 100644 --- a/src/libpakfire/util.c +++ b/src/libpakfire/util.c @@ -756,12 +756,11 @@ ERROR: return r; } -int pakfire_json_add_integer(struct json_object* json, - const char* name, int64_t value) { +int pakfire_json_add_int64(struct json_object* json, const char* name, int64_t value) { // Convert integer to JSON object struct json_object* object = json_object_new_int64(value); if (!object) - return 1; + return -errno; // Add the object return json_object_object_add(json, name, object);