qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH-for-9.1 v2] hw/ide/pci.c: Remove dead code from bmdma_prepare_buf()
@ 2024-08-05 18:24 Philippe Mathieu-Daudé
  2024-08-05 23:13 ` Richard Henderson
  2024-08-06  8:32 ` Philippe Mathieu-Daudé
  0 siblings, 2 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-08-05 18:24 UTC (permalink / raw)
  To: qemu-devel
  Cc: John Snow, qemu-block, Peter Maydell, Kevin Wolf,
	Philippe Mathieu-Daudé

From: Peter Maydell <peter.maydell@linaro.org>

Coverity notes that the code at the end of the loop in
bmdma_prepare_buf() is unreachable.  This is because in commit
9fbf0fa81fca8f527 ("ide: remove hardcoded 2GiB transactional limit")
we removed the only codepath in the loop which could "break" out of
it, but didn't notice that this meant we should also remove the code
at the end of the loop.

Remove the dead code.

Resolves: Coverity CID 1547772
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
v2: Break and return once at EOF
---
 hw/ide/pci.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/hw/ide/pci.c b/hw/ide/pci.c
index 4675d079a1..a008fe7316 100644
--- a/hw/ide/pci.c
+++ b/hw/ide/pci.c
@@ -237,7 +237,7 @@ static int32_t bmdma_prepare_buf(const IDEDMA *dma, int32_t limit)
             /* end of table (with a fail safe of one page) */
             if (bm->cur_prd_last ||
                 (bm->cur_addr - bm->addr) >= BMDMA_PAGE_SIZE) {
-                return s->sg.size;
+                break;
             }
             pci_dma_read(pci_dev, bm->cur_addr, &prd, 8);
             bm->cur_addr += 8;
@@ -266,10 +266,7 @@ static int32_t bmdma_prepare_buf(const IDEDMA *dma, int32_t limit)
             s->io_buffer_size += l;
         }
     }
-
-    qemu_sglist_destroy(&s->sg);
-    s->io_buffer_size = 0;
-    return -1;
+    return s->sg.size;
 }
 
 /* return 0 if buffer completed */
-- 
2.45.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH-for-9.1 v2] hw/ide/pci.c: Remove dead code from bmdma_prepare_buf()
  2024-08-05 18:24 [PATCH-for-9.1 v2] hw/ide/pci.c: Remove dead code from bmdma_prepare_buf() Philippe Mathieu-Daudé
@ 2024-08-05 23:13 ` Richard Henderson
  2024-08-06  8:32 ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Henderson @ 2024-08-05 23:13 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: John Snow, qemu-block, Peter Maydell, Kevin Wolf

On 8/6/24 04:24, Philippe Mathieu-Daudé wrote:
> From: Peter Maydell<peter.maydell@linaro.org>
> 
> Coverity notes that the code at the end of the loop in
> bmdma_prepare_buf() is unreachable.  This is because in commit
> 9fbf0fa81fca8f527 ("ide: remove hardcoded 2GiB transactional limit")
> we removed the only codepath in the loop which could "break" out of
> it, but didn't notice that this meant we should also remove the code
> at the end of the loop.
> 
> Remove the dead code.
> 
> Resolves: Coverity CID 1547772
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> Reviewed-by: Kevin Wolf<kwolf@redhat.com>
> Reviewed-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> v2: Break and return once at EOF
> ---
>   hw/ide/pci.c | 7 ++-----
>   1 file changed, 2 insertions(+), 5 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH-for-9.1 v2] hw/ide/pci.c: Remove dead code from bmdma_prepare_buf()
  2024-08-05 18:24 [PATCH-for-9.1 v2] hw/ide/pci.c: Remove dead code from bmdma_prepare_buf() Philippe Mathieu-Daudé
  2024-08-05 23:13 ` Richard Henderson
@ 2024-08-06  8:32 ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-08-06  8:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: John Snow, qemu-block, Peter Maydell, Kevin Wolf

On 5/8/24 20:24, Philippe Mathieu-Daudé wrote:
> From: Peter Maydell <peter.maydell@linaro.org>
> 
> Coverity notes that the code at the end of the loop in
> bmdma_prepare_buf() is unreachable.  This is because in commit
> 9fbf0fa81fca8f527 ("ide: remove hardcoded 2GiB transactional limit")
> we removed the only codepath in the loop which could "break" out of
> it, but didn't notice that this meant we should also remove the code
> at the end of the loop.
> 
> Remove the dead code.
> 
> Resolves: Coverity CID 1547772
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> Reviewed-by: Kevin Wolf <kwolf@redhat.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> v2: Break and return once at EOF
> ---
>   hw/ide/pci.c | 7 ++-----
>   1 file changed, 2 insertions(+), 5 deletions(-)

Patch queued.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-08-06  8:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-05 18:24 [PATCH-for-9.1 v2] hw/ide/pci.c: Remove dead code from bmdma_prepare_buf() Philippe Mathieu-Daudé
2024-08-05 23:13 ` Richard Henderson
2024-08-06  8:32 ` Philippe Mathieu-Daudé

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).