]> git.ipfire.org Git - pakfire.git/commitdiff
util: Rename JSON function to add integers to int64
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 15 Sep 2024 04:12:44 +0000 (04:12 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 15 Sep 2024 04:12:44 +0000 (04:12 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/include/pakfire/util.h
src/libpakfire/package.c
src/libpakfire/util.c

index 701b1375a0ac8f77f861605fcbfde970b0b73fce..41095531ecc12cf17fbef602bb504e6d5fe8e966 100644 (file)
@@ -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);
 
index ad5d0f3f4007e6928e6276c54eaf830119a609d2..41f3a9e858dcb5b1f7a2536d3b9d94b04a4c6486 100644 (file)
@@ -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;
 
index 406d5d937e5219b62fd7dd11e332a72fa47de3c9..7f4afc438dfecbbde355d0c478ff694d7d92c365 100644 (file)
@@ -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);