aboutsummaryrefslogtreecommitdiff
path: root/sway/swaynag.c
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-02-28 16:43:05 +0100
committerSimon Ser <contact@emersion.fr>2023-04-14 18:34:54 +0200
commit08c1946d71039e583696842c3558b337aede1cbf (patch)
tree3873db2edfb31146bd6cd17dae63f068aef34f05 /sway/swaynag.c
parentac8962eb626a8c715241ae91646f2d1bfcb61533 (diff)
Use format_str() throughout
Diffstat (limited to 'sway/swaynag.c')
-rw-r--r--sway/swaynag.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/sway/swaynag.c b/sway/swaynag.c
index 4a0a6d30..6031174d 100644
--- a/sway/swaynag.c
+++ b/sway/swaynag.c
@@ -145,22 +145,16 @@ void swaynag_log(const char *swaynag_command, struct swaynag_instance *swaynag,
va_list args;
va_start(args, fmt);
- size_t length = vsnprintf(NULL, 0, fmt, args) + 1;
+ char *str = vformat_str(fmt, args);
va_end(args);
-
- char *temp = malloc(length + 1);
- if (!temp) {
+ if (!str) {
sway_log(SWAY_ERROR, "Failed to allocate buffer for swaynag log entry.");
return;
}
- va_start(args, fmt);
- vsnprintf(temp, length, fmt, args);
- va_end(args);
-
- write(swaynag->fd[1], temp, length);
+ write(swaynag->fd[1], str, strlen(str));
- free(temp);
+ free(str);
}
void swaynag_show(struct swaynag_instance *swaynag) {