]> git.ipfire.org Git - pakfire.git/commitdiff
pakfire_make_cache_path: Implicitely handle size argument
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 19 Apr 2021 15:12:00 +0000 (15:12 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 19 Apr 2021 15:12:00 +0000 (15:12 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/dist.c
src/libpakfire/include/pakfire/pakfire.h
src/libpakfire/package.c
src/libpakfire/pakfire.c
src/libpakfire/repo.c

index a7c162fe63ac719e534b0076d4d6caebb829c21c..4bb66797d1bc00bb5a412e5059f23b647039255d 100644 (file)
@@ -163,8 +163,7 @@ static int pakfire_dist_add_source(Pakfire pakfire, struct pakfire_packager* pac
        char cache_path[PATH_MAX];
 
        const char* name = pakfire_package_get_name(pkg);
-       pakfire_make_cache_path(pakfire, cache_path, sizeof(cache_path) - 1,
-               "sources/%s/%s", name, filename);
+       pakfire_make_cache_path(pakfire, cache_path, "sources/%s/%s", name, filename);
 
        // Download the file if it does not exist in the cache
        if (access(cache_path, R_OK) != 0) {
index a81faf31e7f4c953d8ee054d34f1ae2828e218c5..a8063b13e9fe1bd0300305428452be07e879a986 100644 (file)
@@ -84,9 +84,11 @@ int pakfire_read_makefile(PakfireParser* parser, Pakfire pakfire, const char* pa
 
 #include <solv/pool.h>
 
-int pakfire_make_cache_path(Pakfire pakfire, char* path, size_t length,
-       const char* format, ...)
-       __attribute__((format(printf, 4, 5)));
+#define pakfire_make_cache_path(pakfire, path, format, ...) \
+       __pakfire_make_cache_path(pakfire, path, sizeof(path) - 1, format, __VA_ARGS__)
+
+int __pakfire_make_cache_path(Pakfire pakfire, char* path, size_t length,
+       const char* format, ...) __attribute__((format(printf, 4, 5)));
 
 void pakfire_pool_has_changed(Pakfire pakfire);
 void pakfire_pool_apply_changes(Pakfire pakfire);
index 1825de4d1144b2fb0ae2a0157ef55dfeb1ffe98f..2fd34107170338a5e43588c342a73ebcaa546500 100644 (file)
@@ -913,7 +913,7 @@ PAKFIRE_EXPORT char* pakfire_package_get_cache_path(PakfirePackage pkg) {
        if (strlen(checksum) < 3)
                return NULL;
 
-       pakfire_make_cache_path(pkg->pakfire, path, sizeof(path) - 1,
+       pakfire_make_cache_path(pkg->pakfire, path,
                "%c%c/%s/%s", checksum[0], checksum[1], checksum + 2, filename);
 
        return strdup(path);
index 6e74f67f397e05b6ae1b8be343a884edb1b038df..0635c49f999c9bfd0a162f374bf810cf83f8113d 100644 (file)
@@ -1148,7 +1148,7 @@ PAKFIRE_EXPORT PakfirePackageList pakfire_search(Pakfire pakfire, const char* wh
 
 // Cache
 
-int pakfire_make_cache_path(Pakfire pakfire, char* path, size_t length,
+int __pakfire_make_cache_path(Pakfire pakfire, char* path, size_t length,
                const char* format, ...) {
        va_list args;
 
@@ -1174,7 +1174,7 @@ int pakfire_make_cache_path(Pakfire pakfire, char* path, size_t length,
 PAKFIRE_EXPORT int pakfire_cache_destroy(Pakfire pakfire, const char* path) {
        char cache_path[PATH_MAX];
 
-       pakfire_make_cache_path(pakfire, cache_path, sizeof(cache_path) - 1, "%s", path);
+       pakfire_make_cache_path(pakfire, cache_path, "%s", path);
 
        // Completely delete the tree of files
        return pakfire_rmtree(cache_path, 0);
index 9df53bc8a0ba9941f1cf157824188ffdc75776f0..4e4837514d027aaac205b18ee0410a6c6a14841b 100644 (file)
@@ -259,7 +259,7 @@ static int pakfire_repo_read_metadata(PakfireRepo repo, const char* path, int re
 
        // Try loading the database
        if (*database_filename) {
-               pakfire_make_cache_path(repo->pakfire, database_cache_path, sizeof(database_cache_path) -1,
+               pakfire_make_cache_path(repo->pakfire, database_cache_path,
                        "repodata/%s/%s", pakfire_repo_get_name(repo), database_filename);
 
                // Download the database if necessary
@@ -427,13 +427,13 @@ PAKFIRE_EXPORT PakfireRepo pakfire_repo_create(Pakfire pakfire, const char* name
                return repo;
 
        // Make path to mirrorlist
-       r = pakfire_make_cache_path(pakfire, repo->appdata->mirrorlist, sizeof(repo->appdata->mirrorlist) - 1,
+       r = pakfire_make_cache_path(pakfire, repo->appdata->mirrorlist,
                "repodata/%s/mirrorlist", pakfire_repo_get_name(repo));
        if (r < 0)
                goto ERROR;
 
        // Make path for metadata
-       r = pakfire_make_cache_path(pakfire, repo->appdata->metadata, sizeof(repo->appdata->metadata) - 1,
+       r = pakfire_make_cache_path(pakfire, repo->appdata->metadata,
                "repodata/%s/repomd.json", pakfire_repo_get_name(repo));
        if (r < 0)
                goto ERROR;
@@ -843,7 +843,7 @@ PAKFIRE_EXPORT PakfirePackage pakfire_repo_add_archive(PakfireRepo repo, Pakfire
 PAKFIRE_EXPORT int pakfire_repo_clean(PakfireRepo repo) {
        char cache_path[PATH_MAX];
 
-       int r = pakfire_make_cache_path(repo->pakfire, cache_path, sizeof(cache_path) - 1,
+       int r = pakfire_make_cache_path(repo->pakfire, cache_path,
                "%s", pakfire_repo_get_name(repo));
        if (r < 0)
                return r;