vsprintf: address violations of MISRA C:2012 Rule 16.3

MISRA C:2012 Rule 16.3 states: "An unconditional `break' statement
shall terminate every switch-clause".

In order to meet the requirements to deviate the rule:
1) refactor the for loop to make the switch-clause ending with a
   return statement (note that adding a break at the end of the
   switch-clause would result in a violation of Rule 2.1
   "A project shall not contain unreachable code");
2) add pseudo-keyword fallthrough.

No functional change.

Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
Federico Serafini authored and Jan Beulich committed 2024-04-04 12:01:50 +02:00
1 parent 226bdb155b
commit 6eeb3e86bd
1 file changed
+5 -1
+5 -1
View File
@@ -377,7 +377,7 @@ static char *pointer(char *str, const char *end, const char **fmt_ptr,
str = number(str, end, hex_buffer[i], 16, 2, -1, ZEROPAD);
if ( ++i == field_width )
return str;
break;
if ( sep )
{
@@ -386,6 +386,8 @@ static char *pointer(char *str, const char *end, const char **fmt_ptr,
++str;
}
}
return str;
}
case 'p': /* PCI SBDF. */
@@ -619,6 +621,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
case 'X':
flags |= LARGE;
fallthrough;
case 'x':
base = 16;
break;
@@ -626,6 +629,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
case 'd':
case 'i':
flags |= SIGN;
fallthrough;
case 'u':
break;
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.