[PATCH:xf86-input-keyboard] sun_kbd: Replace deprecated xfree/xcalloc with free & calloc

Julien Cristau jcristau at debian.org
Thu Dec 23 16:20:29 PST 2010


On Thu, Dec 23, 2010 at 16:00:33 -0800, Alan Coopersmith wrote:

> Reworked char * pointers to avoid introducing new warnings of:
> sun_kbd.c:512: warning: passing arg 1 of `free' discards qualifiers from pointer target type
> 
> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
> ---
>  src/sun_kbd.c |   14 +++++---------
>  1 files changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/src/sun_kbd.c b/src/sun_kbd.c
> index 86b8f97..01743ff 100644
> --- a/src/sun_kbd.c
> +++ b/src/sun_kbd.c
> @@ -489,15 +489,13 @@ ReadInput(InputInfoPtr pInfo)
>  static Bool
>  OpenKeyboard(InputInfoPtr pInfo)
>  {
> +    char *deviceOption = NULL;
>      const char *kbdPath = NULL;
> -    const char *defaultKbd = "/dev/kbd";
>  
>      if (pInfo->options != NULL) {
> -	kbdPath = xf86SetStrOption(pInfo->options, "Device", NULL);
> -    }
> -    if (kbdPath == NULL) {
> -        kbdPath = defaultKbd;
> +	deviceOption = xf86SetStrOption(pInfo->options, "Device", NULL);
>      }
> +    kbdPath = (deviceOption != NULL) ? deviceOption : "/dev/kbd";

can't this whole thing be replaced with

        kbdPath = xf86SetStrOption(pInfo->options, "Device", "/dev/kbd")

?

AFAICT it should handle a NULL pInfo->options fine (returning the
default).  Not tested though.

Cheers,
Julien


More information about the xorg-devel mailing list