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

coding guidelines: comply with MISRA C:2012 Rule 13.3



In particular:

- avoided ++/-- on volatile

- avoided to have more than one ++/-- in for third clause

- moved ++/-- before or after the value use

- avoided pointless ++/--

- replaced consecutive ++ with a single +=

Signed-off-by: default avatarAbramo Bagnara <abramo.bagnara@bugseng.com>
parent f953e929
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -188,6 +188,6 @@ FUNC_NORETURN void z_x86_cpu_init(struct x86_cpuboot *cpuboot)
#endif

	/* Enter kernel, never return */
	cpuboot->ready++;
	cpuboot->ready += 1;
	cpuboot->fn(cpuboot->arg);
}
+3 −1
Original line number Diff line number Diff line
@@ -59,7 +59,9 @@ int z_x86_allocate_vector(unsigned int priority, int prev_vector)
		vector = (int)uvector;
	}

	for (unsigned int i = 0; i < VECTORS_PER_PRIORITY; ++i, ++vector) {
	const int end_vector = vector + (int) VECTORS_PER_PRIORITY;

	for (; vector < end_vector; ++vector) {
		if (prev_vector != 1 && vector == prev_vector) {
			continue;
		}
+11 −5
Original line number Diff line number Diff line
@@ -46,14 +46,18 @@ static void prdec(struct _pfr *r, long v)
	char digs[11U * sizeof(long) / 4];
	size_t i = sizeof(digs) - 1;

	digs[i--] = '\0';
	digs[i] = '\0';
	--i;
	while ((v != 0) || (i == 9)) {
		digs[i--] = '0' + (v % 10);
		digs[i] = '0' + (v % 10);
		--i;
		v /= 10;
	}

	while (digs[++i] != '\0') {
	++i;
	while (digs[i] != '\0') {
		pc(r, digs[i]);
		++i;
	}
}

@@ -102,8 +106,10 @@ static size_t vpf(struct _pfr *r, const char *f, va_list ap)
		case 's': {
			char *s = va_arg(ap, char *);

			while (*s != '\0')
				pc(r, *s++);
			while (*s != '\0') {
				pc(r, *s);
				++s;
			}
			break;
		}
		case 'p':
+3 −2
Original line number Diff line number Diff line
@@ -33,7 +33,8 @@ static void efi_putchar(int c)
		efi_putchar((int)'\r');
	}

	efibuf[n++] = (uint16_t)c;
	efibuf[n] = (uint16_t)c;
	++n;

	if (c == (int)'\n' || n == PUTCHAR_BUFSZ) {
		efibuf[n] = 0U;
@@ -120,7 +121,7 @@ uintptr_t __abi efi_entry(void *img_handle, struct efi_system_table *sys_tab)
	 * to drain before we start banging on the same UART from the
	 * OS.
	 */
	for (volatile int i = 0; i < 50000000; i++) {
	for (volatile int i = 0; i < 50000000; i += 1) {
	}

	__asm__ volatile("cli; jmp *%0" :: "r"(code));
+2 −1
Original line number Diff line number Diff line
@@ -274,7 +274,8 @@ do { \
	} \
	size_t _arg_size = Z_CBPRINTF_ARG_SIZE(_arg); \
	if (Z_CBPRINTF_IS_PCHAR(_arg) != 0) { \
		(_s_buf)[(_s_idx)++] = (uint16_t)((_idx) / sizeof(int)); \
		(_s_buf)[(_s_idx)] = (uint16_t)((_idx) / sizeof(int)); \
		++(_s_idx); \
	} \
	if ((_buf) != NULL && (_idx) < (_max)) { \
		Z_CBPRINTF_STORE_ARG(&(_buf)[(_idx)], _arg); \
Loading