[Qemu-devel] [PATCH] es1370: more fixes for ADC_FRAMEADR and ADC_FRAMECNT

Paolo Bonzini posted 1 patch 7 years ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20181016135027.9856-1-pbonzini@redhat.com
Test docker-clang@ubuntu passed
Test checkpatch passed
Test asan passed
Test docker-mingw@fedora failed
Test docker-quick@centos7 passed
hw/audio/es1370.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
[Qemu-devel] [PATCH] es1370: more fixes for ADC_FRAMEADR and ADC_FRAMECNT
Posted by Paolo Bonzini 7 years ago
They are not consecutive with DAC1_FRAME* and DAC2_FRAME*; Coverity
still complains about es1370_read, while es1370_write was fixed in
commit cf9270e5220671f49cc238deaf6136669cc07ae1.

Fixes: 154c1d1f960c5147a3f8ef00907504112f271cd8
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/audio/es1370.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c
index 4f980a598b..aa5a8d728c 100644
--- a/hw/audio/es1370.c
+++ b/hw/audio/es1370.c
@@ -585,9 +585,12 @@ static uint64_t es1370_read(void *opaque, hwaddr addr, unsigned size)
 #endif
         break;
 
+    case ES1370_REG_ADC_FRAMECNT:
+        d += 2;
+        goto framecnt;
     case ES1370_REG_DAC1_FRAMECNT:
     case ES1370_REG_DAC2_FRAMECNT:
-    case ES1370_REG_ADC_FRAMECNT:
+    framecnt:
         d += (addr - ES1370_REG_DAC1_FRAMECNT) >> 3;
         val = d->frame_cnt;
 #ifdef DEBUG_ES1370
@@ -602,9 +605,12 @@ static uint64_t es1370_read(void *opaque, hwaddr addr, unsigned size)
 #endif
         break;
 
+    case ES1370_REG_ADC_FRAMEADR:
+        d += 2;
+        goto frameadr;
     case ES1370_REG_DAC1_FRAMEADR:
     case ES1370_REG_DAC2_FRAMEADR:
-    case ES1370_REG_ADC_FRAMEADR:
+    frameadr:
         d += (addr - ES1370_REG_DAC1_FRAMEADR) >> 3;
         val = d->frame_addr;
         break;
-- 
2.17.1


Re: [Qemu-devel] [PATCH] es1370: more fixes for ADC_FRAMEADR and ADC_FRAMECNT
Posted by Thomas Huth 7 years ago
On 2018-10-16 15:50, Paolo Bonzini wrote:
> They are not consecutive with DAC1_FRAME* and DAC2_FRAME*; Coverity
> still complains about es1370_read, while es1370_write was fixed in
> commit cf9270e5220671f49cc238deaf6136669cc07ae1.
> 
> Fixes: 154c1d1f960c5147a3f8ef00907504112f271cd8
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  hw/audio/es1370.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c
> index 4f980a598b..aa5a8d728c 100644
> --- a/hw/audio/es1370.c
> +++ b/hw/audio/es1370.c
> @@ -585,9 +585,12 @@ static uint64_t es1370_read(void *opaque, hwaddr addr, unsigned size)
>  #endif
>          break;
>  
> +    case ES1370_REG_ADC_FRAMECNT:
> +        d += 2;
> +        goto framecnt;
>      case ES1370_REG_DAC1_FRAMECNT:
>      case ES1370_REG_DAC2_FRAMECNT:
> -    case ES1370_REG_ADC_FRAMECNT:
> +    framecnt:
>          d += (addr - ES1370_REG_DAC1_FRAMECNT) >> 3;
>          val = d->frame_cnt;
>  #ifdef DEBUG_ES1370
> @@ -602,9 +605,12 @@ static uint64_t es1370_read(void *opaque, hwaddr addr, unsigned size)
>  #endif
>          break;
>  
> +    case ES1370_REG_ADC_FRAMEADR:
> +        d += 2;
> +        goto frameadr;
>      case ES1370_REG_DAC1_FRAMEADR:
>      case ES1370_REG_DAC2_FRAMEADR:
> -    case ES1370_REG_ADC_FRAMEADR:
> +    frameadr:
>          d += (addr - ES1370_REG_DAC1_FRAMEADR) >> 3;
>          val = d->frame_addr;
>          break;
> 

It's in a pull request already, so this is likely too late: But for the
next time, could you maybe rather use a "/* fall through */" comment
instead of a goto? That looks less ugly.

 Thomas


Re: [Qemu-devel] [PATCH] es1370: more fixes for ADC_FRAMEADR and ADC_FRAMECNT
Posted by Paolo Bonzini 7 years ago
On 19/10/2018 10:46, Thomas Huth wrote:
>>
> It's in a pull request already, so this is likely too late: But for the
> next time, could you maybe rather use a "/* fall through */" comment
> instead of a goto? That looks less ugly.

Wait, it's not ugly, it's wrong.  The label is placed incorrectly.

Paolo