summaryrefslogtreecommitdiff
path: root/hw/kdrive
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2011-12-12 16:49:34 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2011-12-12 17:03:11 -0800
commitff64ad6c74a3e14ca34bacb8866bdbd2262bddff (patch)
treea4c201ed409ada2d96af1c757831593e7794b465 /hw/kdrive
parent5bc590bde23ce1c57015b1d9e1cc63189c37448e (diff)
Convert KdDoSwitchCmd to use asprintf instead of malloc/strcat/etc.
Also fix the reason argument to be const char * to clear several gcc warnings of: kdrive.c:151:2: warning: passing argument 1 of 'KdDoSwitchCmd' discards qualifiers from pointer target type kdrive.c:116:1: note: expected 'char *' but argument is of type 'const char *' Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'hw/kdrive')
-rw-r--r--hw/kdrive/src/kdrive.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index 8dd039e1d..2c649409e 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -113,19 +113,14 @@ KdDisableScreen (ScreenPtr pScreen)
}
static void
-KdDoSwitchCmd (char *reason)
+KdDoSwitchCmd (const char *reason)
{
if (kdSwitchCmd)
{
- char *command = malloc(strlen (kdSwitchCmd) +
- 1 +
- strlen (reason) +
- 1);
- if (!command)
+ char *command;
+
+ if (asprintf(&command, "%s %s", kdSwitchCmd, reason) == -1)
return;
- strcpy (command, kdSwitchCmd);
- strcat (command, " ");
- strcat (command, reason);
system (command);
free(command);
}