diff options
-rw-r--r-- | samsung-ipc/ipc.c | 13 | ||||
-rw-r--r-- | samsung-ipc/ipc_devices.c | 3 | ||||
-rw-r--r-- | samsung-ipc/ipc_devices.h | 2 |
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 |