* [PATCH 0/5] hw/display/artist: Fix Coverity 1419388 & 1419389
@ 2020-02-14 0:12 Philippe Mathieu-Daudé
2020-02-14 0:12 ` [PATCH 1/5] hw/display/artist: Move trace event to draw_line() Philippe Mathieu-Daudé
` (5 more replies)
0 siblings, 6 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-02-14 0:12 UTC (permalink / raw)
To: Helge Deller, qemu-devel, Sven Schnelle
Cc: Philippe Mathieu-Daudé, Gerd Hoffmann, Richard Henderson
Another easy Coverity fix.
Philippe Mathieu-Daudé (5):
hw/display/artist: Move trace event to draw_line()
hw/display/artist: Remove pointless initialization
hw/display/artist: Delay some variables initialization
hw/display/artist: Avoid drawing line when nothing to display
hw/display/artist: Remove dead code (CID 1419388 & 1419389)
hw/display/artist.c | 29 +++++++++--------------------
1 file changed, 9 insertions(+), 20 deletions(-)
--
2.21.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/5] hw/display/artist: Move trace event to draw_line()
2020-02-14 0:12 [PATCH 0/5] hw/display/artist: Fix Coverity 1419388 & 1419389 Philippe Mathieu-Daudé
@ 2020-02-14 0:12 ` Philippe Mathieu-Daudé
2020-02-15 9:12 ` Sven Schnelle
2020-02-14 0:12 ` [PATCH 2/5] hw/display/artist: Remove pointless initialization Philippe Mathieu-Daudé
` (4 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-02-14 0:12 UTC (permalink / raw)
To: Helge Deller, qemu-devel, Sven Schnelle
Cc: Philippe Mathieu-Daudé, Gerd Hoffmann, Richard Henderson
Instead of emitting the trace event before each call to
draw_line(), call it once at draw_line() entrance.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/display/artist.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/hw/display/artist.c b/hw/display/artist.c
index 65be9e3554..abacb0e27d 100644
--- a/hw/display/artist.c
+++ b/hw/display/artist.c
@@ -557,90 +557,91 @@ static void fill_window(ARTISTState *s, int startx, int starty,
static void draw_line(ARTISTState *s, int x1, int y1, int x2, int y2,
bool update_start, int skip_pix, int max_pix)
{
struct vram_buffer *buf;
uint8_t color = artist_get_color(s);
int dx, dy, t, e, x, y, incy, diago, horiz;
bool c1;
uint8_t *p;
+ trace_artist_draw_line(x1, y1, x2, y2);
if (update_start) {
s->vram_start = (x2 << 16) | y2;
}
buf = &s->vram_buffer[ARTIST_BUFFER_AP];
c1 = false;
incy = 1;
if (x2 > x1) {
dx = x2 - x1;
} else {
dx = x1 - x2;
}
if (y2 > y1) {
dy = y2 - y1;
} else {
dy = y1 - y2;
}
if (dy > dx) {
t = y2;
y2 = x2;
x2 = t;
t = y1;
y1 = x1;
x1 = t;
t = dx;
dx = dy;
dy = t;
c1 = true;
}
if (x1 > x2) {
t = y2;
y2 = y1;
y1 = t;
t = x1;
x1 = x2;
x2 = t;
}
horiz = dy << 1;
diago = (dy - dx) << 1;
e = (dy << 1) - dx;
if (y1 <= y2) {
incy = 1;
} else {
incy = -1;
}
x = x1;
y = y1;
do {
if (c1) {
p = buf->data + x * s->width + y;
} else {
p = buf->data + y * s->width + x;
}
if (skip_pix > 0) {
skip_pix--;
} else {
artist_rop8(s, p, color);
}
if (e > 0) {
artist_invalidate_lines(buf, y, 1);
y += incy;
e += diago;
} else {
e += horiz;
}
x++;
} while (x <= x2 && (max_pix == -1 || --max_pix > 0));
}
@@ -648,13 +649,12 @@ static void draw_line(ARTISTState *s, int x1, int y1, int x2, int y2,
static void draw_line_pattern_start(ARTISTState *s)
{
int startx = artist_get_x(s->vram_start);
int starty = artist_get_y(s->vram_start);
int endx = artist_get_x(s->blockmove_size);
int endy = artist_get_y(s->blockmove_size);
int pstart = s->line_pattern_start >> 16;
- trace_artist_draw_line(startx, starty, endx, endy);
draw_line(s, startx, starty, endx, endy, false, -1, pstart);
s->line_pattern_skip = pstart;
}
@@ -662,15 +662,14 @@ static void draw_line_pattern_start(ARTISTState *s)
static void draw_line_pattern_next(ARTISTState *s)
{
int startx = artist_get_x(s->vram_start);
int starty = artist_get_y(s->vram_start);
int endx = artist_get_x(s->blockmove_size);
int endy = artist_get_y(s->blockmove_size);
int line_xy = s->line_xy >> 16;
- trace_artist_draw_line(startx, starty, endx, endy);
draw_line(s, startx, starty, endx, endy, false, s->line_pattern_skip,
s->line_pattern_skip + line_xy);
s->line_pattern_skip += line_xy;
s->image_bitmap_op ^= 2;
}
@@ -678,84 +677,81 @@ static void draw_line_pattern_next(ARTISTState *s)
static void draw_line_size(ARTISTState *s, bool update_start)
{
int startx = artist_get_x(s->vram_start);
int starty = artist_get_y(s->vram_start);
int endx = artist_get_x(s->line_size);
int endy = artist_get_y(s->line_size);
- trace_artist_draw_line(startx, starty, endx, endy);
draw_line(s, startx, starty, endx, endy, update_start, -1, -1);
}
static void draw_line_xy(ARTISTState *s, bool update_start)
{
int startx = artist_get_x(s->vram_start);
int starty = artist_get_y(s->vram_start);
int sizex = artist_get_x(s->blockmove_size);
int sizey = artist_get_y(s->blockmove_size);
int linexy = s->line_xy >> 16;
int endx, endy;
endx = startx;
endy = starty;
if (sizex > 0) {
endx = startx + linexy;
}
if (sizex < 0) {
endx = startx;
startx -= linexy;
}
if (sizey > 0) {
endy = starty + linexy;
}
if (sizey < 0) {
endy = starty;
starty -= linexy;
}
if (startx < 0) {
startx = 0;
}
if (endx < 0) {
endx = 0;
}
if (starty < 0) {
starty = 0;
}
if (endy < 0) {
endy = 0;
}
if (endx < 0) {
return;
}
if (endy < 0) {
return;
}
- trace_artist_draw_line(startx, starty, endx, endy);
draw_line(s, startx, starty, endx, endy, false, -1, -1);
}
static void draw_line_end(ARTISTState *s, bool update_start)
{
int startx = artist_get_x(s->vram_start);
int starty = artist_get_y(s->vram_start);
int endx = artist_get_x(s->line_end);
int endy = artist_get_y(s->line_end);
- trace_artist_draw_line(startx, starty, endx, endy);
draw_line(s, startx, starty, endx, endy, update_start, -1, -1);
}
--
2.21.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/5] hw/display/artist: Remove pointless initialization
2020-02-14 0:12 [PATCH 0/5] hw/display/artist: Fix Coverity 1419388 & 1419389 Philippe Mathieu-Daudé
2020-02-14 0:12 ` [PATCH 1/5] hw/display/artist: Move trace event to draw_line() Philippe Mathieu-Daudé
@ 2020-02-14 0:12 ` Philippe Mathieu-Daudé
2020-02-15 9:12 ` Sven Schnelle
2020-02-14 0:13 ` [PATCH 3/5] hw/display/artist: Delay some variables initialization Philippe Mathieu-Daudé
` (3 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-02-14 0:12 UTC (permalink / raw)
To: Helge Deller, qemu-devel, Sven Schnelle
Cc: Philippe Mathieu-Daudé, Gerd Hoffmann, Richard Henderson
We are initializating incy inconditionally:
if (y1 <= y2) {
incy = 1;
} else {
incy = -1;
}
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/display/artist.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/hw/display/artist.c b/hw/display/artist.c
index abacb0e27d..47f0e9f0bc 100644
--- a/hw/display/artist.c
+++ b/hw/display/artist.c
@@ -557,91 +557,90 @@ static void fill_window(ARTISTState *s, int startx, int starty,
static void draw_line(ARTISTState *s, int x1, int y1, int x2, int y2,
bool update_start, int skip_pix, int max_pix)
{
struct vram_buffer *buf;
uint8_t color = artist_get_color(s);
int dx, dy, t, e, x, y, incy, diago, horiz;
bool c1;
uint8_t *p;
trace_artist_draw_line(x1, y1, x2, y2);
if (update_start) {
s->vram_start = (x2 << 16) | y2;
}
buf = &s->vram_buffer[ARTIST_BUFFER_AP];
c1 = false;
- incy = 1;
if (x2 > x1) {
dx = x2 - x1;
} else {
dx = x1 - x2;
}
if (y2 > y1) {
dy = y2 - y1;
} else {
dy = y1 - y2;
}
if (dy > dx) {
t = y2;
y2 = x2;
x2 = t;
t = y1;
y1 = x1;
x1 = t;
t = dx;
dx = dy;
dy = t;
c1 = true;
}
if (x1 > x2) {
t = y2;
y2 = y1;
y1 = t;
t = x1;
x1 = x2;
x2 = t;
}
horiz = dy << 1;
diago = (dy - dx) << 1;
e = (dy << 1) - dx;
if (y1 <= y2) {
incy = 1;
} else {
incy = -1;
}
x = x1;
y = y1;
do {
if (c1) {
p = buf->data + x * s->width + y;
} else {
p = buf->data + y * s->width + x;
}
if (skip_pix > 0) {
skip_pix--;
} else {
artist_rop8(s, p, color);
}
if (e > 0) {
artist_invalidate_lines(buf, y, 1);
y += incy;
e += diago;
} else {
e += horiz;
}
x++;
} while (x <= x2 && (max_pix == -1 || --max_pix > 0));
}
--
2.21.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/5] hw/display/artist: Delay some variables initialization
2020-02-14 0:12 [PATCH 0/5] hw/display/artist: Fix Coverity 1419388 & 1419389 Philippe Mathieu-Daudé
2020-02-14 0:12 ` [PATCH 1/5] hw/display/artist: Move trace event to draw_line() Philippe Mathieu-Daudé
2020-02-14 0:12 ` [PATCH 2/5] hw/display/artist: Remove pointless initialization Philippe Mathieu-Daudé
@ 2020-02-14 0:13 ` Philippe Mathieu-Daudé
2020-02-15 9:12 ` Sven Schnelle
2020-02-14 0:13 ` [RFC PATCH 4/5] hw/display/artist: Avoid drawing line when nothing to display Philippe Mathieu-Daudé
` (2 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-02-14 0:13 UTC (permalink / raw)
To: Helge Deller, qemu-devel, Sven Schnelle
Cc: Philippe Mathieu-Daudé, Gerd Hoffmann, Richard Henderson
We want to have an early exit path. Delay some initializations
before the variables are used.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/display/artist.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/hw/display/artist.c b/hw/display/artist.c
index 47f0e9f0bc..97c811b35e 100644
--- a/hw/display/artist.c
+++ b/hw/display/artist.c
@@ -557,90 +557,90 @@ static void fill_window(ARTISTState *s, int startx, int starty,
static void draw_line(ARTISTState *s, int x1, int y1, int x2, int y2,
bool update_start, int skip_pix, int max_pix)
{
struct vram_buffer *buf;
- uint8_t color = artist_get_color(s);
+ uint8_t color;
int dx, dy, t, e, x, y, incy, diago, horiz;
bool c1;
uint8_t *p;
trace_artist_draw_line(x1, y1, x2, y2);
if (update_start) {
s->vram_start = (x2 << 16) | y2;
}
- buf = &s->vram_buffer[ARTIST_BUFFER_AP];
-
- c1 = false;
-
if (x2 > x1) {
dx = x2 - x1;
} else {
dx = x1 - x2;
}
if (y2 > y1) {
dy = y2 - y1;
} else {
dy = y1 - y2;
}
+
+ c1 = false;
if (dy > dx) {
t = y2;
y2 = x2;
x2 = t;
t = y1;
y1 = x1;
x1 = t;
t = dx;
dx = dy;
dy = t;
c1 = true;
}
if (x1 > x2) {
t = y2;
y2 = y1;
y1 = t;
t = x1;
x1 = x2;
x2 = t;
}
horiz = dy << 1;
diago = (dy - dx) << 1;
e = (dy << 1) - dx;
if (y1 <= y2) {
incy = 1;
} else {
incy = -1;
}
x = x1;
y = y1;
+ color = artist_get_color(s);
+ buf = &s->vram_buffer[ARTIST_BUFFER_AP];
do {
if (c1) {
p = buf->data + x * s->width + y;
} else {
p = buf->data + y * s->width + x;
}
if (skip_pix > 0) {
skip_pix--;
} else {
artist_rop8(s, p, color);
}
if (e > 0) {
artist_invalidate_lines(buf, y, 1);
y += incy;
e += diago;
} else {
e += horiz;
}
x++;
} while (x <= x2 && (max_pix == -1 || --max_pix > 0));
}
--
2.21.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [RFC PATCH 4/5] hw/display/artist: Avoid drawing line when nothing to display
2020-02-14 0:12 [PATCH 0/5] hw/display/artist: Fix Coverity 1419388 & 1419389 Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2020-02-14 0:13 ` [PATCH 3/5] hw/display/artist: Delay some variables initialization Philippe Mathieu-Daudé
@ 2020-02-14 0:13 ` Philippe Mathieu-Daudé
2020-02-14 0:13 ` [PATCH 5/5] hw/display/artist: Remove dead code (CID 1419388 & 1419389) Philippe Mathieu-Daudé
2020-02-16 1:45 ` [PATCH 0/5] hw/display/artist: Fix Coverity 1419388 & 1419389 Richard Henderson
5 siblings, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-02-14 0:13 UTC (permalink / raw)
To: Helge Deller, qemu-devel, Sven Schnelle
Cc: Philippe Mathieu-Daudé, Gerd Hoffmann, Richard Henderson
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
RFC because untested =)
---
hw/display/artist.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/hw/display/artist.c b/hw/display/artist.c
index 97c811b35e..5492079116 100644
--- a/hw/display/artist.c
+++ b/hw/display/artist.c
@@ -557,90 +557,93 @@ static void fill_window(ARTISTState *s, int startx, int starty,
static void draw_line(ARTISTState *s, int x1, int y1, int x2, int y2,
bool update_start, int skip_pix, int max_pix)
{
struct vram_buffer *buf;
uint8_t color;
int dx, dy, t, e, x, y, incy, diago, horiz;
bool c1;
uint8_t *p;
trace_artist_draw_line(x1, y1, x2, y2);
if (update_start) {
s->vram_start = (x2 << 16) | y2;
}
if (x2 > x1) {
dx = x2 - x1;
} else {
dx = x1 - x2;
}
if (y2 > y1) {
dy = y2 - y1;
} else {
dy = y1 - y2;
}
+ if (!dx || !dy) {
+ return;
+ }
c1 = false;
if (dy > dx) {
t = y2;
y2 = x2;
x2 = t;
t = y1;
y1 = x1;
x1 = t;
t = dx;
dx = dy;
dy = t;
c1 = true;
}
if (x1 > x2) {
t = y2;
y2 = y1;
y1 = t;
t = x1;
x1 = x2;
x2 = t;
}
horiz = dy << 1;
diago = (dy - dx) << 1;
e = (dy << 1) - dx;
if (y1 <= y2) {
incy = 1;
} else {
incy = -1;
}
x = x1;
y = y1;
color = artist_get_color(s);
buf = &s->vram_buffer[ARTIST_BUFFER_AP];
do {
if (c1) {
p = buf->data + x * s->width + y;
} else {
p = buf->data + y * s->width + x;
}
if (skip_pix > 0) {
skip_pix--;
} else {
artist_rop8(s, p, color);
}
if (e > 0) {
artist_invalidate_lines(buf, y, 1);
y += incy;
e += diago;
} else {
e += horiz;
}
x++;
} while (x <= x2 && (max_pix == -1 || --max_pix > 0));
}
--
2.21.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 5/5] hw/display/artist: Remove dead code (CID 1419388 & 1419389)
2020-02-14 0:12 [PATCH 0/5] hw/display/artist: Fix Coverity 1419388 & 1419389 Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2020-02-14 0:13 ` [RFC PATCH 4/5] hw/display/artist: Avoid drawing line when nothing to display Philippe Mathieu-Daudé
@ 2020-02-14 0:13 ` Philippe Mathieu-Daudé
2020-02-15 9:11 ` Sven Schnelle
2020-02-16 1:45 ` [PATCH 0/5] hw/display/artist: Fix Coverity 1419388 & 1419389 Richard Henderson
5 siblings, 1 reply; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-02-14 0:13 UTC (permalink / raw)
To: Helge Deller, qemu-devel, Sven Schnelle
Cc: Philippe Mathieu-Daudé, Gerd Hoffmann, Richard Henderson
Coverity reports:
*** CID 1419388: Control flow issues (DEADCODE)
/hw/display/artist.c: 739 in draw_line_xy()
733 if (endy < 0) {
734 endy = 0;
735 }
736
737
738 if (endx < 0) {
>>> CID 1419388: Control flow issues (DEADCODE)
>>> Execution cannot reach this statement: "return;".
739 return;
740 }
741
742 if (endy < 0) {
743 return;
744 }
*** CID 1419389: Control flow issues (DEADCODE)
/hw/display/artist.c: 743 in draw_line_xy()
737
738 if (endx < 0) {
739 return;
740 }
741
742 if (endy < 0) {
>>> CID 1419389: Control flow issues (DEADCODE)
>>> Execution cannot reach this statement: "return;".
743 return;
744 }
745
746 trace_artist_draw_line(startx, starty, endx, endy);
747 draw_line(s, startx, starty, endx, endy, false, -1, -1);
748 }
Fixes: Covertiy CID 1419388 and 1419389 (commit 4765384ce33)
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/display/artist.c | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/hw/display/artist.c b/hw/display/artist.c
index 5492079116..753dbb9a77 100644
--- a/hw/display/artist.c
+++ b/hw/display/artist.c
@@ -690,59 +690,50 @@ static void draw_line_size(ARTISTState *s, bool update_start)
static void draw_line_xy(ARTISTState *s, bool update_start)
{
int startx = artist_get_x(s->vram_start);
int starty = artist_get_y(s->vram_start);
int sizex = artist_get_x(s->blockmove_size);
int sizey = artist_get_y(s->blockmove_size);
int linexy = s->line_xy >> 16;
int endx, endy;
endx = startx;
endy = starty;
if (sizex > 0) {
endx = startx + linexy;
}
if (sizex < 0) {
endx = startx;
startx -= linexy;
}
if (sizey > 0) {
endy = starty + linexy;
}
if (sizey < 0) {
endy = starty;
starty -= linexy;
}
if (startx < 0) {
startx = 0;
}
if (endx < 0) {
endx = 0;
}
if (starty < 0) {
starty = 0;
}
if (endy < 0) {
endy = 0;
}
-
- if (endx < 0) {
- return;
- }
-
- if (endy < 0) {
- return;
- }
-
draw_line(s, startx, starty, endx, endy, false, -1, -1);
}
--
2.21.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 5/5] hw/display/artist: Remove dead code (CID 1419388 & 1419389)
2020-02-14 0:13 ` [PATCH 5/5] hw/display/artist: Remove dead code (CID 1419388 & 1419389) Philippe Mathieu-Daudé
@ 2020-02-15 9:11 ` Sven Schnelle
0 siblings, 0 replies; 11+ messages in thread
From: Sven Schnelle @ 2020-02-15 9:11 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Helge Deller, Gerd Hoffmann, qemu-devel, Richard Henderson
On Fri, Feb 14, 2020 at 01:13:02AM +0100, Philippe Mathieu-Daudé wrote:
> Coverity reports:
>
> *** CID 1419388: Control flow issues (DEADCODE)
> /hw/display/artist.c: 739 in draw_line_xy()
> 733 if (endy < 0) {
> 734 endy = 0;
> 735 }
> 736
> 737
> 738 if (endx < 0) {
> >>> CID 1419388: Control flow issues (DEADCODE)
> >>> Execution cannot reach this statement: "return;".
> 739 return;
> 740 }
> 741
> 742 if (endy < 0) {
> 743 return;
> 744 }
>
> *** CID 1419389: Control flow issues (DEADCODE)
> /hw/display/artist.c: 743 in draw_line_xy()
> 737
> 738 if (endx < 0) {
> 739 return;
> 740 }
> 741
> 742 if (endy < 0) {
> >>> CID 1419389: Control flow issues (DEADCODE)
> >>> Execution cannot reach this statement: "return;".
> 743 return;
> 744 }
> 745
> 746 trace_artist_draw_line(startx, starty, endx, endy);
> 747 draw_line(s, startx, starty, endx, endy, false, -1, -1);
> 748 }
>
> Fixes: Covertiy CID 1419388 and 1419389 (commit 4765384ce33)
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> hw/display/artist.c | 9 ---------
> 1 file changed, 9 deletions(-)
>
> diff --git a/hw/display/artist.c b/hw/display/artist.c
> index 5492079116..753dbb9a77 100644
> --- a/hw/display/artist.c
> +++ b/hw/display/artist.c
> @@ -690,59 +690,50 @@ static void draw_line_size(ARTISTState *s, bool update_start)
> static void draw_line_xy(ARTISTState *s, bool update_start)
> {
>
> int startx = artist_get_x(s->vram_start);
> int starty = artist_get_y(s->vram_start);
> int sizex = artist_get_x(s->blockmove_size);
> int sizey = artist_get_y(s->blockmove_size);
> int linexy = s->line_xy >> 16;
> int endx, endy;
>
> endx = startx;
> endy = starty;
>
> if (sizex > 0) {
> endx = startx + linexy;
> }
>
> if (sizex < 0) {
> endx = startx;
> startx -= linexy;
> }
>
> if (sizey > 0) {
> endy = starty + linexy;
> }
>
> if (sizey < 0) {
> endy = starty;
> starty -= linexy;
> }
>
> if (startx < 0) {
> startx = 0;
> }
>
> if (endx < 0) {
> endx = 0;
> }
>
> if (starty < 0) {
> starty = 0;
> }
>
> if (endy < 0) {
> endy = 0;
> }
>
> -
> - if (endx < 0) {
> - return;
> - }
> -
> - if (endy < 0) {
> - return;
> - }
> -
> draw_line(s, startx, starty, endx, endy, false, -1, -1);
> }
>
> --
> 2.21.1
>
Acked-by: Sven Schnelle <svens@stackframe.org>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/5] hw/display/artist: Delay some variables initialization
2020-02-14 0:13 ` [PATCH 3/5] hw/display/artist: Delay some variables initialization Philippe Mathieu-Daudé
@ 2020-02-15 9:12 ` Sven Schnelle
0 siblings, 0 replies; 11+ messages in thread
From: Sven Schnelle @ 2020-02-15 9:12 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Helge Deller, Gerd Hoffmann, qemu-devel, Richard Henderson
On Fri, Feb 14, 2020 at 01:13:00AM +0100, Philippe Mathieu-Daudé wrote:
> We want to have an early exit path. Delay some initializations
> before the variables are used.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> hw/display/artist.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/hw/display/artist.c b/hw/display/artist.c
> index 47f0e9f0bc..97c811b35e 100644
> --- a/hw/display/artist.c
> +++ b/hw/display/artist.c
> @@ -557,90 +557,90 @@ static void fill_window(ARTISTState *s, int startx, int starty,
> static void draw_line(ARTISTState *s, int x1, int y1, int x2, int y2,
> bool update_start, int skip_pix, int max_pix)
> {
> struct vram_buffer *buf;
> - uint8_t color = artist_get_color(s);
> + uint8_t color;
> int dx, dy, t, e, x, y, incy, diago, horiz;
> bool c1;
> uint8_t *p;
>
> trace_artist_draw_line(x1, y1, x2, y2);
>
> if (update_start) {
> s->vram_start = (x2 << 16) | y2;
> }
>
> - buf = &s->vram_buffer[ARTIST_BUFFER_AP];
> -
> - c1 = false;
> -
> if (x2 > x1) {
> dx = x2 - x1;
> } else {
> dx = x1 - x2;
> }
> if (y2 > y1) {
> dy = y2 - y1;
> } else {
> dy = y1 - y2;
> }
> +
> + c1 = false;
> if (dy > dx) {
> t = y2;
> y2 = x2;
> x2 = t;
>
> t = y1;
> y1 = x1;
> x1 = t;
>
> t = dx;
> dx = dy;
> dy = t;
>
> c1 = true;
> }
>
> if (x1 > x2) {
> t = y2;
> y2 = y1;
> y1 = t;
>
> t = x1;
> x1 = x2;
> x2 = t;
> }
>
> horiz = dy << 1;
> diago = (dy - dx) << 1;
> e = (dy << 1) - dx;
>
> if (y1 <= y2) {
> incy = 1;
> } else {
> incy = -1;
> }
> x = x1;
> y = y1;
> + color = artist_get_color(s);
> + buf = &s->vram_buffer[ARTIST_BUFFER_AP];
>
> do {
> if (c1) {
> p = buf->data + x * s->width + y;
> } else {
> p = buf->data + y * s->width + x;
> }
>
> if (skip_pix > 0) {
> skip_pix--;
> } else {
> artist_rop8(s, p, color);
> }
>
> if (e > 0) {
> artist_invalidate_lines(buf, y, 1);
> y += incy;
> e += diago;
> } else {
> e += horiz;
> }
> x++;
> } while (x <= x2 && (max_pix == -1 || --max_pix > 0));
> }
> --
> 2.21.1
>
Acked-by: Sven Schnelle <svens@stackframe.org>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/5] hw/display/artist: Remove pointless initialization
2020-02-14 0:12 ` [PATCH 2/5] hw/display/artist: Remove pointless initialization Philippe Mathieu-Daudé
@ 2020-02-15 9:12 ` Sven Schnelle
0 siblings, 0 replies; 11+ messages in thread
From: Sven Schnelle @ 2020-02-15 9:12 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Helge Deller, Gerd Hoffmann, qemu-devel, Richard Henderson
On Fri, Feb 14, 2020 at 01:12:59AM +0100, Philippe Mathieu-Daudé wrote:
> We are initializating incy inconditionally:
>
> if (y1 <= y2) {
> incy = 1;
> } else {
> incy = -1;
> }
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> hw/display/artist.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/hw/display/artist.c b/hw/display/artist.c
> index abacb0e27d..47f0e9f0bc 100644
> --- a/hw/display/artist.c
> +++ b/hw/display/artist.c
> @@ -557,91 +557,90 @@ static void fill_window(ARTISTState *s, int startx, int starty,
> static void draw_line(ARTISTState *s, int x1, int y1, int x2, int y2,
> bool update_start, int skip_pix, int max_pix)
> {
> struct vram_buffer *buf;
> uint8_t color = artist_get_color(s);
> int dx, dy, t, e, x, y, incy, diago, horiz;
> bool c1;
> uint8_t *p;
>
> trace_artist_draw_line(x1, y1, x2, y2);
>
> if (update_start) {
> s->vram_start = (x2 << 16) | y2;
> }
>
> buf = &s->vram_buffer[ARTIST_BUFFER_AP];
>
> c1 = false;
> - incy = 1;
>
> if (x2 > x1) {
> dx = x2 - x1;
> } else {
> dx = x1 - x2;
> }
> if (y2 > y1) {
> dy = y2 - y1;
> } else {
> dy = y1 - y2;
> }
> if (dy > dx) {
> t = y2;
> y2 = x2;
> x2 = t;
>
> t = y1;
> y1 = x1;
> x1 = t;
>
> t = dx;
> dx = dy;
> dy = t;
>
> c1 = true;
> }
>
> if (x1 > x2) {
> t = y2;
> y2 = y1;
> y1 = t;
>
> t = x1;
> x1 = x2;
> x2 = t;
> }
>
> horiz = dy << 1;
> diago = (dy - dx) << 1;
> e = (dy << 1) - dx;
>
> if (y1 <= y2) {
> incy = 1;
> } else {
> incy = -1;
> }
> x = x1;
> y = y1;
>
> do {
> if (c1) {
> p = buf->data + x * s->width + y;
> } else {
> p = buf->data + y * s->width + x;
> }
>
> if (skip_pix > 0) {
> skip_pix--;
> } else {
> artist_rop8(s, p, color);
> }
>
> if (e > 0) {
> artist_invalidate_lines(buf, y, 1);
> y += incy;
> e += diago;
> } else {
> e += horiz;
> }
> x++;
> } while (x <= x2 && (max_pix == -1 || --max_pix > 0));
> }
> --
> 2.21.1
>
Acked-by: Sven Schnelle <svens@stackframe.org>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/5] hw/display/artist: Move trace event to draw_line()
2020-02-14 0:12 ` [PATCH 1/5] hw/display/artist: Move trace event to draw_line() Philippe Mathieu-Daudé
@ 2020-02-15 9:12 ` Sven Schnelle
0 siblings, 0 replies; 11+ messages in thread
From: Sven Schnelle @ 2020-02-15 9:12 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Helge Deller, Gerd Hoffmann, qemu-devel, Richard Henderson
On Fri, Feb 14, 2020 at 01:12:58AM +0100, Philippe Mathieu-Daudé wrote:
> Instead of emitting the trace event before each call to
> draw_line(), call it once at draw_line() entrance.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> hw/display/artist.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/hw/display/artist.c b/hw/display/artist.c
> index 65be9e3554..abacb0e27d 100644
> --- a/hw/display/artist.c
> +++ b/hw/display/artist.c
> @@ -557,90 +557,91 @@ static void fill_window(ARTISTState *s, int startx, int starty,
> static void draw_line(ARTISTState *s, int x1, int y1, int x2, int y2,
> bool update_start, int skip_pix, int max_pix)
> {
> struct vram_buffer *buf;
> uint8_t color = artist_get_color(s);
> int dx, dy, t, e, x, y, incy, diago, horiz;
> bool c1;
> uint8_t *p;
>
> + trace_artist_draw_line(x1, y1, x2, y2);
>
> if (update_start) {
> s->vram_start = (x2 << 16) | y2;
> }
>
> buf = &s->vram_buffer[ARTIST_BUFFER_AP];
>
> c1 = false;
> incy = 1;
>
> if (x2 > x1) {
> dx = x2 - x1;
> } else {
> dx = x1 - x2;
> }
> if (y2 > y1) {
> dy = y2 - y1;
> } else {
> dy = y1 - y2;
> }
> if (dy > dx) {
> t = y2;
> y2 = x2;
> x2 = t;
>
> t = y1;
> y1 = x1;
> x1 = t;
>
> t = dx;
> dx = dy;
> dy = t;
>
> c1 = true;
> }
>
> if (x1 > x2) {
> t = y2;
> y2 = y1;
> y1 = t;
>
> t = x1;
> x1 = x2;
> x2 = t;
> }
>
> horiz = dy << 1;
> diago = (dy - dx) << 1;
> e = (dy << 1) - dx;
>
> if (y1 <= y2) {
> incy = 1;
> } else {
> incy = -1;
> }
> x = x1;
> y = y1;
>
> do {
> if (c1) {
> p = buf->data + x * s->width + y;
> } else {
> p = buf->data + y * s->width + x;
> }
>
> if (skip_pix > 0) {
> skip_pix--;
> } else {
> artist_rop8(s, p, color);
> }
>
> if (e > 0) {
> artist_invalidate_lines(buf, y, 1);
> y += incy;
> e += diago;
> } else {
> e += horiz;
> }
> x++;
> } while (x <= x2 && (max_pix == -1 || --max_pix > 0));
> }
> @@ -648,13 +649,12 @@ static void draw_line(ARTISTState *s, int x1, int y1, int x2, int y2,
> static void draw_line_pattern_start(ARTISTState *s)
> {
>
> int startx = artist_get_x(s->vram_start);
> int starty = artist_get_y(s->vram_start);
> int endx = artist_get_x(s->blockmove_size);
> int endy = artist_get_y(s->blockmove_size);
> int pstart = s->line_pattern_start >> 16;
>
> - trace_artist_draw_line(startx, starty, endx, endy);
> draw_line(s, startx, starty, endx, endy, false, -1, pstart);
> s->line_pattern_skip = pstart;
> }
> @@ -662,15 +662,14 @@ static void draw_line_pattern_start(ARTISTState *s)
> static void draw_line_pattern_next(ARTISTState *s)
> {
>
> int startx = artist_get_x(s->vram_start);
> int starty = artist_get_y(s->vram_start);
> int endx = artist_get_x(s->blockmove_size);
> int endy = artist_get_y(s->blockmove_size);
> int line_xy = s->line_xy >> 16;
>
> - trace_artist_draw_line(startx, starty, endx, endy);
> draw_line(s, startx, starty, endx, endy, false, s->line_pattern_skip,
> s->line_pattern_skip + line_xy);
> s->line_pattern_skip += line_xy;
> s->image_bitmap_op ^= 2;
> }
> @@ -678,84 +677,81 @@ static void draw_line_pattern_next(ARTISTState *s)
> static void draw_line_size(ARTISTState *s, bool update_start)
> {
>
> int startx = artist_get_x(s->vram_start);
> int starty = artist_get_y(s->vram_start);
> int endx = artist_get_x(s->line_size);
> int endy = artist_get_y(s->line_size);
>
> - trace_artist_draw_line(startx, starty, endx, endy);
> draw_line(s, startx, starty, endx, endy, update_start, -1, -1);
> }
>
> static void draw_line_xy(ARTISTState *s, bool update_start)
> {
>
> int startx = artist_get_x(s->vram_start);
> int starty = artist_get_y(s->vram_start);
> int sizex = artist_get_x(s->blockmove_size);
> int sizey = artist_get_y(s->blockmove_size);
> int linexy = s->line_xy >> 16;
> int endx, endy;
>
> endx = startx;
> endy = starty;
>
> if (sizex > 0) {
> endx = startx + linexy;
> }
>
> if (sizex < 0) {
> endx = startx;
> startx -= linexy;
> }
>
> if (sizey > 0) {
> endy = starty + linexy;
> }
>
> if (sizey < 0) {
> endy = starty;
> starty -= linexy;
> }
>
> if (startx < 0) {
> startx = 0;
> }
>
> if (endx < 0) {
> endx = 0;
> }
>
> if (starty < 0) {
> starty = 0;
> }
>
> if (endy < 0) {
> endy = 0;
> }
>
>
> if (endx < 0) {
> return;
> }
>
> if (endy < 0) {
> return;
> }
>
> - trace_artist_draw_line(startx, starty, endx, endy);
> draw_line(s, startx, starty, endx, endy, false, -1, -1);
> }
>
> static void draw_line_end(ARTISTState *s, bool update_start)
> {
>
> int startx = artist_get_x(s->vram_start);
> int starty = artist_get_y(s->vram_start);
> int endx = artist_get_x(s->line_end);
> int endy = artist_get_y(s->line_end);
>
> - trace_artist_draw_line(startx, starty, endx, endy);
> draw_line(s, startx, starty, endx, endy, update_start, -1, -1);
> }
>
> --
> 2.21.1
>
Acked-by: Sven Schnelle <svens@stackframe.org>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 0/5] hw/display/artist: Fix Coverity 1419388 & 1419389
2020-02-14 0:12 [PATCH 0/5] hw/display/artist: Fix Coverity 1419388 & 1419389 Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2020-02-14 0:13 ` [PATCH 5/5] hw/display/artist: Remove dead code (CID 1419388 & 1419389) Philippe Mathieu-Daudé
@ 2020-02-16 1:45 ` Richard Henderson
5 siblings, 0 replies; 11+ messages in thread
From: Richard Henderson @ 2020-02-16 1:45 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, Helge Deller, qemu-devel, Sven Schnelle
Cc: Gerd Hoffmann, Richard Henderson
On 2/13/20 4:12 PM, Philippe Mathieu-Daudé wrote:
> Another easy Coverity fix.
>
> Philippe Mathieu-Daudé (5):
> hw/display/artist: Move trace event to draw_line()
> hw/display/artist: Remove pointless initialization
> hw/display/artist: Delay some variables initialization
> hw/display/artist: Avoid drawing line when nothing to display
> hw/display/artist: Remove dead code (CID 1419388 & 1419389)
>
> hw/display/artist.c | 29 +++++++++--------------------
> 1 file changed, 9 insertions(+), 20 deletions(-)
>
Queued to tgt-hppa.
r~
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2020-02-16 1:47 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-14 0:12 [PATCH 0/5] hw/display/artist: Fix Coverity 1419388 & 1419389 Philippe Mathieu-Daudé
2020-02-14 0:12 ` [PATCH 1/5] hw/display/artist: Move trace event to draw_line() Philippe Mathieu-Daudé
2020-02-15 9:12 ` Sven Schnelle
2020-02-14 0:12 ` [PATCH 2/5] hw/display/artist: Remove pointless initialization Philippe Mathieu-Daudé
2020-02-15 9:12 ` Sven Schnelle
2020-02-14 0:13 ` [PATCH 3/5] hw/display/artist: Delay some variables initialization Philippe Mathieu-Daudé
2020-02-15 9:12 ` Sven Schnelle
2020-02-14 0:13 ` [RFC PATCH 4/5] hw/display/artist: Avoid drawing line when nothing to display Philippe Mathieu-Daudé
2020-02-14 0:13 ` [PATCH 5/5] hw/display/artist: Remove dead code (CID 1419388 & 1419389) Philippe Mathieu-Daudé
2020-02-15 9:11 ` Sven Schnelle
2020-02-16 1:45 ` [PATCH 0/5] hw/display/artist: Fix Coverity 1419388 & 1419389 Richard Henderson
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.