aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2014-02-23 11:19:39 +0100
committerPaul Kocialkowski <contact@paulk.fr>2014-02-23 11:19:39 +0100
commit121ae6d21c18dd79ed1dc7df4c86a681d70a337a (patch)
tree2283270e9681cbd589c6f61e0ac28eb2cb9e8d33
parent420519cbbaf40fb2af8295f8eb7a80d281b0933d (diff)
downloadexternal_libsamsung-ipc-121ae6d21c18dd79ed1dc7df4c86a681d70a337a.zip
external_libsamsung-ipc-121ae6d21c18dd79ed1dc7df4c86a681d70a337a.tar.gz
external_libsamsung-ipc-121ae6d21c18dd79ed1dc7df4c86a681d70a337a.tar.bz2
ipc_devices: Proper type for count and index
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r--samsung-ipc/ipc.c13
-rw-r--r--samsung-ipc/ipc_devices.c3
-rw-r--r--samsung-ipc/ipc_devices.h2
3 files changed, 12 insertions, 6 deletions
diff --git a/samsung-ipc/ipc.c b/samsung-ipc/ipc.c
index a8cacf0..5a5de3e 100644
--- a/samsung-ipc/ipc.c
+++ b/samsung-ipc/ipc.c
@@ -104,7 +104,7 @@ int ipc_device_detect(void)
kernel_version = strdup(utsname.release);
#endif
- for (i = 0; i < ipc_devices_count; i++) {
+ for (i = 0; i < (int) ipc_devices_count; i++) {
// Eliminate index if the name doesn't match
if (name != NULL && ipc_devices[i].name != NULL && strcmp(name, ipc_devices[i].name) != 0)
continue;
@@ -147,13 +147,18 @@ complete:
struct ipc_client *ipc_client_create(int type)
{
struct ipc_client *client = NULL;
- int device_index;
+ unsigned int device_index;
+ int rc;
if (type < 0 || type > IPC_CLIENT_TYPE_RFS)
return NULL;
- device_index = ipc_device_detect();
- if (device_index < 0 || device_index > ipc_devices_count)
+ rc = ipc_device_detect();
+ if (rc < 0)
+ goto error;
+
+ device_index = (unsigned int) rc;
+ if (device_index > ipc_devices_count)
goto error;
client = (struct ipc_client *) calloc(1, sizeof(struct ipc_client));
diff --git a/samsung-ipc/ipc_devices.c b/samsung-ipc/ipc_devices.c
index ee97f77..fc2c226 100644
--- a/samsung-ipc/ipc_devices.c
+++ b/samsung-ipc/ipc_devices.c
@@ -136,6 +136,7 @@ struct ipc_device_desc ipc_devices[] = {
},
};
-int ipc_devices_count = sizeof(ipc_devices) / sizeof(struct ipc_device_desc);
+unsigned int ipc_devices_count = sizeof(ipc_devices) /
+ sizeof(struct ipc_device_desc);
// vim:ts=4:sw=4:expandtab
diff --git a/samsung-ipc/ipc_devices.h b/samsung-ipc/ipc_devices.h
index 36058c9..c5e3fcd 100644
--- a/samsung-ipc/ipc_devices.h
+++ b/samsung-ipc/ipc_devices.h
@@ -44,7 +44,7 @@ struct ipc_device_desc {
};
extern struct ipc_device_desc ipc_devices[];
-extern int ipc_devices_count;
+extern unsigned int ipc_devices_count;
#endif