]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: Set __attribute__((format(...))) wherever needed
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 9 Oct 2024 13:09:18 +0000 (13:09 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 9 Oct 2024 15:13:46 +0000 (15:13 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
17 files changed:
src/cli/lib/build.c
src/cli/lib/progressbar.c
src/libpakfire/cgroup.c
src/libpakfire/dist.c
src/libpakfire/httpclient.c
src/libpakfire/include/pakfire/config.h
src/libpakfire/include/pakfire/httpclient.h
src/libpakfire/include/pakfire/log_stream.h
src/libpakfire/include/pakfire/logging.h
src/libpakfire/include/pakfire/progress.h
src/libpakfire/include/pakfire/util.h
src/libpakfire/include/pakfire/xfer.h
src/libpakfire/jail.c
src/libpakfire/job.c
src/libpakfire/repo.c
src/libpakfire/transaction.c
src/libpakfire/xfer.c

index c5e070303ddf6fa0e7f4faabc9f1aa1b08799581..f01a76be35580c14199bbe8d26a9c6e76bbf00f6 100644 (file)
@@ -104,6 +104,10 @@ static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
        return 0;
 }
 
+static void log_callback(void* data, int priority, const char* file, int line,
+       const char* function, const char* format, va_list args)
+       __attribute__((format(printf, 6, 0)));
+
 static void log_callback(void* data, int priority, const char* file, int line,
                const char* function, const char* format, va_list args) {
        char* buffer = NULL;
index 76b5cc72267cd988f707f4be7de4741a148ead9d..bf2f083efe73ba5838eeb18ec2e4c699d20fa662 100644 (file)
@@ -298,6 +298,9 @@ static const char* cli_progressbar_string(struct cli_progressbar* p,
        return (const char*)data;
 }
 
+static int cli_progressbar_add_string(struct cli_progressbar* p, const char* format, ...)
+       __attribute__((format(printf, 2, 3)));
+
 static int cli_progressbar_add_string(struct cli_progressbar* p, const char* format, ...) {
        char* s = NULL;
        va_list args;
index 27b97c793dcbe080acc1ebfc3166508b10eaef63..a7e628b8be56810f76f00f51cf945464730b3120 100644 (file)
@@ -389,6 +389,9 @@ ERROR:
        return bytes_read;
 }
 
+static int pakfire_cgroup_write(struct pakfire_cgroup* cgroup,
+               const char* path, const char* format, ...) __attribute__((format(printf, 3, 4)));
+
 static int pakfire_cgroup_write(struct pakfire_cgroup* cgroup,
                const char* path, const char* format, ...) {
        va_list args;
index 59b21d241c2de2bdb5cac6beef5ac6968b0dc307..b92bb8288cf012621d84e280bffcbfe6cb413c9a 100644 (file)
@@ -290,7 +290,7 @@ static int pakfire_dist_download_source(struct pakfire_httpclient* httpclient,
                return 0;
 
        // Create a new transfer
-       r = pakfire_httpclient_create_xfer(&xfer, httpclient, filename);
+       r = pakfire_httpclient_create_xfer(&xfer, httpclient, "%s", filename);
        if (r)
                goto ERROR;
 
index 5c5862c434ad234a117194ff608319396fc86187..b7de1d1457b16d4cb9c76a461ac9ced0b75a7b12 100644 (file)
@@ -577,7 +577,7 @@ int pakfire_httpclient_run(struct pakfire_httpclient* client, const char* title)
        int r = 0;
 
        // Set the title
-       r = pakfire_progress_set_title(client->progress, title);
+       r = pakfire_progress_set_title(client->progress, "%s", title);
        if (r)
                return r;
 
index aeea5e7ef1686ae3050b23957c80c4bdd0a5c139..fd35545baf5959e1832f49ccc353c32f16d45f38 100644 (file)
@@ -34,7 +34,8 @@ struct pakfire_config* pakfire_config_unref(struct pakfire_config* config);
 int pakfire_config_set(struct pakfire_config* config,
        const char* section, const char* key, const char* value);
 int pakfire_config_set_format(struct pakfire_config* config,
-       const char* section, const char* key, const char* format, ...);
+       const char* section, const char* key, const char* format, ...)
+       __attribute__((format(printf, 4, 5)));
 
 const char* pakfire_config_get(struct pakfire_config* config,
        const char* section, const char* key, const char* _default);
index 9d2b3a0b8ac9ca746dff749b92dfee5ee13ef451..1d8f36b42bc31e36be1aa85409114d2e64b6782a 100644 (file)
@@ -45,7 +45,8 @@ const char* pakfire_httpclient_get_baseurl(struct pakfire_httpclient* client);
 int pakfire_httpclient_set_baseurl(struct pakfire_httpclient* client, const char* baseurl);
 
 int pakfire_httpclient_create_xfer(struct pakfire_xfer** xfer,
-       struct pakfire_httpclient* downloader, const char* url, ...);
+       struct pakfire_httpclient* downloader, const char* url, ...)
+       __attribute__((format(printf, 3, 4)));
 
 int pakfire_httpclient_enqueue_xfer(
        struct pakfire_httpclient* downloader, struct pakfire_xfer* xfer);
index b98ea08c70dbeaa32e0f3bc652e5cd0458c143a5..ca98ba95c6e3d69c6f886d18c43c8f72a4d039d4 100644 (file)
@@ -42,7 +42,8 @@ struct pakfire_log_stream* pakfire_log_stream_unref(struct pakfire_log_stream* s
 int pakfire_log_stream_in_parent(struct pakfire_log_stream* stream, sd_event* loop);
 int pakfire_log_stream_in_child(struct pakfire_log_stream* stream);
 
-int pakfire_log_stream_write(struct pakfire_log_stream* stream, const char* format, va_list args);
+int pakfire_log_stream_write(struct pakfire_log_stream* stream,
+       const char* format, va_list args) __attribute__((format(printf, 2, 0)));
 
 #endif /* PAKFIRE_PRIVATE */
 #endif /* PAKFIRE_LOG_STREAM_H */
index b85b00213c50e4bef1e98dec3696ff7422b47d6a..40ad6e51862e68ec72bc02da972dc7deb7ce675e 100644 (file)
@@ -27,9 +27,11 @@ typedef void (*pakfire_log_callback)(void* data, int priority, const char* file,
        int line, const char* fn, const char* format, va_list args);
 
 void pakfire_log_stderr(void* data, int priority, const char* file,
-       int line, const char* fn, const char* format, va_list args);
+       int line, const char* fn, const char* format, va_list args)
+       __attribute__((format(printf, 6, 0)));
 void pakfire_log_syslog(void* data, int priority, const char* file,
-       int line, const char* fn, const char* format, va_list args);
+       int line, const char* fn, const char* format, va_list args)
+       __attribute__((format(printf, 6, 0)));
 
 #ifdef PAKFIRE_PRIVATE
 
@@ -68,7 +70,7 @@ static inline void __attribute__((always_inline, format(printf, 2, 3)))
 
 // This function does absolutely nothing
 static inline void __attribute__((always_inline, format(printf, 2, 3)))
-       pakfire_log_null(struct pakfire_ctx* ctx, const char *format, ...) {}
+       pakfire_log_null(struct pakfire* pakfire, const char *format, ...) {}
 
 #ifdef ENABLE_DEBUG
 #      define PAKFIRE_DEBUG(pakfire, arg...) pakfire_log_condition(pakfire, LOG_DEBUG, ## arg)
index 60d1ce96afc52163eff108cfac5acffe1179fd77..76bf73cfd0d717dde6504224184cb2461832f463 100644 (file)
@@ -87,7 +87,8 @@ int pakfire_progress_update(struct pakfire_progress* p, unsigned long int value)
 int pakfire_progress_increment(struct pakfire_progress* p, unsigned long int value);
 int pakfire_progress_reset(struct pakfire_progress* p);
 
-int pakfire_progress_set_title(struct pakfire_progress* p, const char* format, ...);
+int pakfire_progress_set_title(struct pakfire_progress* p, const char* format, ...)
+       __attribute__((format(printf, 2, 3)));
 void pakfire_progress_set_max_value(struct pakfire_progress* p, unsigned long int value);
 
 #endif
index e8c61557cd9a42f55463754133827f32cef57dc7..779ec4fc6e81c2057ba7f58a325ecfb52bc2cd51 100644 (file)
@@ -64,7 +64,8 @@ int __pakfire_path_realpath(char* dest, const size_t length, const char* path);
 // File stuff
 
 int pakfire_file_write(struct pakfire* pakfire, const char* path,
-       uid_t owner, gid_t group, mode_t mode, const char* format, ...);
+       uid_t owner, gid_t group, mode_t mode, const char* format, ...)
+       __attribute__((format(printf, 6, 7)));
 
 int pakfire_touch(const char* path, mode_t mode);
 int pakfire_mkparentdir(const char* path, mode_t mode);
index 3ed5a2dc2113b4831ece1cb2a11d6d9b9f603c9a..80effd06fe86d568e0a4e4d24d625c7d0f5e3d40 100644 (file)
@@ -82,9 +82,11 @@ typedef enum pakfire_transfer_method {
 } pakfire_xfer_method_t;
 
 int pakfire_xfer_create(struct pakfire_xfer** transfer, struct pakfire_ctx* ctx,
-       struct pakfire_httpclient* httpclient, const char* url, ...);
+       struct pakfire_httpclient* httpclient, const char* url, ...)
+       __attribute__((format(printf, 4, 5)));
 int __pakfire_xfer_create(struct pakfire_xfer** xfer, struct pakfire_ctx* ctx,
-       struct pakfire_httpclient* client, const char* url, va_list args);
+       struct pakfire_httpclient* client, const char* url, va_list args)
+       __attribute__((format(printf, 4, 0)));
 
 struct pakfire_xfer* pakfire_xfer_ref(struct pakfire_xfer* xfer);
 struct pakfire_xfer* pakfire_xfer_unref(struct pakfire_xfer* xfer);
index b1ecc90e2e355dc8285851e44a5a570334923972..735fddb029df3fbd8af562802233e47e61575a1e 100644 (file)
@@ -469,6 +469,10 @@ PAKFIRE_EXPORT void pakfire_jail_set_stdout_callback(struct pakfire_jail* jail,
 
        All log messages will be sent to the parent process through their respective pipes.
 */
+
+static void pakfire_jail_log_redirect(void* data, int priority, const char* file,
+       int line, const char* fn, const char* format, va_list args) __attribute__((format(printf, 6, 0)));
+
 static void pakfire_jail_log_redirect(void* data, int priority, const char* file,
                int line, const char* fn, const char* format, va_list args) {
        struct pakfire_jail_exec* ctx = data;
index daa259ea60a59c5a90ea1bfc9f8fe3b550281851..1ae7d69e8bd86d388f30c87beb9cd4f1456a6b21 100644 (file)
@@ -389,6 +389,10 @@ static int pakfire_job_parent(struct pakfire_job* job) {
        return 0;
 }
 
+static void pakfire_job_log(void* data, int priority, const char* file,
+       int line, const char* fn, const char* format, va_list args)
+       __attribute__((format(printf, 6, 0)));
+
 static void pakfire_job_log(void* data, int priority, const char* file,
                int line, const char* fn, const char* format, va_list args) {
        struct pakfire_job* job = data;
index 36cd9dd58a9ff4f597364aa555235474a227ac05..108a07b86b509aa06c4487c5088caa2955905d14 100644 (file)
@@ -200,6 +200,10 @@ char* pakfire_repo_url_replace(struct pakfire_repo* repo, const char* url) {
 #define pakfire_repo_path(repo, path, format, ...) \
        __pakfire_repo_path(repo, path, sizeof(path), format, __VA_ARGS__)
 
+static int __pakfire_repo_path(struct pakfire_repo* repo,
+               char* path, const size_t length, const char* format, ...)
+               __attribute__((format(printf, 4, 5)));
+
 static int __pakfire_repo_path(struct pakfire_repo* repo,
                char* path, const size_t length, const char* format, ...) {
        char buffer[PATH_MAX];
@@ -236,7 +240,7 @@ static int pakfire_repo_create_xfer(struct pakfire_xfer** xfer,
        int r;
 
        // Create a new transfer
-       r = pakfire_httpclient_create_xfer(&x, httpclient, url);
+       r = pakfire_httpclient_create_xfer(&x, httpclient, "%s", url);
        if (r)
                goto ERROR;
 
@@ -1154,7 +1158,7 @@ PAKFIRE_EXPORT int pakfire_repo_write_config(struct pakfire_repo* repo, FILE* f)
                        goto ERROR;
                }
 
-               r = pakfire_config_set_format(config, section, "key", "%.*s", length, buffer);
+               r = pakfire_config_set_format(config, section, "key", "%.*s", (int)length, buffer);
                if (r) {
                        ERROR(repo->pakfire, "Could not set key: %m\n");
                        goto ERROR;
@@ -1301,7 +1305,7 @@ static int pakfire_repo_download(struct pakfire_repo* repo, const char* url,
                goto ERROR;
 
        // Create a new transfer
-       r = pakfire_httpclient_create_xfer(&xfer, httpclient, url);
+       r = pakfire_httpclient_create_xfer(&xfer, httpclient, "%s", url);
        if (r)
                goto ERROR;
 
index 18b9ccbd8c39cdf3825ca683229bf9baad70ba07..e2bc303a1f55addb26b276e9412aab7084805b7c 100644 (file)
@@ -382,6 +382,9 @@ static int pakfire_transaction_get_progress(struct pakfire_transaction* transact
        return transaction->progress * 100 / transaction->num;
 }
 
+static void pakfire_transaction_status(struct pakfire_transaction* transaction,
+       const char* message, ...) __attribute__((format(printf, 2, 3)));
+
 static void pakfire_transaction_status(struct pakfire_transaction* transaction,
                const char* message, ...) {
        char* buffer = NULL;
@@ -880,6 +883,9 @@ static ssize_t pakfire_transaction_downloadsize(struct pakfire_transaction* tran
        return size;
 }
 
+static int pakfire_transaction_append_line(char** s, const char* format, ...)
+       __attribute__((format(printf, 2, 3)));
+
 static int pakfire_transaction_append_line(char** s, const char* format, ...) {
        va_list args;
        int r;
index 67385fbd394cd175b8d0108f69e46b3c4e7ea79b..c9de59b94560e2684afdbcf48f7988369fa2f3f7 100644 (file)
@@ -1338,7 +1338,7 @@ static int pakfire_xfer_prepare_progress(struct pakfire_xfer* xfer,
        // Set the title
        title = pakfire_xfer_get_title(xfer);
        if (title) {
-               r = pakfire_progress_set_title(xfer->progress, title);
+               r = pakfire_progress_set_title(xfer->progress, "%s", title);
                if (r)
                        return r;
        }