Skip to contentSkip to conversation

input: for best practices, return -ENOMEM instead of -1 when returning on mem allocation errors

PATCH Applied Davidlohr Bueso 2 participants 3 messages Sep 23, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 input: for best practices, return -ENOMEM instead of -1 when returning on mem allocation errors

input: for best practices, return -ENOMEM instead of -1 when returning on mem allocation errors.

---
 drivers/input/misc/powermate.c   |    2 +-
 drivers/input/mouse/elantech.c   |    2 +-
 drivers/input/mouse/synaptics.c  |    2 +-
 drivers/input/mouse/trackpoint.c |    2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/input/misc/powermate.c +1 -1
index bf170f6..f459471 100644
@@ -280,7 +280,7 @@ static int powermate_alloc_buffers(struct usb_device *udev, struct powermate_dev
 
 	pm->configcr = kmalloc(sizeof(*(pm->configcr)), GFP_KERNEL);
 	if (!pm->configcr)
-		return -1;
+		return -ENOMEM;
 
 	return 0;
 }
drivers/input/mouse/elantech.c +1 -1
index 4831120..04d9bf3 100644
@@ -699,7 +699,7 @@ int elantech_init(struct psmouse *psmouse)
 
 	psmouse->private = etd = kzalloc(sizeof(struct elantech_data), GFP_KERNEL);
 	if (!etd)
-		return -1;
+		return -ENOMEM;
 
 	etd->parity[0] = 1;
 	for (i = 1; i < 256; i++)
drivers/input/mouse/synaptics.c +1 -1
index 96b70a4..a79bc36 100644
@@ -731,7 +731,7 @@ int synaptics_init(struct psmouse *psmouse)
 
 	psmouse->private = priv = kzalloc(sizeof(struct synaptics_data), GFP_KERNEL);
 	if (!priv)
-		return -1;
+		return -ENOMEM;
 
 	psmouse_reset(psmouse);
 
drivers/input/mouse/trackpoint.c +1 -1
index 0643e49..54b2fa8 100644
@@ -303,7 +303,7 @@ int trackpoint_detect(struct psmouse *psmouse, bool set_properties)
 
 	psmouse->private = kzalloc(sizeof(struct trackpoint_data), GFP_KERNEL);
 	if (!psmouse->private)
-		return -1;
+		return -ENOMEM;
 
 	psmouse->vendor = "IBM";
 	psmouse->name = "TrackPoint";
Signature · 1 line
1.7.0.4
maintainer Applied
#1 lore raw
Quoted 3 lines · Davidlohr Bueso

input: for best practices, return -ENOMEM instead of -1 when returning on mem allocation errors.

Applied, thank you Davidlohr.

FWIW there are more code in drivers/input/serio and drivers/input/mouse/ that return -1 instead of a proper error codes.

Signature · 1 line
Dmitry
#2 lore raw
Quoted 10 lines · Dmitry Torokhov
Quoted 3 lines · Davidlohr Bueso

input: for best practices, return -ENOMEM instead of -1 when returning on mem allocation errors.

Applied, thank you Davidlohr.

FWIW there are more code in drivers/input/serio and drivers/input/mouse/ that return -1 instead of a proper error codes.

Yes, I'll be preparing a patch shortly for those.

Thanks,
Davidlohr