diff --git a/lib/libc/minimal/source/stdlib/atoi.c b/lib/libc/minimal/source/stdlib/atoi.c index 196a2e6736cb1e..909580e3b703e9 100644 --- a/lib/libc/minimal/source/stdlib/atoi.c +++ b/lib/libc/minimal/source/stdlib/atoi.c @@ -43,6 +43,12 @@ int atoi(const char *s) break; /* artifact to quiet coverity warning */ case '+': s++; + default: + /* Add an empty default with break, this is a defensive programming. + * Static analysis tool won't raise a violation if default is empty, + * but has that comment. + */ + break; } /* Compute n as a negative number to avoid overflow on INT_MIN */ while (isdigit(*s)) { diff --git a/lib/os/cbprintf_complete.c b/lib/os/cbprintf_complete.c index 528278b3ecc507..d45c12c3787ae4 100644 --- a/lib/os/cbprintf_complete.c +++ b/lib/os/cbprintf_complete.c @@ -555,6 +555,10 @@ static inline const char *extract_specifier(struct conversion *conv, unsupported = sizeof(ptrdiff_t) > 4; break; default: + /* Add an empty default with break, this is a defensive + * programming. Static analysis tool won't raise a violation + * if default is empty, but has that comment. + */ break; } } else { @@ -1303,6 +1307,10 @@ static inline void store_count(const struct conversion *conv, *(ptrdiff_t *)dp = (ptrdiff_t)count; break; default: + /* Add an empty default with break, this is a defensive programming. + * Static analysis tool won't raise a violation if default is empty, + * but has that comment. + */ break; } } @@ -1665,6 +1673,12 @@ int cbvprintf(cbprintf_cb out, void *ctx, const char *fp, va_list ap) &sign, buf, &bpe); } break; + default: + /* Add an empty default with break, this is a defensive + * programming. Static analysis tool won't raise a violation + * if default is empty, but has that comment. + */ + break; } /* If we don't have a converted value to emit, move diff --git a/lib/os/fdtable.c b/lib/os/fdtable.c index e08b541e732fca..3b737e77b32b5c 100644 --- a/lib/os/fdtable.c +++ b/lib/os/fdtable.c @@ -309,6 +309,12 @@ int fcntl(int fd, int cmd, ...) /* Not implemented so far. */ errno = EINVAL; return -1; + default: + /* Add an empty default with break, this is a defensive programming. + * Static analysis tool won't raise a violation if default is empty, + * but has that comment. + */ + break; } /* The rest of commands are per-fd, handled by ioctl vmethod. */