Commit d03fa8d8 authored by Abramo Bagnara's avatar Abramo Bagnara Committed by Anas Nashif
Browse files

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: default avatarAbramo Bagnara <abramo.bagnara@bugseng.com>
parent 40cf447b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ int arch_mem_domain_max_partitions_get(void)
/*
 * Validate the given buffer is user accessible or not
 */
int arch_buffer_validate(void *addr, size_t size, int write)
int arch_buffer_validate(void *addr, size_t size, bool write)
{
	return arc_core_mpu_buffer_validate(addr, size, write);
}
+1 −1
Original line number Diff line number Diff line
@@ -207,7 +207,7 @@ int arc_core_mpu_get_max_domain_partition_regions(void)
/**
 * @brief validate the given buffer is user accessible or not
 */
int arc_core_mpu_buffer_validate(void *addr, size_t size, int write)
int arc_core_mpu_buffer_validate(void *addr, size_t size, bool write)
{
	/*
	 * For ARC MPU, smaller region number takes priority.
+1 −1
Original line number Diff line number Diff line
@@ -779,7 +779,7 @@ int arc_core_mpu_get_max_domain_partition_regions(void)
/**
 * @brief validate the given buffer is user accessible or not
 */
int arc_core_mpu_buffer_validate(void *addr, size_t size, int write)
int arc_core_mpu_buffer_validate(void *addr, size_t size, bool write)
{
	int r_index;
	int key = arch_irq_lock();
+1 −1
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ void z_arm_irq_priority_set(unsigned int irq, unsigned int prio, uint32_t flags)
	__ASSERT(prio <= (BIT(NUM_IRQ_PRIO_BITS) - 1),
		 "invalid priority %d for %d irq! values must be less than %lu\n",
		 prio - _IRQ_PRIO_OFFSET, irq,
		 BIT(NUM_IRQ_PRIO_BITS) - (_IRQ_PRIO_OFFSET));
		 (unsigned long)BIT(NUM_IRQ_PRIO_BITS) - (_IRQ_PRIO_OFFSET));
	NVIC_SetPriority((IRQn_Type)irq, prio);
}

+1 −1
Original line number Diff line number Diff line
@@ -324,7 +324,7 @@ int arch_mem_domain_max_partitions_get(void)
	return ARM_CORE_MPU_MAX_DOMAIN_PARTITIONS_GET(available_regions);
}

int arch_buffer_validate(void *addr, size_t size, int write)
int arch_buffer_validate(void *addr, size_t size, bool write)
{
	return arm_core_mpu_buffer_validate(addr, size, write);
}
Loading