summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2011-11-10 14:02:56 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2011-11-10 14:06:49 +0100
commite33d0bf36819fdf9d14bf61cb770862f735cdba3 (patch)
tree810f2754de70e20c1f316df4d920be7fb26077b8
parentaa5af56943ff177c0260a2d1a0a9b835d9547997 (diff)
downloadpjctl-e33d0bf36819fdf9d14bf61cb770862f735cdba3.tar.gz
pjctl-e33d0bf36819fdf9d14bf61cb770862f735cdba3.tar.bz2
pjctl-e33d0bf36819fdf9d14bf61cb770862f735cdba3.zip
Replace g_strdup_printf with asprintf
-rw-r--r--src/pjctl.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/pjctl.c b/src/pjctl.c
index f4f38c7..a64e78e 100644
--- a/src/pjctl.c
+++ b/src/pjctl.c
@@ -18,6 +18,7 @@
*/
#define _POSIX_C_SOURCE 1
+#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
@@ -176,7 +177,7 @@ handle_data(struct pjctl *pjctl, char *data, int len)
cmd->response_func(pjctl, &data[PJLINK_COMMAND],
&data[PJLINK_PARAMETER]);
- g_free(cmd->command);
+ free(cmd->command);
g_free(cmd);
send_next_cmd(pjctl);
@@ -243,7 +244,8 @@ power(struct pjctl *pjctl, char **argv, int argc)
return -1;
}
- cmd->command = g_strdup_printf("%%1POWR %c\r", on ? '1' : '0');
+ if (asprintf(&cmd->command, "%%1POWR %c\r", on ? '1' : '0') < 0)
+ return -1;
cmd->response_func = power_response;
pjctl->queue = g_list_append(pjctl->queue, cmd);
@@ -297,7 +299,8 @@ source(struct pjctl *pjctl, char **argv, int argc)
num = '1';
}
- cmd->command = g_strdup_printf("%%1INPT %d%c\r", type, num);
+ if (asprintf(&cmd->command, "%%1INPT %d%c\r", type, num) < 0)
+ return -1;
cmd->response_func = source_response;
pjctl->queue = g_list_append(pjctl->queue, cmd);
@@ -361,7 +364,8 @@ avmute(struct pjctl *pjctl, char **argv, int argc)
return -1;
}
- cmd->command = g_strdup_printf("%%1AVMT %d%d\r", type, on);
+ if (asprintf(&cmd->command, "%%1AVMT %d%d\r", type, on) < 0)
+ return -1;
cmd->response_func = avmute_response;
pjctl->queue = g_list_append(pjctl->queue, cmd);
@@ -501,7 +505,8 @@ status(struct pjctl *pjctl, char **argv, int argc)
cmd = g_memdup(&cmds[i], sizeof *cmd);
if (!cmd)
return -1;
- cmd->command = g_strdup_printf("%%1%s ?\r", cmd->command);
+ if (asprintf(&cmd->command, "%%1%s ?\r", cmds[i].command) < 0)
+ return -1;
pjctl->queue = g_list_append(pjctl->queue, cmd);
}