[PATCH 09/12] libusbg: Return suitable error codes instead of -1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Krzysztof Opasiak <k.opasiak@xxxxxxxxxxx>
---
 src/usbg.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/usbg.c b/src/usbg.c
index cd2179e..4d74a0d 100644
--- a/src/usbg.c
+++ b/src/usbg.c
@@ -316,18 +316,15 @@ static int usbg_lookup_function_type(const char *name)
 	int max = sizeof(function_names)/sizeof(char *);
 
 	if (!name)
-		return -1;
+		return USBG_ERROR_INVALID_PARAM;
 
 	do {
 		if (!strcmp(name, function_names[i]))
-			break;
+			return i;
 		i++;
 	} while (i != max);
 
-	if (i == max)
-		i = -1;
-
-	return i;
+	return USBG_ERROR_NOT_FOUND;
 }
 
 const const char *usbg_get_function_type_str(usbg_function_type type)
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux