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

Alan Coopersmith alan.coopersmith at oracle.com
Thu Dec 23 16:00:33 PST 2010


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";
 
     pInfo->fd = open(kbdPath, O_RDONLY | O_NONBLOCK);
     
@@ -508,9 +506,7 @@ OpenKeyboard(InputInfoPtr pInfo)
 		    kbdPath);
     }
     
-    if ((kbdPath != NULL) && (kbdPath != defaultKbd)) {
-	xfree(kbdPath);
-    }
+    free(deviceOption);
 
     if (pInfo->fd == -1) {
 	return FALSE;
@@ -540,7 +536,7 @@ xf86OSKbdPreInit(InputInfoPtr pInfo)
 
     pKbd->CustomKeycodes = FALSE;
 
-    pKbd->private = xcalloc(sizeof(sunKbdPrivRec), 1);
+    pKbd->private = calloc(sizeof(sunKbdPrivRec), 1);
     if (pKbd->private == NULL) {
        xf86Msg(X_ERROR,"can't allocate keyboard OS private data\n");
        return FALSE;
-- 
1.7.3.2



More information about the xorg-devel mailing list