dbus-handler: Change type for comparison of identical types 50/315750/1
authorUnsung Lee <unsung.lee@samsung.com>
Tue, 3 Dec 2024 01:52:46 +0000 (10:52 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Wed, 4 Dec 2024 10:54:31 +0000 (19:54 +0900)
Change type of variable 'i' to size_t for comparison of idential types.
In this case, size_t (unsigned) has big max value than max value of int (signed).
Therefore, it can cause wrong result when performing comparison operation.
For example, 'for (int i = 0; i < size_t size; i++)' can cause overflow of 'i',
so it would result in infinite loops.

Change-Id: I9d06aca90908bc3320c82beaace6f365c9f2d710
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
src/common/ipc/dbus-handler.c

index e985ef34e1e1ddd3a1c38257cf83a13e9f488350..942788be7c7f47c7a91796b35be8cb579f391ced 100644 (file)
@@ -83,7 +83,7 @@ static void d_bus_method_handler(GDBusConnection *connection,
                GVariant *parameters, GDBusMethodInvocation *invocation,
                gpointer user_data)
 {
-       int i;
+       size_t i;
        struct d_bus_method_handle *handle;
        int name_len;
 
@@ -370,7 +370,7 @@ on_error:
 
 resourced_ret_c d_bus_register_signals(const struct d_bus_signal *signals, const size_t size)
 {
-       int i;
+       size_t i;
        int ret;
 
        for (i = 0; i < size; i++) {