Skip to content

Commit d03fa8d

Browse files
Abramo-Bagnaranashif
authored andcommitted
coding guidelines: partially comply with MISRA C:2012 essential types rules.
In particular: - use bool when the data nature is Boolean; - use explicit comparison with 0 or NULL; - avoid mixing signed and unsigned integers in computations and comparisons; - avoid mixing enumerations with integers: when this is unavoidable, always convert enums to integers and not the other way around; - avoid mixing characters with integers; - ensure computations are done in the destination precision; - added /*? comments when the developer intentions are not clear; - added U suffix to unsigned constants (except for the CONFIG_* macro constants, as they cannot be changed and then their use as unsigned constants should be prefixed with a cast). Violations for rules 10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 11.7, 12.2, 14.4 and 16.7 in the reference builds have been reduced from 67818 to 60. The commit cannot be divided on a per-rule basis due to numerous cross-dependencies between changes. Signed-off-by: Abramo Bagnara <abramo.bagnara@bugseng.com>
1 parent 40cf447 commit d03fa8d

File tree

120 files changed

+1146
-1104
lines changed

Some content is hidden

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

120 files changed

+1146
-1104
lines changed

arch/arc/core/mpu/arc_core_mpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ int arch_mem_domain_max_partitions_get(void)
3535
/*
3636
* Validate the given buffer is user accessible or not
3737
*/
38-
int arch_buffer_validate(void *addr, size_t size, int write)
38+
int arch_buffer_validate(void *addr, size_t size, bool write)
3939
{
4040
return arc_core_mpu_buffer_validate(addr, size, write);
4141
}

arch/arc/core/mpu/arc_mpu_common_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ int arc_core_mpu_get_max_domain_partition_regions(void)
207207
/**
208208
* @brief validate the given buffer is user accessible or not
209209
*/
210-
int arc_core_mpu_buffer_validate(void *addr, size_t size, int write)
210+
int arc_core_mpu_buffer_validate(void *addr, size_t size, bool write)
211211
{
212212
/*
213213
* For ARC MPU, smaller region number takes priority.

arch/arc/core/mpu/arc_mpu_v4_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ int arc_core_mpu_get_max_domain_partition_regions(void)
779779
/**
780780
* @brief validate the given buffer is user accessible or not
781781
*/
782-
int arc_core_mpu_buffer_validate(void *addr, size_t size, int write)
782+
int arc_core_mpu_buffer_validate(void *addr, size_t size, bool write)
783783
{
784784
int r_index;
785785
int key = arch_irq_lock();

arch/arm/core/aarch32/irq_manage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void z_arm_irq_priority_set(unsigned int irq, unsigned int prio, uint32_t flags)
8888
__ASSERT(prio <= (BIT(NUM_IRQ_PRIO_BITS) - 1),
8989
"invalid priority %d for %d irq! values must be less than %lu\n",
9090
prio - _IRQ_PRIO_OFFSET, irq,
91-
BIT(NUM_IRQ_PRIO_BITS) - (_IRQ_PRIO_OFFSET));
91+
(unsigned long)BIT(NUM_IRQ_PRIO_BITS) - (_IRQ_PRIO_OFFSET));
9292
NVIC_SetPriority((IRQn_Type)irq, prio);
9393
}
9494

arch/arm/core/aarch32/mpu/arm_core_mpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ int arch_mem_domain_max_partitions_get(void)
324324
return ARM_CORE_MPU_MAX_DOMAIN_PARTITIONS_GET(available_regions);
325325
}
326326

327-
int arch_buffer_validate(void *addr, size_t size, int write)
327+
int arch_buffer_validate(void *addr, size_t size, bool write)
328328
{
329329
return arm_core_mpu_buffer_validate(addr, size, write);
330330
}

arch/arm/core/aarch32/mpu/arm_core_mpu_dev.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ int arm_core_mpu_get_max_available_dyn_regions(void);
261261
* spans multiple enabled MPU regions (even if these regions all
262262
* permit user access).
263263
*/
264-
int arm_core_mpu_buffer_validate(void *addr, size_t size, int write);
264+
int arm_core_mpu_buffer_validate(void *addr, size_t size, bool write);
265265

266266
#endif /* CONFIG_ARM_MPU */
267267

arch/arm/core/aarch32/mpu/arm_mpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ int arm_core_mpu_get_max_available_dyn_regions(void)
253253
*
254254
* Presumes the background mapping is NOT user accessible.
255255
*/
256-
int arm_core_mpu_buffer_validate(void *addr, size_t size, int write)
256+
int arm_core_mpu_buffer_validate(void *addr, size_t size, bool write)
257257
{
258258
return mpu_buffer_validate(addr, size, write);
259259
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ static inline int is_user_accessible_region(uint32_t r_index, int write)
169169
* This internal function validates whether a given memory buffer
170170
* is user accessible or not.
171171
*/
172-
static inline int mpu_buffer_validate(void *addr, size_t size, int write)
172+
static inline int mpu_buffer_validate(void *addr, size_t size, bool write)
173173
{
174174
int32_t r_index;
175175
int rc = -EPERM;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ static inline int is_enabled_region(uint32_t index)
270270
* in case the fast address range check fails.
271271
*
272272
*/
273-
static inline int mpu_buffer_validate(void *addr, size_t size, int write)
273+
static inline int mpu_buffer_validate(void *addr, size_t size, bool write)
274274
{
275275
uint32_t _addr = (uint32_t)addr;
276276
uint32_t _size = (uint32_t)size;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ static inline int is_user_accessible_region(uint32_t r_index, int write)
536536
/**
537537
* @brief validate the given buffer is user accessible or not
538538
*/
539-
int arm_core_mpu_buffer_validate(void *addr, size_t size, int write)
539+
int arm_core_mpu_buffer_validate(void *addr, size_t size, bool write)
540540
{
541541
uint8_t r_index;
542542

0 commit comments

Comments
 (0)