From: Federico Serafini <federico.serafini@bugseng.com>
To: xen-devel@lists.xenproject.org
Cc: consulting@bugseng.com,
Federico Serafini <federico.serafini@bugseng.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
George Dunlap <george.dunlap@citrix.com>,
Jan Beulich <jbeulich@suse.com>, Julien Grall <julien@xen.org>,
Stefano Stabellini <sstabellini@kernel.org>
Subject: [XEN PATCH v2 2/2] vsprintf: address violations of MISRA C:2012 Rule 16.3
Date: Thu, 4 Apr 2024 09:49:29 +0200 [thread overview]
Message-ID: <9705ea09d3dac2e569c075cd9bd7f594796b12c1.1712215939.git.federico.serafini@bugseng.com> (raw)
In-Reply-To: <cover.1712215939.git.federico.serafini@bugseng.com>
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>
---
Changes in v2:
- improved commit message.
---
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;
--
2.34.1
next prev parent reply other threads:[~2024-04-04 7:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-04 7:49 [XEN PATCH v2 0/2] xen: address violations of MISRA C:2012 Rule 16.3 Federico Serafini
2024-04-04 7:49 ` [XEN PATCH v2 1/2] xen/sched: " Federico Serafini
2024-04-04 7:58 ` Jan Beulich
2024-04-04 9:51 ` George Dunlap
2024-04-04 7:49 ` Federico Serafini [this message]
2024-04-04 7:59 ` [XEN PATCH v2 2/2] vsprintf: " Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9705ea09d3dac2e569c075cd9bd7f594796b12c1.1712215939.git.federico.serafini@bugseng.com \
--to=federico.serafini@bugseng.com \
--cc=andrew.cooper3@citrix.com \
--cc=consulting@bugseng.com \
--cc=george.dunlap@citrix.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.