Message ID | 20200325025919.21316-3-kuhn.chenqun@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | redundant code: Fix warnings reported by Clang static code analyzer | expand |
Le 25/03/2020 à 03:59, Chen Qun a écrit : > Clang static code analyzer show warning: > hw/display/blizzard.c:940:9: warning: Value stored to 'data' is never read > data >>= 5; > ^ ~ > Reported-by: Euler Robot <euler.robot@huawei.com> > Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com> > --- > Cc: Andrzej Zaborowski <balrogg@gmail.com> > Cc: Peter Maydell <peter.maydell@linaro.org> > > v1->v2: Use extract16() function instead of bit operation(Base on Laurent's comments). > --- > hw/display/blizzard.c | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/hw/display/blizzard.c b/hw/display/blizzard.c > index 359e399c2a..105241577d 100644 > --- a/hw/display/blizzard.c > +++ b/hw/display/blizzard.c > @@ -19,6 +19,7 @@ > */ > > #include "qemu/osdep.h" > +#include "qemu/bitops.h" > #include "ui/console.h" > #include "hw/display/blizzard.h" > #include "ui/pixel_ops.h" > @@ -932,12 +933,9 @@ static void blizzard_draw_line16_32(uint32_t *dest, > const uint16_t *end = (const void *) src + width; > while (src < end) { > data = *src ++; > - b = (data & 0x1f) << 3; > - data >>= 5; > - g = (data & 0x3f) << 2; > - data >>= 6; > - r = (data & 0x1f) << 3; > - data >>= 5; > + b = extract16(data, 0, 5) << 3; > + g = extract16(data, 5, 6) << 2; > + r = extract16(data, 11, 5) << 3; > *dest++ = rgb_to_pixel32(r, g, b); > } > } > Reviewed-by: Laurent Vivier <laurent@vivier.eu>
diff --git a/hw/display/blizzard.c b/hw/display/blizzard.c index 359e399c2a..105241577d 100644 --- a/hw/display/blizzard.c +++ b/hw/display/blizzard.c @@ -19,6 +19,7 @@ */ #include "qemu/osdep.h" +#include "qemu/bitops.h" #include "ui/console.h" #include "hw/display/blizzard.h" #include "ui/pixel_ops.h" @@ -932,12 +933,9 @@ static void blizzard_draw_line16_32(uint32_t *dest, const uint16_t *end = (const void *) src + width; while (src < end) { data = *src ++; - b = (data & 0x1f) << 3; - data >>= 5; - g = (data & 0x3f) << 2; - data >>= 6; - r = (data & 0x1f) << 3; - data >>= 5; + b = extract16(data, 0, 5) << 3; + g = extract16(data, 5, 6) << 2; + r = extract16(data, 11, 5) << 3; *dest++ = rgb_to_pixel32(r, g, b); } }
Clang static code analyzer show warning: hw/display/blizzard.c:940:9: warning: Value stored to 'data' is never read data >>= 5; ^ ~ Reported-by: Euler Robot <euler.robot@huawei.com> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com> --- Cc: Andrzej Zaborowski <balrogg@gmail.com> Cc: Peter Maydell <peter.maydell@linaro.org> v1->v2: Use extract16() function instead of bit operation(Base on Laurent's comments). --- hw/display/blizzard.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)