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:
parent
5bc590bde2
commit
ff64ad6c74
|
@ -113,19 +113,14 @@ KdDisableScreen (ScreenPtr pScreen)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
KdDoSwitchCmd (char *reason)
|
KdDoSwitchCmd (const char *reason)
|
||||||
{
|
{
|
||||||
if (kdSwitchCmd)
|
if (kdSwitchCmd)
|
||||||
{
|
{
|
||||||
char *command = malloc(strlen (kdSwitchCmd) +
|
char *command;
|
||||||
1 +
|
|
||||||
strlen (reason) +
|
if (asprintf(&command, "%s %s", kdSwitchCmd, reason) == -1)
|
||||||
1);
|
|
||||||
if (!command)
|
|
||||||
return;
|
return;
|
||||||
strcpy (command, kdSwitchCmd);
|
|
||||||
strcat (command, " ");
|
|
||||||
strcat (command, reason);
|
|
||||||
system (command);
|
system (command);
|
||||||
free(command);
|
free(command);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue