[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] vsprintf: address violations of MISRA C:2012 Rule 16.3
commit 6eeb3e86bdfa55874f4c44527551e9b82125dc83 Author: Federico Serafini <federico.serafini@xxxxxxxxxxx> AuthorDate: Thu Apr 4 12:01:50 2024 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Thu Apr 4 12:01:50 2024 +0200 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@xxxxxxxxxxx> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx> --- xen/common/vsprintf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xen/common/vsprintf.c b/xen/common/vsprintf.c index c49631c0a4..612751c90f 100644 --- a/xen/common/vsprintf.c +++ b/xen/common/vsprintf.c @@ -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; -- generated by git-patchbot for /home/xen/git/xen.git#master
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |