Patchwork [01/16] eicon: fix -Warray-bounds warning

login
register
mail settings
Submitter Danny Kukawka
Date Jan. 30, 2012, 10 p.m.
Message ID <1327960820-11867-2-git-send-email-danny.kukawka@bisect.de>
Download mbox | patch
Permalink /patch/138659/
State Changes Requested
Delegated to: David Miller
Headers show

Comments

Danny Kukawka - Jan. 30, 2012, 10 p.m.
Fix for a -Warray-bounds warning. mixer_notify_update() tries to
write to ((CAPI_MSG *) msg)->info.facility_req.structs[3] while
structs is defined as byte structs[1], define structs[1] as
structs[4].

Signed-off-by: Danny Kukawka <danny.kukawka@bisect.de>
---
 drivers/isdn/hardware/eicon/capi20.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Ben Hutchings - Jan. 30, 2012, 11:09 p.m.
On Mon, 2012-01-30 at 23:00 +0100, Danny Kukawka wrote:
> Fix for a -Warray-bounds warning. mixer_notify_update() tries to
> write to ((CAPI_MSG *) msg)->info.facility_req.structs[3] while
> structs is defined as byte structs[1], define structs[1] as
> structs[4].

I suspect that all the 'byte structs[1];' fields defined in that header
are actually variable-length arrays.  In that case, there may be no
reasonable bound you can specify.

Ben.

> Signed-off-by: Danny Kukawka <danny.kukawka@bisect.de>
> ---
>  drivers/isdn/hardware/eicon/capi20.h |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/isdn/hardware/eicon/capi20.h b/drivers/isdn/hardware/eicon/capi20.h
> index 7ebcccd..f9170ad 100644
> --- a/drivers/isdn/hardware/eicon/capi20.h
> +++ b/drivers/isdn/hardware/eicon/capi20.h
> @@ -226,7 +226,7 @@ typedef struct {
>          /* FACILITY-REQUEST */
>  typedef struct {
>    word Selector;
> -  byte structs[1];      /* Facility parameters */
> +  byte structs[4];      /* Facility parameters */
>  } _FAC_REQP;
>          /* FACILITY-CONFIRM STRUCT FOR SUPPLEMENT. SERVICES */
>  typedef struct {
Karsten Keil - Jan. 31, 2012, 3:25 p.m.
On Mon, Jan 30, 2012 at 11:09:32PM +0000, Ben Hutchings wrote:
> On Mon, 2012-01-30 at 23:00 +0100, Danny Kukawka wrote:
> > Fix for a -Warray-bounds warning. mixer_notify_update() tries to
> > write to ((CAPI_MSG *) msg)->info.facility_req.structs[3] while
> > structs is defined as byte structs[1], define structs[1] as
> > structs[4].
> 
> I suspect that all the 'byte structs[1];' fields defined in that header
> are actually variable-length arrays.  In that case, there may be no
> reasonable bound you can specify.

Yes, exactely, the structs is a ASN1 coded message so it can have any len.

Karsten

> 
> Ben.
> 
> > Signed-off-by: Danny Kukawka <danny.kukawka@bisect.de>
> > ---
> >  drivers/isdn/hardware/eicon/capi20.h |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/isdn/hardware/eicon/capi20.h b/drivers/isdn/hardware/eicon/capi20.h
> > index 7ebcccd..f9170ad 100644
> > --- a/drivers/isdn/hardware/eicon/capi20.h
> > +++ b/drivers/isdn/hardware/eicon/capi20.h
> > @@ -226,7 +226,7 @@ typedef struct {
> >          /* FACILITY-REQUEST */
> >  typedef struct {
> >    word Selector;
> > -  byte structs[1];      /* Facility parameters */
> > +  byte structs[4];      /* Facility parameters */
> >  } _FAC_REQP;
> >          /* FACILITY-CONFIRM STRUCT FOR SUPPLEMENT. SERVICES */
> >  typedef struct {
> 
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Danny Kukawka - Jan. 31, 2012, 5:04 p.m.
On Dienstag, 31. Januar 2012, Karsten Keil wrote:
> On Mon, Jan 30, 2012 at 11:09:32PM +0000, Ben Hutchings wrote:
> > On Mon, 2012-01-30 at 23:00 +0100, Danny Kukawka wrote:
> > > Fix for a -Warray-bounds warning. mixer_notify_update() tries to
> > > write to ((CAPI_MSG *) msg)->info.facility_req.structs[3] while
> > > structs is defined as byte structs[1], define structs[1] as
> > > structs[4].
> >
> > I suspect that all the 'byte structs[1];' fields defined in that header
> > are actually variable-length arrays.  In that case, there may be no
> > reasonable bound you can specify.
>
> Yes, exactely, the structs is a ASN1 coded message so it can have any len.

So, how can we get rid of the compiler warning then?

Danny

> Karsten
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Laight - Feb. 1, 2012, 9:04 a.m.
> -----Original Message-----
> From: netdev-owner@vger.kernel.org 
> [mailto:netdev-owner@vger.kernel.org] On Behalf Of Danny Kukawka
> Sent: 31 January 2012 17:04
> To: Karsten Keil
> Cc: Ben Hutchings; Armin Schindler; 
> linux-kernel@vger.kernel.org; netdev@vger.kernel.org; Karsten Keil
> Subject: Re: [PATCH 01/16] eicon: fix -Warray-bounds warning
> 
> On Dienstag, 31. Januar 2012, Karsten Keil wrote:
> > On Mon, Jan 30, 2012 at 11:09:32PM +0000, Ben Hutchings wrote:
> > > On Mon, 2012-01-30 at 23:00 +0100, Danny Kukawka wrote:
> > > > Fix for a -Warray-bounds warning. mixer_notify_update() tries to
> > > > write to ((CAPI_MSG *) msg)->info.facility_req.structs[3] while
> > > > structs is defined as byte structs[1], define structs[1] as
> > > > structs[4].
> > >
> > > I suspect that all the 'byte structs[1];' fields defined 
> in that header
> > > are actually variable-length arrays.  In that case, there 
> may be no
> > > reasonable bound you can specify.
> >
> > Yes, exactely, the structs is a ASN1 coded message so it 
> can have any len.
> 
> So, how can we get rid of the compiler warning then?

Try defining it as a 'variable sized array' - byte structs[0].

	David


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Danny Kukawka - Feb. 1, 2012, 12:52 p.m.
On Mittwoch, 1. Februar 2012, David Laight wrote:
> > -----Original Message-----
> > From: netdev-owner@vger.kernel.org
> > [mailto:netdev-owner@vger.kernel.org] On Behalf Of Danny Kukawka
> > Sent: 31 January 2012 17:04
> > To: Karsten Keil
> > Cc: Ben Hutchings; Armin Schindler;
> > linux-kernel@vger.kernel.org; netdev@vger.kernel.org; Karsten Keil
> > Subject: Re: [PATCH 01/16] eicon: fix -Warray-bounds warning
> >
> > On Dienstag, 31. Januar 2012, Karsten Keil wrote:
> > > On Mon, Jan 30, 2012 at 11:09:32PM +0000, Ben Hutchings wrote:
> > > > On Mon, 2012-01-30 at 23:00 +0100, Danny Kukawka wrote:
> > > > > Fix for a -Warray-bounds warning. mixer_notify_update() tries to
> > > > > write to ((CAPI_MSG *) msg)->info.facility_req.structs[3] while
> > > > > structs is defined as byte structs[1], define structs[1] as
> > > > > structs[4].
> > > >
> > > > I suspect that all the 'byte structs[1];' fields defined
> >
> > in that header
> >
> > > > are actually variable-length arrays.  In that case, there
> >
> > may be no
> >
> > > > reasonable bound you can specify.
> > >
> > > Yes, exactely, the structs is a ASN1 coded message so it
> >
> > can have any len.
> >
> > So, how can we get rid of the compiler warning then?
>
> Try defining it as a 'variable sized array' - byte structs[0].

Okay, that works. I'll send an updated patch.

Thanks

Danny
> 	David
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Karsten Keil - Feb. 2, 2012, 6:25 p.m.
On Wed, Feb 01, 2012 at 01:52:18PM +0100, Danny Kukawka wrote:
> On Mittwoch, 1. Februar 2012, David Laight wrote:
> > > -----Original Message-----
> > > From: netdev-owner@vger.kernel.org
> > > [mailto:netdev-owner@vger.kernel.org] On Behalf Of Danny Kukawka
> > > Sent: 31 January 2012 17:04
> > > To: Karsten Keil
> > > Cc: Ben Hutchings; Armin Schindler;
> > > linux-kernel@vger.kernel.org; netdev@vger.kernel.org; Karsten Keil
> > > Subject: Re: [PATCH 01/16] eicon: fix -Warray-bounds warning
> > >
> > > On Dienstag, 31. Januar 2012, Karsten Keil wrote:
> > > > On Mon, Jan 30, 2012 at 11:09:32PM +0000, Ben Hutchings wrote:
> > > > > On Mon, 2012-01-30 at 23:00 +0100, Danny Kukawka wrote:
> > > > > > Fix for a -Warray-bounds warning. mixer_notify_update() tries to
> > > > > > write to ((CAPI_MSG *) msg)->info.facility_req.structs[3] while
> > > > > > structs is defined as byte structs[1], define structs[1] as
> > > > > > structs[4].
> > > > >
> > > > > I suspect that all the 'byte structs[1];' fields defined
> > >
> > > in that header
> > >
> > > > > are actually variable-length arrays.  In that case, there
> > >
> > > may be no
> > >
> > > > > reasonable bound you can specify.
> > > >
> > > > Yes, exactely, the structs is a ASN1 coded message so it
> > >
> > > can have any len.
> > >
> > > So, how can we get rid of the compiler warning then?
> >
> > Try defining it as a 'variable sized array' - byte structs[0].
> 
> Okay, that works. I'll send an updated patch.
> 

Nice, I did not know this way.

Karsten
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/isdn/hardware/eicon/capi20.h b/drivers/isdn/hardware/eicon/capi20.h
index 7ebcccd..f9170ad 100644
--- a/drivers/isdn/hardware/eicon/capi20.h
+++ b/drivers/isdn/hardware/eicon/capi20.h
@@ -226,7 +226,7 @@  typedef struct {
         /* FACILITY-REQUEST */
 typedef struct {
   word Selector;
-  byte structs[1];      /* Facility parameters */
+  byte structs[4];      /* Facility parameters */
 } _FAC_REQP;
         /* FACILITY-CONFIRM STRUCT FOR SUPPLEMENT. SERVICES */
 typedef struct {