Skip to content

Commit cb96624

Browse files
committed
Fix OpenBSD support and clean code (clang -Wformat errors)
1 parent caa5770 commit cb96624

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

src/notification.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ void notification_print(const struct notification *n)
6161
printf("\ticon_id: '%s'\n", STR_NN(n->icon_id));
6262
printf("\tdesktop_entry: '%s'\n", n->desktop_entry ? n->desktop_entry : "");
6363
printf("\tcategory: %s\n", STR_NN(n->category));
64-
printf("\ttimeout: %ld\n", n->timeout/1000);
65-
printf("\tstart: %ld\n", n->start);
66-
printf("\ttimestamp: %ld\n", n->timestamp);
64+
printf("\ttimeout: %lld\n", n->timeout/1000);
65+
printf("\tstart: %lld\n", n->start);
66+
printf("\ttimestamp: %lld\n", n->timestamp);
6767
printf("\turgency: %s\n", notification_urgency_to_string(n->urgency));
6868
printf("\ttransient: %d\n", n->transient);
6969
printf("\tformatted: '%s'\n", STR_NN(n->msg));
@@ -144,8 +144,8 @@ void notification_run_script(struct notification *n)
144144
// Set environment variables
145145
gchar *n_id_str = g_strdup_printf("%i", n->id);
146146
gchar *n_progress_str = g_strdup_printf("%i", n->progress);
147-
gchar *n_timeout_str = g_strdup_printf("%li", n->timeout/1000);
148-
gchar *n_timestamp_str = g_strdup_printf("%li", n->timestamp / 1000);
147+
gchar *n_timeout_str = g_strdup_printf("%lli", n->timeout/1000);
148+
gchar *n_timestamp_str = g_strdup_printf("%lli", n->timestamp / 1000);
149149
safe_setenv("DUNST_APP_NAME", appname);
150150
safe_setenv("DUNST_SUMMARY", summary);
151151
safe_setenv("DUNST_BODY", body);
@@ -713,14 +713,14 @@ void notification_update_text_to_render(struct notification *n)
713713
char *new_buf;
714714
if (hours > 0) {
715715
new_buf =
716-
g_strdup_printf("%s (%ldh %ldm %lds old)", buf, hours,
716+
g_strdup_printf("%s (%lldh %lldm %llds old)", buf, hours,
717717
minutes, seconds);
718718
} else if (minutes > 0) {
719719
new_buf =
720-
g_strdup_printf("%s (%ldm %lds old)", buf, minutes,
720+
g_strdup_printf("%s (%lldm %llds old)", buf, minutes,
721721
seconds);
722722
} else {
723-
new_buf = g_strdup_printf("%s (%lds old)", buf, seconds);
723+
new_buf = g_strdup_printf("%s (%llds old)", buf, seconds);
724724
}
725725

726726
g_free(buf);

src/rules.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,12 @@ void rule_print(const struct rule *r)
139139
if (r->msg_urgency != URG_NONE) printf("\tmsg_urgency: '%s'\n", notification_urgency_to_string(r->msg_urgency));
140140
if (r->stack_tag != NULL) printf("\tstack_tag: '%s'\n", r->stack_tag);
141141
if (r->desktop_entry != NULL) printf("\tdesktop_entry: '%s'\n", r->desktop_entry);
142-
if (r->match_dbus_timeout != -1) printf("\tmatch_dbus_timeout: %ld\n", r->match_dbus_timeout);
142+
if (r->match_dbus_timeout != -1) printf("\tmatch_dbus_timeout: %lld\n", r->match_dbus_timeout);
143143
if (r->match_transient != -1) printf("\tmatch_transient: %d\n", r->match_transient);
144144

145145
// modifiers
146-
if (r->timeout != -1) printf("\ttimeout: %ld\n", r->timeout);
147-
if (r->override_dbus_timeout != -1) printf("\toverride_dbus_timeout: %ld\n", r->override_dbus_timeout);
146+
if (r->timeout != -1) printf("\ttimeout: %lld\n", r->timeout);
147+
if (r->override_dbus_timeout != -1) printf("\toverride_dbus_timeout: %lld\n", r->override_dbus_timeout);
148148
if (r->markup != -1) printf("\tmarkup: %d\n", r->markup);
149149
if (r->action_name != NULL) printf("\taction_name: '%s'\n", r->action_name);
150150
if (r->urgency != URG_NONE) printf("\turgency: '%s'\n", notification_urgency_to_string(r->urgency));

src/utils.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
#include <sys/stat.h>
1414
#include <time.h>
1515
#include <unistd.h>
16+
#ifndef __OpenBSD__
1617
#include <wordexp.h>
18+
#endif
1719

1820
#include "log.h"
1921
#include "settings_data.h"
@@ -180,6 +182,7 @@ int string_array_length(char **s)
180182
/* see utils.h */
181183
char *string_to_path(char *string)
182184
{
185+
#ifndef __OpenBSD__
183186
ASSERT_OR_RET(string, string);
184187

185188
wordexp_t we;
@@ -208,6 +211,15 @@ char *string_to_path(char *string)
208211
wordfree(&we);
209212

210213
return res;
214+
#else
215+
if (string && STRN_EQ(string, "~/", 2)) {
216+
char *home = g_strconcat(user_get_home(), "/", NULL);
217+
string = string_replace_at(string, 0, 2, home);
218+
g_free(home);
219+
}
220+
221+
return string;
222+
#endif
211223
}
212224

213225
/* see utils.h */

0 commit comments

Comments
 (0)