diff mbox series

[14/14] hw/s390x/3270-ccw: avoid taking address of fields in packed struct

Message ID 20190329111104.17223-15-berrange@redhat.com (mailing list archive)
State New, archived
Headers show
Series misc set of fixes for warnings under GCC 9 | expand

Commit Message

Daniel P. Berrangé March 29, 2019, 11:11 a.m. UTC
Compiling with GCC 9 complains

hw/s390x/3270-ccw.c: In function ‘emulated_ccw_3270_cb’:
hw/s390x/3270-ccw.c:81:19: error: taking address of packed member of ‘struct SCHIB’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
   81 |         SCSW *s = &sch->curr_status.scsw;
      |                   ^~~~~~~~~~~~~~~~~~~~~~

This local variable is only present to save a little bit of
typing when setting the field later. Get rid of this to avoid
the warning about unaligned accesses.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 hw/s390x/3270-ccw.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

David Hildenbrand March 29, 2019, 11:42 a.m. UTC | #1
On 29.03.19 12:11, Daniel P. Berrangé wrote:
> Compiling with GCC 9 complains
> 
> hw/s390x/3270-ccw.c: In function ‘emulated_ccw_3270_cb’:
> hw/s390x/3270-ccw.c:81:19: error: taking address of packed member of ‘struct SCHIB’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
>    81 |         SCSW *s = &sch->curr_status.scsw;
>       |                   ^~~~~~~~~~~~~~~~~~~~~~
> 
> This local variable is only present to save a little bit of
> typing when setting the field later. Get rid of this to avoid
> the warning about unaligned accesses.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  hw/s390x/3270-ccw.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/s390x/3270-ccw.c b/hw/s390x/3270-ccw.c
> index 2c8d16ccf7..14882242c3 100644
> --- a/hw/s390x/3270-ccw.c
> +++ b/hw/s390x/3270-ccw.c
> @@ -78,13 +78,13 @@ static int emulated_ccw_3270_cb(SubchDev *sch, CCW1 ccw)
>  
>      if (rc == -EIO) {
>          /* I/O error, specific devices generate specific conditions */
> -        SCSW *s = &sch->curr_status.scsw;
> +        SCHIB *schib = &sch->curr_status;
>  
>          sch->curr_status.scsw.dstat = SCSW_DSTAT_UNIT_CHECK;
>          sch->sense_data[0] = 0x40;    /* intervention-req */
> -        s->ctrl &= ~SCSW_ACTL_START_PEND;
> -        s->ctrl &= ~SCSW_CTRL_MASK_STCTL;
> -        s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY |
> +        schib->scsw.ctrl &= ~SCSW_ACTL_START_PEND;
> +        schib->scsw.ctrl &= ~SCSW_CTRL_MASK_STCTL;
> +        schib->scsw.ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY |
>                     SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND;

Don't like that way of indenting.

Reviewed-by: David Hildenbrand <david@redhat.com>

>      }
>  
>
Thomas Huth March 29, 2019, 11:53 a.m. UTC | #2
On 29/03/2019 12.11, Daniel P. Berrangé wrote:
> Compiling with GCC 9 complains
> 
> hw/s390x/3270-ccw.c: In function ‘emulated_ccw_3270_cb’:
> hw/s390x/3270-ccw.c:81:19: error: taking address of packed member of ‘struct SCHIB’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
>    81 |         SCSW *s = &sch->curr_status.scsw;
>       |                   ^~~~~~~~~~~~~~~~~~~~~~
> 
> This local variable is only present to save a little bit of
> typing when setting the field later. Get rid of this to avoid
> the warning about unaligned accesses.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  hw/s390x/3270-ccw.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/s390x/3270-ccw.c b/hw/s390x/3270-ccw.c
> index 2c8d16ccf7..14882242c3 100644
> --- a/hw/s390x/3270-ccw.c
> +++ b/hw/s390x/3270-ccw.c
> @@ -78,13 +78,13 @@ static int emulated_ccw_3270_cb(SubchDev *sch, CCW1 ccw)
>  
>      if (rc == -EIO) {
>          /* I/O error, specific devices generate specific conditions */
> -        SCSW *s = &sch->curr_status.scsw;
> +        SCHIB *schib = &sch->curr_status;
>  
>          sch->curr_status.scsw.dstat = SCSW_DSTAT_UNIT_CHECK;
>          sch->sense_data[0] = 0x40;    /* intervention-req */
> -        s->ctrl &= ~SCSW_ACTL_START_PEND;
> -        s->ctrl &= ~SCSW_CTRL_MASK_STCTL;
> -        s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY |
> +        schib->scsw.ctrl &= ~SCSW_ACTL_START_PEND;
> +        schib->scsw.ctrl &= ~SCSW_CTRL_MASK_STCTL;
> +        schib->scsw.ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY |
>                     SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND;
>      }

Reviewed-by: Thomas Huth <thuth@redhat.com>
diff mbox series

Patch

diff --git a/hw/s390x/3270-ccw.c b/hw/s390x/3270-ccw.c
index 2c8d16ccf7..14882242c3 100644
--- a/hw/s390x/3270-ccw.c
+++ b/hw/s390x/3270-ccw.c
@@ -78,13 +78,13 @@  static int emulated_ccw_3270_cb(SubchDev *sch, CCW1 ccw)
 
     if (rc == -EIO) {
         /* I/O error, specific devices generate specific conditions */
-        SCSW *s = &sch->curr_status.scsw;
+        SCHIB *schib = &sch->curr_status;
 
         sch->curr_status.scsw.dstat = SCSW_DSTAT_UNIT_CHECK;
         sch->sense_data[0] = 0x40;    /* intervention-req */
-        s->ctrl &= ~SCSW_ACTL_START_PEND;
-        s->ctrl &= ~SCSW_CTRL_MASK_STCTL;
-        s->ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY |
+        schib->scsw.ctrl &= ~SCSW_ACTL_START_PEND;
+        schib->scsw.ctrl &= ~SCSW_CTRL_MASK_STCTL;
+        schib->scsw.ctrl |= SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY |
                    SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND;
     }