From: Wei Liu <wei.liu2@citrix.com>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org,
xen-devel@lists.xenproject.org, wei.liu2@citrix.com,
samuel.thibault@ens-lyon.org
Subject: Re: [PATCH] mini-os: fix coverity issues in printf.c
Date: Wed, 17 Aug 2016 15:13:27 +0100 [thread overview]
Message-ID: <20160817141327.GC2590@citrix.com> (raw)
In-Reply-To: <1471441199-5843-1-git-send-email-jgross@suse.com>
On Wed, Aug 17, 2016 at 03:39:59PM +0200, Juergen Gross wrote:
> Fix two issues discovered by coverity.
I would update the commit message to make it contain more information.
Fix two issues discovered by Coverity:
1. properl mark one switch case as fall-through
2. unroll a loop that only executes once
CID: 1369623
CID: 1019001
>
> Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
> ---
> lib/printf.c | 25 +++++++++++--------------
> 1 file changed, 11 insertions(+), 14 deletions(-)
>
> diff --git a/lib/printf.c b/lib/printf.c
> index ad6a304..f9e9d68 100644
> --- a/lib/printf.c
> +++ b/lib/printf.c
> @@ -379,6 +379,7 @@ reswitch: switch (ch = (u_char)*fmt++) {
> padc = '0';
> goto reswitch;
> }
> + /* fallthrough */
> case '1': case '2': case '3': case '4':
> case '5': case '6': case '7': case '8': case '9':
> for (n = 0;; ++fmt) {
> @@ -966,20 +967,16 @@ literal:
> width = 1;
> if (flags & SUPPRESS) {
> size_t sum = 0;
> - for (;;) {
> - if ((n = inr) < width) {
> - sum += n;
> - width -= n;
> - inp += n;
> - if (sum == 0)
> - goto input_failure;
> - break;
> - } else {
> - sum += width;
> - inr -= width;
> - inp += width;
> - break;
> - }
> + if ((n = inr) < width) {
> + sum += n;
> + width -= n;
> + inp += n;
> + if (sum == 0)
> + goto input_failure;
> + } else {
> + sum += width;
> + inr -= width;
> + inp += width;
> }
> nread += sum;
> } else {
> --
> 2.6.6
>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-08-17 14:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-17 13:39 [PATCH] mini-os: fix coverity issues in printf.c Juergen Gross
2016-08-17 14:13 ` Wei Liu [this message]
2016-08-17 14:25 ` Juergen Gross
2016-08-17 14:26 ` Wei Liu
2016-08-20 12:49 ` Samuel Thibault
2016-08-20 12:50 ` Samuel Thibault
2016-08-22 9:41 ` Wei Liu
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=20160817141327.GC2590@citrix.com \
--to=wei.liu2@citrix.com \
--cc=jgross@suse.com \
--cc=minios-devel@lists.xenproject.org \
--cc=samuel.thibault@ens-lyon.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).