summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2010-12-23 15:53:32 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2011-01-05 23:26:49 -0800
commitcc1a2ba8c9aa3a4bed25394c981b41c903502c84 (patch)
tree259461066a4b43d619cc312eb33ca35cb69b08a8
parentbd099b5a87399d6ff1fd324172bfcc4bc07a362b (diff)
downloadxorg-driver-xf86-input-keyboard-cc1a2ba8c9aa3a4bed25394c981b41c903502c84.tar.gz
sun_kbd: Replace deprecated xfree/xcalloc with free & calloc
Also greatly simplified option/pointer handling to avoid generating new warnings from passing const char * pointers to free() Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/sun_kbd.c30
1 files changed, 9 insertions, 21 deletions
diff --git a/src/sun_kbd.c b/src/sun_kbd.c
index 86b8f97..4dcd01b 100644
--- a/src/sun_kbd.c
+++ b/src/sun_kbd.c
@@ -489,35 +489,23 @@ ReadInput(InputInfoPtr pInfo)
static Bool
OpenKeyboard(InputInfoPtr pInfo)
{
- const char *kbdPath = NULL;
- const char *defaultKbd = "/dev/kbd";
-
- if (pInfo->options != NULL) {
- kbdPath = xf86SetStrOption(pInfo->options, "Device", NULL);
- }
- if (kbdPath == NULL) {
- kbdPath = defaultKbd;
- }
+ char *kbdPath = xf86SetStrOption(pInfo->options, "Device", "/dev/kbd");
+ Bool ret;
pInfo->fd = open(kbdPath, O_RDONLY | O_NONBLOCK);
if (pInfo->fd == -1) {
- xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", pInfo->name, kbdPath);
+ xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", pInfo->name, kbdPath);
+ ret = FALSE;
} else {
xf86MsgVerb(X_INFO, 3, "%s: Opened device \"%s\"\n", pInfo->name,
kbdPath);
- }
-
- if ((kbdPath != NULL) && (kbdPath != defaultKbd)) {
- xfree(kbdPath);
- }
-
- if (pInfo->fd == -1) {
- return FALSE;
- } else {
pInfo->read_input = ReadInput;
- return TRUE;
+ ret = TRUE;
}
+
+ free(kbdPath);
+ return ret;
}
_X_EXPORT Bool
@@ -540,7 +528,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;