aboutsummaryrefslogtreecommitdiffstats
path: root/swaynag/swaynag.c
diff options
context:
space:
mode:
authorLibravatar Nihal Jere <nihal@nihaljere.xyz>2022-02-25 11:40:04 -0600
committerLibravatar Simon Zeni <simon@bl4ckb0ne.ca>2022-02-28 11:24:13 -0500
commit061ffc30ea899c3ed77004065d3958f19e3bb884 (patch)
tree5e1874ef52852964732b2552671d0171623b1543 /swaynag/swaynag.c
parentDon't enter seatop_move_floating when fullscreen (diff)
downloadsway-061ffc30ea899c3ed77004065d3958f19e3bb884.tar.gz
sway-061ffc30ea899c3ed77004065d3958f19e3bb884.tar.zst
sway-061ffc30ea899c3ed77004065d3958f19e3bb884.zip
swaynag: die on all allocation failures
Diffstat (limited to 'swaynag/swaynag.c')
-rw-r--r--swaynag/swaynag.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/swaynag/swaynag.c b/swaynag/swaynag.c
index 23d23f38..60ae3e8f 100644
--- a/swaynag/swaynag.c
+++ b/swaynag/swaynag.c
@@ -30,6 +30,10 @@ static bool terminal_execute(char *terminal, char *command) {
30 chmod(fname, S_IRUSR | S_IWUSR | S_IXUSR); 30 chmod(fname, S_IRUSR | S_IWUSR | S_IXUSR);
31 size_t cmd_size = strlen(terminal) + strlen(" -e ") + strlen(fname) + 1; 31 size_t cmd_size = strlen(terminal) + strlen(" -e ") + strlen(fname) + 1;
32 char *cmd = malloc(cmd_size); 32 char *cmd = malloc(cmd_size);
33 if (!cmd) {
34 perror("malloc");
35 return false;
36 }
33 snprintf(cmd, cmd_size, "%s -e %s", terminal, fname); 37 snprintf(cmd, cmd_size, "%s -e %s", terminal, fname);
34 execlp("sh", "sh", "-c", cmd, NULL); 38 execlp("sh", "sh", "-c", cmd, NULL);
35 sway_log_errno(SWAY_ERROR, "Failed to run command, execlp() returned."); 39 sway_log_errno(SWAY_ERROR, "Failed to run command, execlp() returned.");
@@ -340,6 +344,7 @@ static void handle_global(void *data, struct wl_registry *registry,
340 struct swaynag_seat *seat = 344 struct swaynag_seat *seat =
341 calloc(1, sizeof(struct swaynag_seat)); 345 calloc(1, sizeof(struct swaynag_seat));
342 if (!seat) { 346 if (!seat) {
347 perror("calloc");
343 return; 348 return;
344 } 349 }
345 350
@@ -357,6 +362,10 @@ static void handle_global(void *data, struct wl_registry *registry,
357 if (!swaynag->output) { 362 if (!swaynag->output) {
358 struct swaynag_output *output = 363 struct swaynag_output *output =
359 calloc(1, sizeof(struct swaynag_output)); 364 calloc(1, sizeof(struct swaynag_output));
365 if (!output) {
366 perror("calloc");
367 return;
368 }
360 output->wl_output = wl_registry_bind(registry, name, 369 output->wl_output = wl_registry_bind(registry, name,
361 &wl_output_interface, 4); 370 &wl_output_interface, 4);
362 output->wl_name = name; 371 output->wl_name = name;