From bfd7064a40cfcc419b2c4a9b79c58f1262e8dbf1 Mon Sep 17 00:00:00 2001 From: Jabber Developer Date: Tue, 24 Jun 2025 23:56:25 +0200 Subject: [PATCH 1/3] build: add missing includes to header files This change adds necessary `#include` directives that were previously omitted in some header files. Without these includes, compilation could fail or produce undefined behavior when the headers are used in isolation (i.e., before their dependencies are included elsewhere). Ensures better modularity and reliability of header usage. --- src/event/common.h | 2 ++ src/pgp/gpg.h | 2 ++ src/tools/bookmark_ignore.h | 6 ++++-- src/ui/titlebar.h | 2 ++ src/xmpp/blocking.h | 2 ++ src/xmpp/iq.h | 2 ++ src/xmpp/ox.h | 2 ++ src/xmpp/roster.h | 3 +++ src/xmpp/vcard_funcs.h | 1 + 9 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/event/common.h b/src/event/common.h index 177fd912..edf7850c 100644 --- a/src/event/common.h +++ b/src/event/common.h @@ -10,6 +10,8 @@ #ifndef EVENT_COMMON_H #define EVENT_COMMON_H +#include "glib.h" + void ev_disconnect_cleanup(void); void ev_inc_connection_counter(void); void ev_reset_connection_counter(void); diff --git a/src/pgp/gpg.h b/src/pgp/gpg.h index 7651e719..0ad19607 100644 --- a/src/pgp/gpg.h +++ b/src/pgp/gpg.h @@ -10,6 +10,8 @@ #ifndef PGP_GPG_H #define PGP_GPG_H +#include "glib.h" + typedef struct pgp_key_t { gchar* id; diff --git a/src/tools/bookmark_ignore.h b/src/tools/bookmark_ignore.h index cba61ce0..b5720ec0 100644 --- a/src/tools/bookmark_ignore.h +++ b/src/tools/bookmark_ignore.h @@ -10,8 +10,10 @@ #ifndef BOOKMARK_IGNORE_H #define BOOKMARK_IGNORE_H -void bookmark_ignore_on_connect(const char* const barejid); -void bookmark_ignore_on_disconnect(void); +#include "xmpp/xmpp.h" + +void bookmark_ignore_on_connect(); +void bookmark_ignore_on_disconnect(); gboolean bookmark_ignored(Bookmark* bookmark); gchar** bookmark_ignore_list(gsize* len); void bookmark_ignore_add(const char* const barejid); diff --git a/src/ui/titlebar.h b/src/ui/titlebar.h index 69f92e1e..81a74cbe 100644 --- a/src/ui/titlebar.h +++ b/src/ui/titlebar.h @@ -10,6 +10,8 @@ #ifndef UI_TITLEBAR_H #define UI_TITLEBAR_H +#include "glib.h" + void create_title_bar(void); void free_title_bar(void); void title_bar_update_virtual(void); diff --git a/src/xmpp/blocking.h b/src/xmpp/blocking.h index 7f0df5b4..b72c7fb0 100644 --- a/src/xmpp/blocking.h +++ b/src/xmpp/blocking.h @@ -10,6 +10,8 @@ #ifndef XMPP_BLOCKING_H #define XMPP_BLOCKING_H +#include + void blocking_request(void); int blocked_set_handler(xmpp_stanza_t* stanza); int reporting_set_handler(xmpp_stanza_t* stanza); diff --git a/src/xmpp/iq.h b/src/xmpp/iq.h index 546e1912..2a5fd81b 100644 --- a/src/xmpp/iq.h +++ b/src/xmpp/iq.h @@ -10,6 +10,8 @@ #ifndef XMPP_IQ_H #define XMPP_IQ_H +#include + typedef int (*ProfIqCallback)(xmpp_stanza_t* const stanza, void* const userdata); typedef void (*ProfIqFreeCallback)(void* userdata); diff --git a/src/xmpp/ox.h b/src/xmpp/ox.h index b17bd894..a671b948 100644 --- a/src/xmpp/ox.h +++ b/src/xmpp/ox.h @@ -7,6 +7,8 @@ * SPDX-License-Identifier: GPL-3.0-or-later WITH OpenSSL-exception */ +#include "glib.h" + /*! * \page OX OX Implementation * diff --git a/src/xmpp/roster.h b/src/xmpp/roster.h index 7e561f55..77711c95 100644 --- a/src/xmpp/roster.h +++ b/src/xmpp/roster.h @@ -10,6 +10,9 @@ #ifndef XMPP_ROSTER_H #define XMPP_ROSTER_H +#include "glib.h" +#include + void roster_request(void); void roster_set_handler(xmpp_stanza_t* const stanza); void roster_result_handler(xmpp_stanza_t* const stanza); diff --git a/src/xmpp/vcard_funcs.h b/src/xmpp/vcard_funcs.h index 6951ecce..03a5e30f 100644 --- a/src/xmpp/vcard_funcs.h +++ b/src/xmpp/vcard_funcs.h @@ -12,6 +12,7 @@ #include "ui/win_types.h" #include "xmpp/vcard.h" +#include vCard* vcard_new(); void vcard_free(vCard* vcard); -- 2.49.1 From 57d79ecf9c6b0e014533a642677aaa367349d9c9 Mon Sep 17 00:00:00 2001 From: Jabber Developer Date: Wed, 25 Jun 2025 00:13:42 +0200 Subject: [PATCH 2/3] fix: add missing parameter types to function declarations Some functions were declared without parameters in header files, despite their implementations specifying arguments. This mismatch is deprecated in all versions of C and is disallowed in C23. This change updates the declarations to match their definitions, ensuring compatibility with C standards, avoiding potential undefined behavior, and improving support in tools and editors. --- src/tools/bookmark_ignore.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/bookmark_ignore.h b/src/tools/bookmark_ignore.h index b5720ec0..092c96c4 100644 --- a/src/tools/bookmark_ignore.h +++ b/src/tools/bookmark_ignore.h @@ -12,7 +12,7 @@ #include "xmpp/xmpp.h" -void bookmark_ignore_on_connect(); +void bookmark_ignore_on_connect(const char* const barejid); void bookmark_ignore_on_disconnect(); gboolean bookmark_ignored(Bookmark* bookmark); gchar** bookmark_ignore_list(gsize* len); -- 2.49.1 From 5b45b35b3ec91a5c39a217ffee5613b559673e96 Mon Sep 17 00:00:00 2001 From: Jabber Developer Date: Wed, 25 Jun 2025 00:23:08 +0200 Subject: [PATCH 3/3] refactor: rename argument to avoid C++ keyword conflict The parameter `template` in format_call_external_argv() was renamed to `template_fmt` to avoid collision with the `template` keyword in C++. This improves compatibility when the header is included in C++ code. --- src/common.c | 14 +++++++------- src/common.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/common.c b/src/common.c index 4b64b597..6a0e24fa 100644 --- a/src/common.c +++ b/src/common.c @@ -748,17 +748,17 @@ call_external(gchar** argv) * * This function constructs an argument vector (argv) based on the provided template string, replacing placeholders ("%u" and "%p") with the provided URL and filename, respectively. * - * @param template The template string with placeholders. - * @param url The URL to replace "%u" (or NULL to skip). - * @param filename The filename to replace "%p" (or NULL to skip). - * @return The constructed argument vector (argv) as a null-terminated array of strings. + * @param template_fmt The template string with placeholders. + * @param url The URL to replace "%u" (or NULL to skip). + * @param filename The filename to replace "%p" (or NULL to skip). + * @return The constructed argument vector (argv) as a null-terminated array of strings. * * @note Remember to free the returned argument vector using `auto_gcharv` or `g_strfreev()`. */ gchar** -format_call_external_argv(const char* template, const char* url, const char* filename) +format_call_external_argv(const char* template_fmt, const char* url, const char* filename) { - gchar** argv = g_strsplit(template, " ", 0); + gchar** argv = g_strsplit(template_fmt, " ", 0); guint num_args = 0; while (argv[num_args]) { @@ -767,7 +767,7 @@ format_call_external_argv(const char* template, const char* url, const char* fil argv[num_args] = g_strdup(url); } else if (0 == g_strcmp0(argv[num_args], "%p") && filename != NULL) { g_free(argv[num_args]); - argv[num_args] = strdup(filename); + argv[num_args] = g_strdup(filename); } num_args++; } diff --git a/src/common.h b/src/common.h index cb3155e4..40c68d60 100644 --- a/src/common.h +++ b/src/common.h @@ -181,7 +181,7 @@ void get_file_paths_recursive(const char* directory, GSList** contents); gchar* get_random_string(int length); gboolean call_external(gchar** argv); -gchar** format_call_external_argv(const char* template, const char* url, const char* filename); +gchar** format_call_external_argv(const char* template_fmt, const char* url, const char* filename); gchar* unique_filename_from_url(const char* url, const char* path); gchar* get_expanded_path(const char* path); -- 2.49.1