xen: address violations of MISRA C:2012 Rule 16.3
v2 cover xen: address violations of MISRA C:2012 Rule 16.3
Address violations of MISRA C:2012 Rule 16.3 by adding fallthrough, break and return at the end of the switch-clauses.
Federico Serafini (2):
xen/sched: address violations of MISRA C:2012 Rule 16.3
vsprintf: address violations of MISRA C:2012 Rule 16.3
xen/common/sched/core.c | 1 + xen/common/sched/credit2.c | 2 +- xen/common/vsprintf.c | 6 +++++- 3 files changed, 7 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/2 xen/sched: address violations of MISRA C:2012 Rule 16.3
Add break statement to address a violation of MISRA C:2012 Rule 16.3 ("An unconditional `break' statement shall terminate every switch-clause").
Replace deprecated comment /* FALLTHRU */ with pseudo-keyword fallthrough to meet the requirements to deviate the rule.
No functional change.
---
Changes in v2:
- this patch is the result of merging together two different patches with the same title;
- commit message has been improved to make clear that the comment is deprecated.
--- xen/common/sched/core.c | 1 + xen/common/sched/credit2.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
xen/common/sched/core.c +1 -0
@@ -2007,6 +2007,7 @@ ret_t do_sched_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)default : ret = -ENOSYS ; +break ; }return ret;
xen/common/sched/credit2.c +1 -1
@@ -3152,8 +3152,8 @@ static int cf_check csched2_sys_cntl(printk (XENLOG_INFO "Disabling context switch rate limiting\n" ); prv->ratelimit_us = params->ratelimit_us;write_unlock_irqrestore (&prv->lock, flags); + fallthrough; -/* FALLTHRU */ case XEN_SYSCTL_SCHEDOP_getinfo: params->ratelimit_us = prv->ratelimit_us;break ;
Signature · 1 line
2.34.1
Re: [XEN PATCH v2 1/2] xen/sched: address violations of MISRA C:2012 Rule 16.3
Quoted 9 lines · Federico Serafini
Add break statement to address a violation of MISRA C:2012 Rule 16.3 ("An unconditional `break' statement shall terminate every switch-clause").
Replace deprecated comment /* FALLTHRU */ with pseudo-keyword fallthrough to meet the requirements to deviate the rule.No functional change.
Signed-off-by Federico Serafini <[email protected]>
Re: [XEN PATCH v2 1/2] xen/sched: address violations of MISRA C:2012 Rule 16.3
In reply to Federico SerafiniQuoted 10 lines · Federico Serafini
Add break statement to address a violation of MISRA C:2012 Rule 16.3 ("An unconditional `break' statement shall terminate every switch-clause").
Replace deprecated comment /* FALLTHRU */ with pseudo-keyword fallthrough to meet the requirements to deviate the rule.No functional change.
Signed-off-by Federico Serafini <[email protected]>
PATCH v2 2/2 vsprintf: address violations of MISRA C:2012 Rule 16.3
In reply to Federico SerafiniMISRA 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.
---
Changes in v2:
- improved commit message.
--- xen/common/vsprintf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
xen/common/vsprintf.c +5 -1
@@ -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 ;
Signature · 1 line
2.34.1
Re: [XEN PATCH v2 2/2] vsprintf: address violations of MISRA C:2012 Rule 16.3
Quoted 10 lines · Federico Serafini
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.
Quoted 3 lines
No functional change.
Signed-off-by Federico Serafini <[email protected]>