Skip to content

Commit 24d7143

Browse files
pflgalak
authored andcommitted
all: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values when computing and comparing against unsigned variables. Signed-off-by: Patrik Flykt <[email protected]>
1 parent caebf20 commit 24d7143

File tree

559 files changed

+2331
-2328
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

559 files changed

+2331
-2328
lines changed

arch/arc/core/cache.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static void dcache_flush_mlines(u32_t start_addr, u32_t size)
9191
u32_t end_addr;
9292
unsigned int key;
9393

94-
if (!dcache_available() || (size == 0)) {
94+
if (!dcache_available() || (size == 0U)) {
9595
return;
9696
}
9797

@@ -150,9 +150,9 @@ static void init_dcache_line_size(void)
150150
u32_t val;
151151

152152
val = z_arc_v2_aux_reg_read(_ARC_V2_D_CACHE_BUILD);
153-
__ASSERT((val&0xff) != 0, "d-cache is not present");
153+
__ASSERT((val&0xff) != 0U, "d-cache is not present");
154154
val = ((val>>16) & 0xf) + 1;
155-
val *= 16;
155+
val *= 16U;
156156
sys_cache_line_size = (size_t) val;
157157
}
158158
#endif

arch/arc/core/fault.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void _Fault(NANO_ESF *esf)
7777
* stack check and mpu violation can come out together, then
7878
* parameter = 0x2 | [0x4 | 0x8 | 0x1]
7979
*/
80-
if (vector == 6 && parameter & 0x2) {
80+
if (vector == 6U && parameter & 0x2) {
8181
z_NanoFatalErrorHandler(_NANO_ERR_STACK_CHK_FAIL, esf);
8282
return;
8383
}

arch/arc/core/mpu/arc_mpu_v2_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ static inline int _mpu_configure(u8_t type, u32_t base, u32_t size)
159159

160160
LOG_DBG("Region info: 0x%x 0x%x", base, size);
161161

162-
if (region_attr == 0 || region_index < 0) {
162+
if (region_attr == 0U || region_index < 0) {
163163
return -EINVAL;
164164
}
165165

arch/arc/core/mpu/arc_mpu_v3_internal.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ static void _mpu_reset_dynamic_regions(void)
320320
_region_init(i, 0, 0, 0);
321321
}
322322

323-
for (i = 0; i < dynamic_regions_num; i++) {
323+
for (i = 0U; i < dynamic_regions_num; i++) {
324324
_region_init(
325325
dyn_reg_info[i].index,
326326
dyn_reg_info[i].base,
@@ -389,7 +389,7 @@ void arc_core_mpu_configure_thread(struct k_thread *thread)
389389
_mpu_reset_dynamic_regions();
390390
#if defined(CONFIG_MPU_STACK_GUARD)
391391
#if defined(CONFIG_USERSPACE)
392-
if ((thread->base.user_options & K_USER) != 0) {
392+
if ((thread->base.user_options & K_USER) != 0U) {
393393
/* the areas before and after the user stack of thread is
394394
* kernel only. These area can be used as stack guard.
395395
* -----------------------
@@ -448,7 +448,7 @@ void arc_core_mpu_configure_thread(struct k_thread *thread)
448448
num_partitions = mem_domain->num_partitions;
449449
pparts = mem_domain->partitions;
450450
} else {
451-
num_partitions = 0;
451+
num_partitions = 0U;
452452
pparts = NULL;
453453
}
454454

arch/arc/include/v2/cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static ALWAYS_INLINE void _icache_setup(void)
4444

4545
val = z_arc_v2_aux_reg_read(_ARC_V2_I_CACHE_BUILD);
4646
val &= 0xff;
47-
if (val != 0) { /* is i-cache present? */
47+
if (val != 0U) { /* is i-cache present? */
4848
/* configure i-cache */
4949
z_arc_v2_aux_reg_write(_ARC_V2_IC_CTRL, icache_config);
5050
}

arch/arm/core/cortex_m/mpu/arm_mpu_v7_internal.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ static int _mpu_partition_is_valid(const struct k_mem_partition *part)
5252
* partition must align with size.
5353
*/
5454
int partition_is_valid =
55-
((part->size & (part->size - 1)) == 0)
55+
((part->size & (part->size - 1)) == 0U)
5656
&&
5757
(part->size >= CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE)
5858
&&
59-
((part->start & (part->size - 1)) == 0);
59+
((part->start & (part->size - 1)) == 0U);
6060

6161
return partition_is_valid;
6262
}
@@ -72,7 +72,7 @@ static int _mpu_partition_is_valid(const struct k_mem_partition *part)
7272
static inline u32_t _size_to_mpu_rasr_size(u32_t size)
7373
{
7474
/* The minimal supported region size is 32 bytes */
75-
if (size <= 32) {
75+
if (size <= 32U) {
7676
return REGION_32B;
7777
}
7878

@@ -264,7 +264,7 @@ static int _mpu_configure_regions(const struct k_mem_partition
264264
int reg_index = start_reg_index;
265265

266266
for (i = 0; i < regions_num; i++) {
267-
if (regions[i]->size == 0) {
267+
if (regions[i]->size == 0U) {
268268
continue;
269269
}
270270
/* Non-empty region. */

arch/arm/core/cortex_m/mpu/arm_mpu_v8_internal.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static int _mpu_partition_is_valid(const struct k_mem_partition *part)
101101
== part->size)
102102
&&
103103
((part->start &
104-
(CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE - 1)) == 0);
104+
(CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE - 1)) == 0U);
105105

106106
return partition_is_valid;
107107
}
@@ -330,7 +330,7 @@ static int _mpu_configure_regions(const struct k_mem_partition
330330
int reg_index = start_reg_index;
331331

332332
for (i = 0; i < regions_num; i++) {
333-
if (regions[i]->size == 0) {
333+
if (regions[i]->size == 0U) {
334334
continue;
335335
}
336336
/* Non-empty region. */
@@ -493,7 +493,7 @@ static int _mpu_mark_areas_for_dynamic_regions(
493493
* which dynamic memory regions may be programmed at run-time.
494494
*/
495495
for (int i = 0; i < dyn_region_areas_num; i++) {
496-
if (dyn_region_areas[i].size == 0) {
496+
if (dyn_region_areas[i].size == 0U) {
497497
continue;
498498
}
499499
/* Non-empty area */

arch/arm/core/cortex_m/mpu/nxp_mpu.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ static int _mpu_partition_is_valid(const struct k_mem_partition *part)
5454
* minimum MPU region size.
5555
*/
5656
int partition_is_valid =
57-
(part->size != 0)
57+
(part->size != 0U)
5858
&&
5959
((part->size &
6060
(~(CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE - 1)))
6161
== part->size)
6262
&&
6363
((part->start &
64-
(CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE - 1)) == 0);
64+
(CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE - 1)) == 0U);
6565

6666
return partition_is_valid;
6767
}
@@ -78,7 +78,7 @@ static void _region_init(const u32_t index,
7878
u32_t region_end = region_conf->end;
7979
u32_t region_attr = region_conf->attr.attr;
8080

81-
if (index == 0) {
81+
if (index == 0U) {
8282
/* The MPU does not allow writes from the core to affect the
8383
* RGD0 start or end addresses nor the permissions associated
8484
* with the debugger; it can only write the permission fields
@@ -241,7 +241,7 @@ static int _mpu_configure_regions(const struct k_mem_partition
241241
int reg_index = start_reg_index;
242242

243243
for (i = 0; i < regions_num; i++) {
244-
if (regions[i]->size == 0) {
244+
if (regions[i]->size == 0U) {
245245
continue;
246246
}
247247
/* Non-empty region. */

arch/arm/core/fault.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ static int _BusFault(NANO_ESF *esf, int fromHardFault)
389389

390390
if (sperr) {
391391
for (i = 0; i < SYSMPU_EAR_COUNT; i++, mask >>= 1) {
392-
if ((sperr & mask) == 0) {
392+
if ((sperr & mask) == 0U) {
393393
continue;
394394
}
395395
STORE_xFAR(edr, SYSMPU->SP[i].EDR);
@@ -796,7 +796,7 @@ void _Fault(NANO_ESF *esf, u32_t exc_return)
796796
/* Invalid EXC_RETURN value */
797797
goto _exit_fatal;
798798
}
799-
if ((exc_return & EXC_RETURN_EXCEPTION_SECURE_Secure) == 0) {
799+
if ((exc_return & EXC_RETURN_EXCEPTION_SECURE_Secure) == 0U) {
800800
/* Secure Firmware shall only handle Secure Exceptions.
801801
* This is a fatal error.
802802
*/

arch/arm/core/irq_offload.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void irq_offload(irq_offload_routine_t routine, void *parameter)
2929
unsigned int key;
3030

3131
__asm__ volatile("mrs %0, PRIMASK;" : "=r" (key) : : "memory");
32-
__ASSERT(key == 0, "irq_offload called with interrupts locked\n");
32+
__ASSERT(key == 0U, "irq_offload called with interrupts locked\n");
3333
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE && CONFIG_ASSERT */
3434

3535
k_sched_lock();

0 commit comments

Comments
 (0)