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>
This commit is contained in:
Alan Coopersmith 2011-12-12 16:49:34 -08:00
parent 5bc590bde2
commit ff64ad6c74

View File

@ -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);
}