Skip to content

Commit

Permalink
coding guidelines 10.4: casting operands to have same types
Browse files Browse the repository at this point in the history
File zephyr/lib/os/cbprintf_nano.c had operands with different types.
It caused Rule 10.4 violation.
Both operands of an operator in which the usual arithmetic conversions
are performed shall have the same essential type category.

Signed-off-by: Maksim Masalski <[email protected]>

coding guidelines 10.4: casting operands to have same types

File zephyr/lib/os/cbprintf_nano.c had operands with different types.
It caused Rule 10.4 violation.
Both operands of an operator in which the usual arithmetic conversions
are performed shall have the same essential type category.

Signed-off-by: Maksim Masalski <[email protected]>

removed cast to int
  • Loading branch information
maksimmasalski authored and carlescufi committed May 8, 2021
1 parent 88f3a98 commit 136c942
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/os/cbprintf_nano.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ int cbvprintf(cbprintf_cb out, void *ctx, const char *fmt, va_list ap)

start:
while (*++fmt != '%') {
if (*fmt == 0) {
if (*fmt == '\0') {
return count;
}
OUTC(*fmt);
Expand Down Expand Up @@ -105,7 +105,7 @@ int cbvprintf(cbprintf_cb out, void *ctx, const char *fmt, va_list ap)

case '.':
precision = 0;
padding_mode &= ~PAD_ZERO;
padding_mode &= (char)~PAD_ZERO;
continue;

case '0':
Expand Down Expand Up @@ -159,7 +159,7 @@ int cbvprintf(cbprintf_cb out, void *ctx, const char *fmt, va_list ap)
length_mod = 'H';
} else if (*fmt == 'l' && length_mod == 'l') {
length_mod = 'L';
} else if (length_mod == 0) {
} else if (length_mod == '\0') {
length_mod = *fmt;
} else {
OUTC('%');
Expand Down Expand Up @@ -219,7 +219,7 @@ int cbvprintf(cbprintf_cb out, void *ctx, const char *fmt, va_list ap)

if (*fmt == 'p') {
x = (uintptr_t)va_arg(ap, void *);
if (x == 0) {
if (x == (uint_value_type)0) {
data = "(nil)";
data_len = 5;
precision = 0;
Expand Down

0 comments on commit 136c942

Please sign in to comment.