Skip to content

Commit 7aeb9f2

Browse files
committed
Fix size_t/int mixup and mark unused variables
1 parent 444f4d7 commit 7aeb9f2

21 files changed

+246
-130
lines changed

src/dbus.c

Lines changed: 74 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ void dbus_cb_fdn_methods(GDBusConnection *connection,
169169
GDBusMethodInvocation *invocation,
170170
gpointer user_data)
171171
{
172+
(void)object_path;
173+
(void)interface_name;
174+
(void)user_data;
172175

173176
struct dbus_method *m = bsearch(method_name,
174177
methods_fdn,
@@ -225,6 +228,9 @@ void dbus_cb_dunst_methods(GDBusConnection *connection,
225228
GDBusMethodInvocation *invocation,
226229
gpointer user_data)
227230
{
231+
(void)object_path;
232+
(void)interface_name;
233+
(void)user_data;
228234

229235
struct dbus_method *m = bsearch(method_name,
230236
methods_dunst,
@@ -236,8 +242,7 @@ void dbus_cb_dunst_methods(GDBusConnection *connection,
236242
m->method(connection, sender, parameters, invocation);
237243
} else {
238244
LOG_M("Unknown method name: '%s' (sender: '%s').",
239-
method_name,
240-
sender);
245+
method_name, sender);
241246
}
242247
}
243248

@@ -246,6 +251,9 @@ static void dbus_cb_dunst_ContextMenuCall(GDBusConnection *connection,
246251
GVariant *parameters,
247252
GDBusMethodInvocation *invocation)
248253
{
254+
(void)sender;
255+
(void)parameters;
256+
249257
LOG_D("CMD: Calling context menu");
250258
context_menu();
251259

@@ -258,6 +266,8 @@ static void dbus_cb_dunst_NotificationAction(GDBusConnection *connection,
258266
GVariant *parameters,
259267
GDBusMethodInvocation *invocation)
260268
{
269+
(void)sender;
270+
261271
guint32 notification_nr = 0;
262272
g_variant_get(parameters, "(u)", &notification_nr);
263273

@@ -288,6 +298,9 @@ static void dbus_cb_dunst_NotificationClearHistory(GDBusConnection *connection,
288298
GVariant *parameters,
289299
GDBusMethodInvocation *invocation)
290300
{
301+
(void)sender;
302+
(void)parameters;
303+
291304
LOG_D("CMD: Clearing the history");
292305
queues_history_clear();
293306
wake_up();
@@ -301,6 +314,9 @@ static void dbus_cb_dunst_NotificationCloseAll(GDBusConnection *connection,
301314
GVariant *parameters,
302315
GDBusMethodInvocation *invocation)
303316
{
317+
(void)sender;
318+
(void)parameters;
319+
304320
LOG_D("CMD: Pushing all to history");
305321
queues_history_push_all();
306322
wake_up();
@@ -314,6 +330,9 @@ static void dbus_cb_dunst_NotificationCloseLast(GDBusConnection *connection,
314330
GVariant *parameters,
315331
GDBusMethodInvocation *invocation)
316332
{
333+
(void)sender;
334+
(void)parameters;
335+
317336
LOG_D("CMD: Closing last notification");
318337
const GList *list = queues_get_displayed();
319338
if (list && list->data) {
@@ -331,6 +350,9 @@ static void dbus_cb_dunst_NotificationShow(GDBusConnection *connection,
331350
GVariant *parameters,
332351
GDBusMethodInvocation *invocation)
333352
{
353+
(void)sender;
354+
(void)parameters;
355+
334356
LOG_D("CMD: Showing last notification from history");
335357
queues_history_pop();
336358
wake_up();
@@ -344,6 +366,9 @@ static void dbus_cb_dunst_NotificationListHistory(GDBusConnection *connection,
344366
GVariant *parameters,
345367
GDBusMethodInvocation *invocation)
346368
{
369+
(void)sender;
370+
(void)parameters;
371+
347372
LOG_D("CMD: Listing all notifications from history");
348373

349374
GVariantBuilder builder;
@@ -396,6 +421,9 @@ static void dbus_cb_dunst_NotificationPopHistory(GDBusConnection *connection,
396421
GVariant *parameters,
397422
GDBusMethodInvocation *invocation)
398423
{
424+
(void)sender;
425+
(void)parameters;
426+
399427
LOG_D("CMD: Popping notification from history");
400428

401429
guint32 id;
@@ -413,6 +441,9 @@ static void dbus_cb_dunst_NotificationRemoveFromHistory(GDBusConnection *connect
413441
GVariant *parameters,
414442
GDBusMethodInvocation *invocation)
415443
{
444+
(void)sender;
445+
(void)parameters;
446+
416447
LOG_D("CMD: Removing notification from history");
417448

418449
guint32 id;
@@ -450,7 +481,7 @@ static void gradient_entry(const struct gradient *grad, GVariantDict *dict, cons
450481
}
451482

452483
char **strv = g_malloc((grad->length + 1) * sizeof(char *));
453-
for (int i = 0; i < grad->length; i++) {
484+
for (size_t i = 0; i < grad->length; i++) {
454485
char buf[10];
455486
if (color_to_string(grad->colors[i], buf))
456487
strv[i] = g_strdup(buf);
@@ -466,6 +497,9 @@ static void dbus_cb_dunst_RuleList(GDBusConnection *connection,
466497
GVariant *parameters,
467498
GDBusMethodInvocation *invocation)
468499
{
500+
(void)sender;
501+
(void)parameters;
502+
469503
LOG_D("CMD: Listing all configured rules");
470504

471505
GVariantBuilder builder;
@@ -589,6 +623,9 @@ static void dbus_cb_dunst_RuleEnable(GDBusConnection *connection,
589623
GVariant *parameters,
590624
GDBusMethodInvocation *invocation)
591625
{
626+
(void)sender;
627+
(void)parameters;
628+
592629
// dbus param state: 0 → disable, 1 → enable, 2 → toggle.
593630

594631
int state = 0;
@@ -634,6 +671,8 @@ static void dbus_cb_dunst_ConfigReload(GDBusConnection *connection,
634671
GVariant *parameters,
635672
GDBusMethodInvocation *invocation)
636673
{
674+
(void)sender;
675+
637676
gchar **configs = NULL;
638677
g_variant_get(parameters, "(^as)", &configs);
639678
reload(configs);
@@ -649,6 +688,9 @@ static void dbus_cb_dunst_Ping(GDBusConnection *connection,
649688
GVariant *parameters,
650689
GDBusMethodInvocation *invocation)
651690
{
691+
(void)sender;
692+
(void)parameters;
693+
652694
g_dbus_method_invocation_return_value(invocation, NULL);
653695
g_dbus_connection_flush(connection, NULL, NULL, NULL);
654696
}
@@ -660,6 +702,9 @@ static void dbus_cb_GetCapabilities(
660702
GVariant *parameters,
661703
GDBusMethodInvocation *invocation)
662704
{
705+
(void)sender;
706+
(void)parameters;
707+
663708
GVariantBuilder *builder;
664709
GVariant *value;
665710

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

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

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

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

904949
void signal_length_propertieschanged(void)
905950
{
906-
907951
static unsigned int last_displayed = 0;
908952
static unsigned int last_history = 0;
909953
static unsigned int last_waiting = 0;
@@ -1005,6 +1049,8 @@ static void dbus_cb_CloseNotification(
10051049
GVariant *parameters,
10061050
GDBusMethodInvocation *invocation)
10071051
{
1052+
(void)sender;
1053+
10081054
guint32 id;
10091055
g_variant_get(parameters, "(u)", &id);
10101056
if (settings.ignore_dbusclose) {
@@ -1029,6 +1075,9 @@ static void dbus_cb_GetServerInformation(
10291075
GVariant *parameters,
10301076
GDBusMethodInvocation *invocation)
10311077
{
1078+
(void)sender;
1079+
(void)parameters;
1080+
10321081
GVariant *answer = g_variant_new("(ssss)", "dunst", "knopwob", VERSION, "1.2");
10331082

10341083
g_dbus_method_invocation_return_value(invocation, answer);
@@ -1127,6 +1176,12 @@ GVariant *dbus_cb_dunst_Properties_Get(GDBusConnection *connection,
11271176
GError **error,
11281177
gpointer user_data)
11291178
{
1179+
(void)connection;
1180+
(void)sender;
1181+
(void)object_path;
1182+
(void)interface_name;
1183+
(void)user_data;
1184+
11301185
struct dunst_status status = dunst_status_get();
11311186

11321187
if (STR_EQ(property_name, "paused")) {
@@ -1158,6 +1213,9 @@ gboolean dbus_cb_dunst_Properties_Set(GDBusConnection *connection,
11581213
GError **error,
11591214
gpointer user_data)
11601215
{
1216+
(void)sender;
1217+
(void)user_data;
1218+
11611219
int targetPauseLevel = -1;
11621220
if (STR_EQ(property_name, "paused")) {
11631221
if (g_variant_get_boolean(value)) {
@@ -1207,7 +1265,7 @@ gboolean dbus_cb_dunst_Properties_Set(GDBusConnection *connection,
12071265

12081266

12091267
static const GDBusInterfaceVTable interface_vtable_fdn = {
1210-
dbus_cb_fdn_methods
1268+
dbus_cb_fdn_methods,
12111269
};
12121270

12131271
static const GDBusInterfaceVTable interface_vtable_dunst = {
@@ -1220,6 +1278,9 @@ static void dbus_cb_bus_acquired(GDBusConnection *connection,
12201278
const gchar *name,
12211279
gpointer user_data)
12221280
{
1281+
(void)name;
1282+
(void)user_data;
1283+
12231284
GError *err = NULL;
12241285
if(!g_dbus_connection_register_object(
12251286
connection,
@@ -1248,6 +1309,8 @@ static void dbus_cb_name_acquired(GDBusConnection *connection,
12481309
const gchar *name,
12491310
gpointer user_data)
12501311
{
1312+
(void)user_data;
1313+
12511314
// If we're not able to get org.fd.N bus, we've still got a problem
12521315
if (STR_EQ(name, FDN_NAME))
12531316
dbus_conn = connection;
@@ -1371,6 +1434,9 @@ static void dbus_cb_name_lost(GDBusConnection *connection,
13711434
const gchar *name,
13721435
gpointer user_data)
13731436
{
1437+
(void)name;
1438+
(void)user_data;
1439+
13741440
if (connection) {
13751441
char *name;
13761442
unsigned int pid;

src/draw.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void gradient_pattern(struct gradient *grad)
110110
grad->colors[0].a);
111111
} else {
112112
grad->pattern = cairo_pattern_create_linear(0, 0, 1, 0);
113-
for (int i = 0; i < grad->length; i++) {
113+
for (size_t i = 0; i < grad->length; i++) {
114114
double offset = i / (double)(grad->length - 1);
115115
cairo_pattern_add_color_stop_rgba(grad->pattern,
116116
offset,
@@ -129,7 +129,7 @@ char *gradient_to_string(const struct gradient *grad)
129129
int max = grad->length * 11 + 1;
130130
char *buf = g_malloc(max);
131131

132-
for (int i = 0, j = 0; i < grad->length; i++) {
132+
for (size_t i = 0, j = 0; i < grad->length; i++) {
133133
j += g_snprintf(buf + j, max - j, "#%02x%02x%02x%02x",
134134
(int)(grad->colors[i].r * 255),
135135
(int)(grad->colors[i].g * 255),

src/dunst.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ static gboolean run(void *data)
179179

180180
gboolean pause_signal(gpointer data)
181181
{
182+
(void)data;
183+
182184
dunst_status_int(S_PAUSE_LEVEL, MAX_PAUSE_LEVEL);
183185
wake_up();
184186

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

188190
gboolean unpause_signal(gpointer data)
189191
{
192+
(void)data;
193+
190194
dunst_status_int(S_PAUSE_LEVEL, 0);
191195
wake_up();
192196

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

196200
gboolean quit_signal(gpointer data)
197201
{
202+
(void)data;
198203
g_main_loop_quit(mainloop);
199204

200205
return G_SOURCE_CONTINUE;

src/icon-lookup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ void get_theme_path(void) {
168168

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

182-
for (int i = 0; i < theme_path->len; i++) {
182+
for (size_t i = 0; i < theme_path->len; i++) {
183183
int theme_index = load_icon_theme_from_dir(theme_path->pdata[i], name);
184184
if (theme_index != -1)
185185
return theme_index;

src/icon.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,12 @@ char *get_path_from_icon_name(const char *iconname, int size)
268268
return path;
269269
}
270270

271+
static void icon_destroy(guchar *pixels, gpointer data)
272+
{
273+
(void)data;
274+
g_free(pixels);
275+
}
276+
271277
GdkPixbuf *icon_get_for_data(GVariant *data, char **id, double dpi_scale, int min_size, int max_size)
272278
{
273279
ASSERT_OR_RET(data, NULL);
@@ -351,7 +357,7 @@ GdkPixbuf *icon_get_for_data(GVariant *data, char **id, double dpi_scale, int mi
351357
width,
352358
height,
353359
rowstride,
354-
(GdkPixbufDestroyNotify) g_free,
360+
icon_destroy,
355361
data_pb);
356362
if (!pixbuf) {
357363
/* Dear user, I'm sorry, I'd like to give you a more specific

src/log.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ static void dunst_log_handler(
7474
const gchar *message,
7575
gpointer testing)
7676
{
77+
(void)log_domain;
78+
7779
if (testing)
7880
log_level = G_LOG_LEVEL_ERROR;
7981

src/markup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ static bool markup_is_entity(const char *str)
273273
return (cur == end);
274274
} else {
275275
const char *supported_tags[] = {"&amp;", "&lt;", "&gt;", "&quot;", "&apos;"};
276-
for (int i = 0; i < sizeof(supported_tags)/sizeof(*supported_tags); i++) {
276+
for (size_t i = 0; i < sizeof(supported_tags)/sizeof(*supported_tags); i++) {
277277
if (g_str_has_prefix(str, supported_tags[i]))
278278
return true;
279279
}

0 commit comments

Comments
 (0)