2006-01-03 11:30:48

by Jan Blunck

[permalink] [raw]
Subject: [PATCH 1/3] Eliminate __attribute__ ((packed)) warnings for gcc-4.1

Since version 4.1 the gcc is warning about ignored attributes. This patch is
using the equivalent attribute on the struct instead of on each of the
structure or union members.

GCC Manual:
"Specifying Attributes of Types

packed
This attribute, attached to struct or union type definition, specifies
that
each member of the structure or union is placed to minimize the memory
required. When attached to an enum definition, it indicates that the
smallest integral type should be used.

Specifying this attribute for struct and union types is equivalent to
specifying the packed attribute on each of the structure or union
members."

Signed-off-by: Jan Blunck <[email protected]>


Attachments:
(No filename) (713.00 B)
eliminate-packed-warnings-2.diff (30.88 kB)
Download all attachments

2006-01-04 02:25:46

by Dave Jones

[permalink] [raw]
Subject: Re: [PATCH 1/3] Eliminate __attribute__ ((packed)) warnings for gcc-4.1

On Tue, Jan 03, 2006 at 12:30:45PM +0100, Jan Blunck wrote:
> typedef struct T30_s {
> /* session parameters */
> - __u8 resolution __attribute__ ((packed));
> - __u8 rate __attribute__ ((packed));
> - __u8 width __attribute__ ((packed));
> - __u8 length __attribute__ ((packed));
> - __u8 compression __attribute__ ((packed));
> - __u8 ecm __attribute__ ((packed));
> - __u8 binary __attribute__ ((packed));
> - __u8 scantime __attribute__ ((packed));
> - __u8 id[FAXIDLEN] __attribute__ ((packed));
> + __u8 resolution;
> + __u8 rate ;
> + __u8 width ;
> + __u8 length ;
> + __u8 compression ;
> + __u8 ecm ;
> + __u8 binary ;
> + __u8 scantime ;
> + __u8 id[FAXIDLEN] ;

What's with the funky placement of ; ?
The rest of the struct looks sensible.

>
> /* various cruft */
> - u32 dataA[6] __attribute((packed));
> - u16 dataB[5] __attribute((packed));
> - u32 dataC[14] __attribute((packed));
> -};
> + u32 dataA[6];
> + u16 dataB[5];
> + u32 dataC[14];
> +} __attribute((packed));

You could fix the horked indentation at the same time.
(This crops up in a few places in this diff)

Dave

2006-01-04 09:15:50

by Jan Engelhardt

[permalink] [raw]
Subject: Re: [PATCH 1/3] Eliminate __attribute__ ((packed)) warnings for gcc-4.1

> > + __u8 rate ;
> > + __u8 width ;
> > + __u8 length ;
> > + __u8 compression ;
> > + __u8 ecm ;
> > + __u8 binary ;
> > + __u8 scantime ;
> > + __u8 id[FAXIDLEN] ;
>
>What's with the funky placement of ; ?
>The rest of the struct looks sensible.
>
Looks like a simple s/__attribute__((packed))// rather than
s/\s+__attribute__((packed))/;

2006-01-04 10:55:48

by Jan Blunck

[permalink] [raw]
Subject: Re: [PATCH 1/3] Eliminate __attribute__ ((packed)) warnings for gcc-4.1

On Wed, Jan 04, Jan Engelhardt wrote:

> >What's with the funky placement of ; ?
> >The rest of the struct looks sensible.
> >
> Looks like a simple s/__attribute__((packed))// rather than
> s/\s+__attribute__((packed))/;

Yeah, seems that I was too lazy. I'll do better next time ;)

Andrew, I'll resend a whitespace-beautified version.

Regards,
Jan

--
Jan Blunck [email protected]
SuSE LINUX - A Novell company
Maxfeldstr. 5 +49-911-74053-608
D-90409 N?rnberg http://www.suse.de

2006-01-04 10:56:30

by Jan Blunck

[permalink] [raw]
Subject: Eliminate __attribute__ ((packed)) warnings for gcc-4.1 (whitespace-beautified version)

Since version 4.1 the gcc is warning about ignored attributes. This patch is
using the equivalent attribute on the struct instead of on each of the
structure or union members.

GCC Manual:
"Specifying Attributes of Types

packed
This attribute, attached to struct or union type definition, specifies
that
each member of the structure or union is placed to minimize the memory
required. When attached to an enum definition, it indicates that the
smallest integral type should be used.

Specifying this attribute for struct and union types is equivalent to
specifying the packed attribute on each of the structure or union
members."

Signed-off-by: Jan Blunck <[email protected]>


Attachments:
(No filename) (703.00 B)
eliminate-packed-warnings-2.diff (30.85 kB)
Download all attachments