Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some warnings (gint formatting, size_t/int mix, etc) #1424

Merged
merged 3 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 74 additions & 8 deletions src/dbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ void dbus_cb_fdn_methods(GDBusConnection *connection,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
(void)object_path;
(void)interface_name;
(void)user_data;

struct dbus_method *m = bsearch(method_name,
methods_fdn,
Expand Down Expand Up @@ -225,6 +228,9 @@ void dbus_cb_dunst_methods(GDBusConnection *connection,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
(void)object_path;
(void)interface_name;
(void)user_data;

struct dbus_method *m = bsearch(method_name,
methods_dunst,
Expand All @@ -236,8 +242,7 @@ void dbus_cb_dunst_methods(GDBusConnection *connection,
m->method(connection, sender, parameters, invocation);
} else {
LOG_M("Unknown method name: '%s' (sender: '%s').",
method_name,
sender);
method_name, sender);
}
}

Expand All @@ -246,6 +251,9 @@ static void dbus_cb_dunst_ContextMenuCall(GDBusConnection *connection,
GVariant *parameters,
GDBusMethodInvocation *invocation)
{
(void)sender;
(void)parameters;

LOG_D("CMD: Calling context menu");
context_menu();

Expand All @@ -258,6 +266,8 @@ static void dbus_cb_dunst_NotificationAction(GDBusConnection *connection,
GVariant *parameters,
GDBusMethodInvocation *invocation)
{
(void)sender;

guint32 notification_nr = 0;
g_variant_get(parameters, "(u)", &notification_nr);

Expand Down Expand Up @@ -288,6 +298,9 @@ static void dbus_cb_dunst_NotificationClearHistory(GDBusConnection *connection,
GVariant *parameters,
GDBusMethodInvocation *invocation)
{
(void)sender;
(void)parameters;

LOG_D("CMD: Clearing the history");
queues_history_clear();
wake_up();
Expand All @@ -301,6 +314,9 @@ static void dbus_cb_dunst_NotificationCloseAll(GDBusConnection *connection,
GVariant *parameters,
GDBusMethodInvocation *invocation)
{
(void)sender;
(void)parameters;

LOG_D("CMD: Pushing all to history");
queues_history_push_all();
wake_up();
Expand All @@ -314,6 +330,9 @@ static void dbus_cb_dunst_NotificationCloseLast(GDBusConnection *connection,
GVariant *parameters,
GDBusMethodInvocation *invocation)
{
(void)sender;
(void)parameters;

LOG_D("CMD: Closing last notification");
const GList *list = queues_get_displayed();
if (list && list->data) {
Expand All @@ -331,6 +350,9 @@ static void dbus_cb_dunst_NotificationShow(GDBusConnection *connection,
GVariant *parameters,
GDBusMethodInvocation *invocation)
{
(void)sender;
(void)parameters;

LOG_D("CMD: Showing last notification from history");
queues_history_pop();
wake_up();
Expand All @@ -344,6 +366,9 @@ static void dbus_cb_dunst_NotificationListHistory(GDBusConnection *connection,
GVariant *parameters,
GDBusMethodInvocation *invocation)
{
(void)sender;
(void)parameters;

LOG_D("CMD: Listing all notifications from history");

GVariantBuilder builder;
Expand Down Expand Up @@ -396,6 +421,9 @@ static void dbus_cb_dunst_NotificationPopHistory(GDBusConnection *connection,
GVariant *parameters,
GDBusMethodInvocation *invocation)
{
(void)sender;
(void)parameters;

LOG_D("CMD: Popping notification from history");

guint32 id;
Expand All @@ -413,6 +441,9 @@ static void dbus_cb_dunst_NotificationRemoveFromHistory(GDBusConnection *connect
GVariant *parameters,
GDBusMethodInvocation *invocation)
{
(void)sender;
(void)parameters;

LOG_D("CMD: Removing notification from history");

guint32 id;
Expand Down Expand Up @@ -450,7 +481,7 @@ static void gradient_entry(const struct gradient *grad, GVariantDict *dict, cons
}

char **strv = g_malloc((grad->length + 1) * sizeof(char *));
for (int i = 0; i < grad->length; i++) {
for (size_t i = 0; i < grad->length; i++) {
char buf[10];
if (color_to_string(grad->colors[i], buf))
strv[i] = g_strdup(buf);
Expand All @@ -466,6 +497,9 @@ static void dbus_cb_dunst_RuleList(GDBusConnection *connection,
GVariant *parameters,
GDBusMethodInvocation *invocation)
{
(void)sender;
(void)parameters;

LOG_D("CMD: Listing all configured rules");

GVariantBuilder builder;
Expand Down Expand Up @@ -589,6 +623,9 @@ static void dbus_cb_dunst_RuleEnable(GDBusConnection *connection,
GVariant *parameters,
GDBusMethodInvocation *invocation)
{
(void)sender;
(void)parameters;

// dbus param state: 0 → disable, 1 → enable, 2 → toggle.

int state = 0;
Expand Down Expand Up @@ -634,6 +671,8 @@ static void dbus_cb_dunst_ConfigReload(GDBusConnection *connection,
GVariant *parameters,
GDBusMethodInvocation *invocation)
{
(void)sender;

gchar **configs = NULL;
g_variant_get(parameters, "(^as)", &configs);
reload(configs);
Expand All @@ -649,6 +688,9 @@ static void dbus_cb_dunst_Ping(GDBusConnection *connection,
GVariant *parameters,
GDBusMethodInvocation *invocation)
{
(void)sender;
(void)parameters;

g_dbus_method_invocation_return_value(invocation, NULL);
g_dbus_connection_flush(connection, NULL, NULL, NULL);
}
Expand All @@ -660,6 +702,9 @@ static void dbus_cb_GetCapabilities(
GVariant *parameters,
GDBusMethodInvocation *invocation)
{
(void)sender;
(void)parameters;

GVariantBuilder *builder;
GVariant *value;

Expand All @@ -669,7 +714,7 @@ static void dbus_cb_GetCapabilities(
g_variant_builder_add(builder, "s", "body-hyperlinks");
g_variant_builder_add(builder, "s", "icon-static");

for (int i = 0; i < sizeof(stack_tag_hints)/sizeof(*stack_tag_hints); ++i)
for (size_t i = 0; i < sizeof(stack_tag_hints)/sizeof(*stack_tag_hints); ++i)
g_variant_builder_add(builder, "s", stack_tag_hints[i]);

// Since markup isn't a global variable anymore, look it up in the
Expand Down Expand Up @@ -761,7 +806,7 @@ static struct notification *dbus_message_to_notification(const gchar *sender, GV
*
* Only accept to first one we find.
*/
for (int i = 0; i < sizeof(stack_tag_hints)/sizeof(*stack_tag_hints); ++i) {
for (size_t i = 0; i < sizeof(stack_tag_hints)/sizeof(*stack_tag_hints); ++i) {
if ((dict_value = g_variant_lookup_value(hints, stack_tag_hints[i], G_VARIANT_TYPE_STRING))) {
n->stack_tag = g_variant_dup_string(dict_value, NULL);
g_variant_unref(dict_value);
Expand Down Expand Up @@ -862,7 +907,7 @@ static struct notification *dbus_message_to_notification(const gchar *sender, GV
size_t length = g_strv_length(cols);
struct gradient *grad = gradient_alloc(length);

for (int i = 0; i < length; i++) {
for (size_t i = 0; i < length; i++) {
if (!string_parse_color(cols[i], &grad->colors[i])) {
g_free(grad);
goto end;
Expand Down Expand Up @@ -903,7 +948,6 @@ static struct notification *dbus_message_to_notification(const gchar *sender, GV

void signal_length_propertieschanged(void)
{

static unsigned int last_displayed = 0;
static unsigned int last_history = 0;
static unsigned int last_waiting = 0;
Expand Down Expand Up @@ -1005,6 +1049,8 @@ static void dbus_cb_CloseNotification(
GVariant *parameters,
GDBusMethodInvocation *invocation)
{
(void)sender;

guint32 id;
g_variant_get(parameters, "(u)", &id);
if (settings.ignore_dbusclose) {
Expand All @@ -1029,6 +1075,9 @@ static void dbus_cb_GetServerInformation(
GVariant *parameters,
GDBusMethodInvocation *invocation)
{
(void)sender;
(void)parameters;

GVariant *answer = g_variant_new("(ssss)", "dunst", "knopwob", VERSION, "1.2");

g_dbus_method_invocation_return_value(invocation, answer);
Expand Down Expand Up @@ -1127,6 +1176,12 @@ GVariant *dbus_cb_dunst_Properties_Get(GDBusConnection *connection,
GError **error,
gpointer user_data)
{
(void)connection;
(void)sender;
(void)object_path;
(void)interface_name;
(void)user_data;

struct dunst_status status = dunst_status_get();

if (STR_EQ(property_name, "paused")) {
Expand Down Expand Up @@ -1158,6 +1213,9 @@ gboolean dbus_cb_dunst_Properties_Set(GDBusConnection *connection,
GError **error,
gpointer user_data)
{
(void)sender;
(void)user_data;

int targetPauseLevel = -1;
if (STR_EQ(property_name, "paused")) {
if (g_variant_get_boolean(value)) {
Expand Down Expand Up @@ -1207,7 +1265,7 @@ gboolean dbus_cb_dunst_Properties_Set(GDBusConnection *connection,


static const GDBusInterfaceVTable interface_vtable_fdn = {
dbus_cb_fdn_methods
dbus_cb_fdn_methods,
};

static const GDBusInterfaceVTable interface_vtable_dunst = {
Expand All @@ -1220,6 +1278,9 @@ static void dbus_cb_bus_acquired(GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
(void)name;
(void)user_data;

GError *err = NULL;
if(!g_dbus_connection_register_object(
connection,
Expand Down Expand Up @@ -1248,6 +1309,8 @@ static void dbus_cb_name_acquired(GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
(void)user_data;

// If we're not able to get org.fd.N bus, we've still got a problem
if (STR_EQ(name, FDN_NAME))
dbus_conn = connection;
Expand Down Expand Up @@ -1371,6 +1434,9 @@ static void dbus_cb_name_lost(GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
(void)name;
(void)user_data;

if (connection) {
char *name;
unsigned int pid;
Expand Down
4 changes: 2 additions & 2 deletions src/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void gradient_pattern(struct gradient *grad)
grad->colors[0].a);
} else {
grad->pattern = cairo_pattern_create_linear(0, 0, 1, 0);
for (int i = 0; i < grad->length; i++) {
for (size_t i = 0; i < grad->length; i++) {
double offset = i / (double)(grad->length - 1);
cairo_pattern_add_color_stop_rgba(grad->pattern,
offset,
Expand All @@ -129,7 +129,7 @@ char *gradient_to_string(const struct gradient *grad)
int max = grad->length * 11 + 1;
char *buf = g_malloc(max);

for (int i = 0, j = 0; i < grad->length; i++) {
for (size_t i = 0, j = 0; i < grad->length; i++) {
j += g_snprintf(buf + j, max - j, "#%02x%02x%02x%02x",
(int)(grad->colors[i].r * 255),
(int)(grad->colors[i].g * 255),
Expand Down
7 changes: 6 additions & 1 deletion src/dunst.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ static gboolean run(void *data)
gint64 sleep = timeout_at - now;
sleep = MAX(sleep, 1000); // Sleep at least 1ms

LOG_D("Sleeping for %li ms", sleep/1000);
LOG_D("Sleeping for %"G_GINT64_FORMAT" ms", sleep/1000);

next_timeout_id = g_timeout_add(sleep/1000, run, NULL);
}
Expand All @@ -179,6 +179,8 @@ static gboolean run(void *data)

gboolean pause_signal(gpointer data)
{
(void)data;

dunst_status_int(S_PAUSE_LEVEL, MAX_PAUSE_LEVEL);
wake_up();

Expand All @@ -187,6 +189,8 @@ gboolean pause_signal(gpointer data)

gboolean unpause_signal(gpointer data)
{
(void)data;

dunst_status_int(S_PAUSE_LEVEL, 0);
wake_up();

Expand All @@ -195,6 +199,7 @@ gboolean unpause_signal(gpointer data)

gboolean quit_signal(gpointer data)
{
(void)data;
g_main_loop_quit(mainloop);

return G_SOURCE_CONTINUE;
Expand Down
4 changes: 2 additions & 2 deletions src/icon-lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ void get_theme_path(void) {

add_paths_from_env(theme_path, "XDG_DATA_DIRS", "icons", "/usr/local/share/:/usr/share/");
g_ptr_array_add(theme_path, g_strdup("/usr/share/pixmaps"));
for (int i = 0; i < theme_path->len; i++) {
for (size_t i = 0; i < theme_path->len; i++) {
LOG_D("Theme locations: %s", (char*)theme_path->pdata[i]);
}
}
Expand All @@ -179,7 +179,7 @@ int load_icon_theme(char *name) {
get_theme_path();
}

for (int i = 0; i < theme_path->len; i++) {
for (size_t i = 0; i < theme_path->len; i++) {
int theme_index = load_icon_theme_from_dir(theme_path->pdata[i], name);
if (theme_index != -1)
return theme_index;
Expand Down
8 changes: 7 additions & 1 deletion src/icon.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,12 @@ char *get_path_from_icon_name(const char *iconname, int size)
return path;
}

static void icon_destroy(guchar *pixels, gpointer data)
{
(void)data;
g_free(pixels);
}

GdkPixbuf *icon_get_for_data(GVariant *data, char **id, double dpi_scale, int min_size, int max_size)
{
ASSERT_OR_RET(data, NULL);
Expand Down Expand Up @@ -351,7 +357,7 @@ GdkPixbuf *icon_get_for_data(GVariant *data, char **id, double dpi_scale, int mi
width,
height,
rowstride,
(GdkPixbufDestroyNotify) g_free,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fwsmit I replaced this g_free with an actual function taking two arguments since it just seemed wrong. Was this supposed to free both the pixels and data_pb?

icon_destroy,
data_pb);
if (!pixbuf) {
/* Dear user, I'm sorry, I'd like to give you a more specific
Expand Down
2 changes: 2 additions & 0 deletions src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ static void dunst_log_handler(
const gchar *message,
gpointer testing)
{
(void)log_domain;

if (testing)
log_level = G_LOG_LEVEL_ERROR;

Expand Down
Loading
Loading