* [PATCH] mini-os: fix coverity issues in printf.c
@ 2016-08-17 13:39 Juergen Gross
2016-08-17 14:13 ` Wei Liu
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Juergen Gross @ 2016-08-17 13:39 UTC (permalink / raw)
To: minios-devel, xen-devel; +Cc: Juergen Gross, samuel.thibault, wei.liu2
Fix two issues discovered by coverity.
Signed-off-by: Juergen Gross <jgross@suse.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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] mini-os: fix coverity issues in printf.c
2016-08-17 13:39 [PATCH] mini-os: fix coverity issues in printf.c Juergen Gross
@ 2016-08-17 14:13 ` Wei Liu
2016-08-17 14:25 ` Juergen Gross
2016-08-20 12:49 ` Samuel Thibault
2016-08-20 12:50 ` Samuel Thibault
2016-08-22 9:41 ` Wei Liu
2 siblings, 2 replies; 7+ messages in thread
From: Wei Liu @ 2016-08-17 14:13 UTC (permalink / raw)
To: Juergen Gross; +Cc: minios-devel, xen-devel, wei.liu2, samuel.thibault
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mini-os: fix coverity issues in printf.c
2016-08-17 14:13 ` Wei Liu
@ 2016-08-17 14:25 ` Juergen Gross
2016-08-17 14:26 ` Wei Liu
2016-08-20 12:49 ` Samuel Thibault
1 sibling, 1 reply; 7+ messages in thread
From: Juergen Gross @ 2016-08-17 14:25 UTC (permalink / raw)
To: Wei Liu; +Cc: minios-devel, xen-devel, samuel.thibault
On 17/08/16 16:13, Wei Liu wrote:
> 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
Do you want me to resend or could you do that when committing?
>
>
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>
> Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Thanks,
Juergen
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mini-os: fix coverity issues in printf.c
2016-08-17 14:25 ` Juergen Gross
@ 2016-08-17 14:26 ` Wei Liu
0 siblings, 0 replies; 7+ messages in thread
From: Wei Liu @ 2016-08-17 14:26 UTC (permalink / raw)
To: Juergen Gross; +Cc: minios-devel, xen-devel, Wei Liu, samuel.thibault
On Wed, Aug 17, 2016 at 04:25:44PM +0200, Juergen Gross wrote:
> On 17/08/16 16:13, Wei Liu wrote:
> > 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
>
> Do you want me to resend or could you do that when committing?
>
I can do it.
I will wait for Samuel's ack.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mini-os: fix coverity issues in printf.c
2016-08-17 14:13 ` Wei Liu
2016-08-17 14:25 ` Juergen Gross
@ 2016-08-20 12:49 ` Samuel Thibault
1 sibling, 0 replies; 7+ messages in thread
From: Samuel Thibault @ 2016-08-20 12:49 UTC (permalink / raw)
To: Wei Liu; +Cc: Juergen Gross, minios-devel, xen-devel
Wei Liu, on Wed 17 Aug 2016 15:13:27 +0100, wrote:
> 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>
Acked-by: Samuel Thibault <samuel.thibautl@ens-lyon.org>
> > ---
> > 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
> >
>
--
Samuel
"2 + 2 = 5 pour d'assez grandes valeurs de 2"
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mini-os: fix coverity issues in printf.c
2016-08-17 13:39 [PATCH] mini-os: fix coverity issues in printf.c Juergen Gross
2016-08-17 14:13 ` Wei Liu
@ 2016-08-20 12:50 ` Samuel Thibault
2016-08-22 9:41 ` Wei Liu
2 siblings, 0 replies; 7+ messages in thread
From: Samuel Thibault @ 2016-08-20 12:50 UTC (permalink / raw)
To: Juergen Gross; +Cc: minios-devel, xen-devel, wei.liu2
Juergen Gross, on Wed 17 Aug 2016 15:39:59 +0200, wrote:
> Fix two issues discovered by coverity.
Thanks for processing mini-os through coverity :)
Samuel
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] mini-os: fix coverity issues in printf.c
2016-08-17 13:39 [PATCH] mini-os: fix coverity issues in printf.c Juergen Gross
2016-08-17 14:13 ` Wei Liu
2016-08-20 12:50 ` Samuel Thibault
@ 2016-08-22 9:41 ` Wei Liu
2 siblings, 0 replies; 7+ messages in thread
From: Wei Liu @ 2016-08-22 9:41 UTC (permalink / raw)
To: Juergen Gross; +Cc: minios-devel, xen-devel, wei.liu2, samuel.thibault
On Wed, Aug 17, 2016 at 03:39:59PM +0200, Juergen Gross wrote:
> Fix two issues discovered by coverity.
>
Pushed with fixed up commit message.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-08-22 9:41 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-17 13:39 [PATCH] mini-os: fix coverity issues in printf.c Juergen Gross
2016-08-17 14:13 ` Wei Liu
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
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).