msf2: Remove dead code reported by Coverity
PATCH v3 1/1 msf2: Remove dead code reported by Coverity
Fixed incorrect frame size mask, validated maximum frame size in spi_write and removed dead code.
---
v3:
Added comment that [31:6] bits are reserved in R_SPI_DFSIZE register and logged incorrect value too in guest error(suggested
by Darren).
v2:
else if -> else in set_fifodepth
log guest error when frame size is more than 32
hw/ssi/mss-spi.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
hw/ssi/mss-spi.c +14 -4
@@ -76,9 +76,10 @@#define C_BIGFIFO (1 << 29)#define C_RESET (1 << 31) -#define FRAMESZ_MASK 0x1F +#define FRAMESZ_MASK 0x3F#define FMCOUNT_MASK 0x00FFFF00#define FMCOUNT_SHIFT 8 +#define FRAMESZ_MAX 32static void txfifo_reset (MSSSpiState *s) {
@@ -104,10 +105,8 @@ static void set_fifodepth(MSSSpiState *s) s->fifo_depth =32 ; }else if (size <=16 ) { s->fifo_depth =16 ; - }else if (size <=32 ) { - s->fifo_depth =8 ; }else { - s->fifo_depth =4 ; + s->fifo_depth =8 ; } }
@@ -301,6 +300,17 @@ static void spi_write(void *opaque, hwaddr addr,if (s->enabled) {break ; } +/* +* [31:6] bits are reserved bits and for future use. +* [5:0] are for frame size. Only [5:0] bits are validated +* during write, [31:6] bits are untouched. +*/ +if ((value &FRAMESZ_MASK ) >FRAMESZ_MAX ) { +qemu_log_mask (LOG_GUEST_ERROR ,"%s: Incorrect size %d provided." +"Maximum frame size is %d\n" , + __func__, value &FRAMESZ_MASK ,FRAMESZ_MAX ); +break ; + } s->regs[R_SPI_DFSIZE ] = value;break ;
Signature · 1 line
2.5.0
This series failed automatic build test. Please find the testing commands and their output below. If you have docker installed, you can probably reproduce it locally.
Hi,
This series failed automatic build test. Please find the testing commands and their output below. If you have docker installed, you can probably reproduce it locally.
Type: series
Message-id: [email protected]
Subject: [Qemu-devel] [Qemu devel v3 PATCH] msf2: Remove dead code reported by Coverity
=== TEST SCRIPT BEGIN ===
#!/bin/bash
set -e
git submodule update --init dtc
# Let docker tests dump environment info
export SHOW_ENV=1
export J=8
time make docker-test-quick@centos6
time make docker-test-build@min-glib
time make docker-test-mingw@fedora
time make docker-test-block@fedora
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'a1c66b66e7 msf2: Remove dead code reported by Coverity
=== OUTPUT BEGIN ===
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc' Cloning into '/var/tmp/patchew-tester-tmp-egubaaoc/src/dtc'...
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git://git.qemu-project.org/dtc.git' into submodule path '/var/tmp/patchew-tester-tmp-egubaaoc/src/dtc' failed Failed to clone 'dtc'. Retry scheduled
Cloning into '/var/tmp/patchew-tester-tmp-egubaaoc/src/dtc'...
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git://git.qemu-project.org/dtc.git' into submodule path '/var/tmp/patchew-tester-tmp-egubaaoc/src/dtc' failed Failed to clone 'dtc' a second time, aborting
=== OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]
Hi Peter,
Quoted 48 lines · On Sun, Oct 22, 2017 at 7:35 PM, <[email protected]> wrote:
Hi,
This series failed automatic build test. Please find the testing commands and
their output below. If you have docker installed, you can probably reproduce it
locally.Type: series
Message-id: [email protected]
Subject: [Qemu-devel] [Qemu devel v3 PATCH] msf2: Remove dead code reported by Coverity=== TEST SCRIPT BEGIN ===
#!/bin/bash
set -e
git submodule update --init dtc
# Let docker tests dump environment info
export SHOW_ENV=1
export J=8
time make docker-test-quick@centos6
time make docker-test-build@min-glib
time make docker-test-mingw@fedora
time make docker-test-block@fedora
=== TEST SCRIPT END ===Updating
3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/1508678882-4327-1-git-
[email protected] -> patchew/1508678882-4327-1-git- [email protected]
Switched to a new branch 'test'a1c66b66e7msf2: Remove dead code reported by Coverity=== OUTPUT BEGIN ===
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into '/var/tmp/patchew-tester-tmp-egubaaoc/src/dtc'...
fatal: Could not read from remote repository.Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git://git.qemu-project.org/dtc.git' into submodule path '/var/tmp/patchew-tester-tmp-egubaaoc/src/dtc' failed
Failed to clone 'dtc'. Retry scheduled
Cloning into '/var/tmp/patchew-tester-tmp-egubaaoc/src/dtc'...
fatal: Could not read from remote repository.
Quoted 9 lines
Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git://git.qemu-project.org/dtc.git' into submodule path '/var/tmp/patchew-tester-tmp-egubaaoc/src/dtc' failed
Failed to clone 'dtc' a second time, aborting
=== OUTPUT END ===Test command exited with code: 1
I did not understand. Is the error related to my patch?
Thanks,
Sundeep
Quoted 6 lines
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]
Quoted 10 lines · sundeep subbaraya
Quoted 10 lines
Cloning into '
/var/tmp/patchew-tester-tmp-egubaaoc/src/dtc'...
fatal: Could not read from remote repository.Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git://git.qemu-project.org/dtc.git' into submodule path '/var/tmp/patchew-tester-tmp-egubaaoc/src/dtc' failed
Failed to clone 'dtc' a second time, aborting
=== OUTPUT END ===
Quoted 4 lines
Quoted 2 lines
Test command exited with code: 1
I did not understand. Is the error related to my patch?
Nope, there is something wrong with the testing bot.
Fam
Hi Fam,
Quoted 12 lines · Fam Zheng
Quoted 6 lines · sundeep subbaraya
Quoted 6 lines
Cloning into '
/var/tmp/patchew-tester-tmp-egubaaoc/src/dtc'...
fatal: Could not read from remote repository.Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git://git.qemu-project.org/dtc.git' into submodulepath
Quoted 4 lines
Quoted 4 lines
'
/var/tmp/patchew-tester-tmp-egubaaoc/src/dtc' failed Failed to clone 'dtc' a second time, aborting === OUTPUT END ===
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Test command exited with code: 1
I did not understand. Is the error related to my patch?
Nope, there is something wrong with the testing bot.
Ok.
Thanks,
Sundeep
Quoted 3 lines
Fam
Quoted 47 lines · Subbaraya Sundeep
Fixed incorrect frame size mask, validated maximum frame size in
spi_writeand removed dead code.Signed-off-by Subbaraya Sundeep <[email protected]>---
v3:
Added comment that [31:6] bits are reserved inR_SPI_DFSIZEregister and logged incorrect value too in guest error(suggested
by Darren).
v2:
else if -> else inset_fifodepth
log guest error when frame size is more than 32
hw/ssi/mss-spi.c| 18 ++++++++++++++----1 file changed, 14 insertions(+), 4 deletions(-)hw/ssi/mss-spi.c +3
-4@@ -76,9 +76,10 @@#define C_BIGFIFO (1 << 29)#define C_RESET (1 << 31) -#define FRAMESZ_MASK 0x1F +#define FRAMESZ_MASK 0x3F#define FMCOUNT_MASK 0x00FFFF00#define FMCOUNT_SHIFT 8 +#define FRAMESZ_MAX 32static void txfifo_reset (MSSSpiState *s) {@@ -104,10 +105,8 @@ static void set_fifodepth(MSSSpiState *s) s->fifo_depth =32 ; }else if (size <=16 ) { s->fifo_depth =16 ; - }else if (size <=32 ) { - s->fifo_depth =8 ; }else { - s->fifo_depth =4 ; + s->fifo_depth =8 ; } }@@ -301,6 +300,17 @@ static void spi_write(void *opaque, hwaddr addr,if (s->enabled) {break ;
hw/ssi/mss-spi.c static void spi_write(void *opaque, hwaddr addr, · line 311
Quoted 10 lines
hw/ssi/mss-spi.c +9
-0} +/* +* [31:6] bits are reserved bits and for future use. +* [5:0] are for frame size. Only [5:0] bits are validated +* during write, [31:6] bits are untouched. +*/ +if ((value &FRAMESZ_MASK ) >FRAMESZ_MAX ) { +qemu_log_mask (LOG_GUEST_ERROR ,"%s: Incorrect size %d provided." +"Maximum frame size is %d\n" , + __func__, value &FRAMESZ_MASK ,FRAMESZ_MAX );
Nitpicking here really, but shouldn't the %d be %u since value is a uint32_t?
Thanks,
Darren.
Quoted 9 lines
hw/ssi/mss-spi.c +2
-0+break ; + } s->regs[R_SPI_DFSIZE ] = value;break ;Signature · 1 line
2.5.0
Hi Darren,
Quoted 65 lines · Darren Kenny
Quoted 57 lines · Subbaraya Sundeep
Fixed incorrect frame size mask, validated maximum frame size in
spi_writeand removed dead code.Signed-off-by Subbaraya Sundeep <[email protected]>---
v3:
Added comment that [31:6] bits are reserved inR_SPI_DFSIZEregister and logged incorrect value too in guest error(suggested
by Darren).
v2:
else if -> else inset_fifodepth
log guest error when frame size is more than 32
hw/ssi/mss-spi.c| 18 ++++++++++++++----1 file changed, 14 insertions(+), 4 deletions(-)hw/ssi/mss-spi.c +10
-4@@ -76,9 +76,10 @@#define C_BIGFIFO (1 << 29)#define C_RESET (1 << 31) -#define FRAMESZ_MASK 0x1F +#define FRAMESZ_MASK 0x3F#define FMCOUNT_MASK 0x00FFFF00#define FMCOUNT_SHIFT 8 +#define FRAMESZ_MAX 32static void txfifo_reset (MSSSpiState *s) {@@ -104,10 +105,8 @@ static void set_fifodepth(MSSSpiState *s) s->fifo_depth =32 ; }else if (size <=16 ) { s->fifo_depth =16 ; - }else if (size <=32 ) { - s->fifo_depth =8 ; }else { - s->fifo_depth =4 ; + s->fifo_depth =8 ; } }@@ -301,6 +300,17 @@ static void spi_write(void *opaque, hwaddr addr,if (s->enabled) {break ; } +/* +* [31:6] bits are reserved bits and for future use. +* [5:0] are for frame size. Only [5:0] bits are validated +* during write, [31:6] bits are untouched. +*/ +if ((value &FRAMESZ_MASK ) >FRAMESZ_MAX ) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: Incorrect size %dprovided."
hw/ssi/mss-spi.c static void spi_write(void *opaque, hwaddr addr, · line 311
Quoted 2 lines
hw/ssi/mss-spi.c +2
-0+"Maximum frame size is %d\n" , + __func__, value & FRAMESZ_MASK, FRAMESZ_MAX);Nitpicking here really, but shouldn't the %d be %u since value is a
uint32_t?
Quoted 1 line
Ok I will change to %u.
Thanks,
Sundeep
Quoted 15 lines
Thanks,
Darren.
+ break;
Quoted 9 lines
+ }
s->regs[R_SPI_DFSIZE] = value; break;--
2.5.0