macro: Change type for comparison of identical types 40/315740/1
authorUnsung Lee <unsung.lee@samsung.com>
Wed, 4 Dec 2024 05:54:34 +0000 (14:54 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Wed, 4 Dec 2024 05:54:45 +0000 (14:54 +0900)
Change type of index 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.

Change-Id: I518fba876d71e245f176acb00c060546e5e6a53a
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
src/common/macro.h

index 8f1d2abd7ab1323e3dfcd8a444f5ff8814463a67..0375092bc684e670fe1d722e9cbc40dbf1b943b8 100644 (file)
        do { \
                char _filtered_type [strlen(type) + 1]; \
                int _index_copy = 0; \
-               for (int _index_original = 0; _index_original < sizeof _filtered_type - 1; ++_index_original) \
+               for (size_t _index_original = 0; _index_original < sizeof _filtered_type - 1; ++_index_original) \
                        if (type[_index_original] != '&') \
                                _filtered_type[_index_copy++] = type[_index_original]; \
                _filtered_type[_index_copy] = '\0'; \