Re: Any reason why we don't initialize all members of struct Xgt_desc_struct in doublefault.c ?

From: Andreas Dilger
Date: Fri Nov 26 2004 - 15:58:23 EST


On Nov 26, 2004 10:14 -0500, Jeff Garzik wrote:
> Jesper Juhl wrote:
> >Yes, this is nitpicking, but I just can't leave small corners like this
> >unpolished ;)
> >
> >in arch/i386/kernel/doublefault.c you will find this (line 20) :
> >
> >struct Xgt_desc_struct gdt_desc = {0, 0};
> >
> >but, struct Xgt_desc_struct has 3 members,
> >
> >struct Xgt_desc_struct {
> > unsigned short size;
> > unsigned long address __attribute__((packed));
> > unsigned short pad;
> >} __attribute__ ((packed));
> >
> >so why only initialize two of them explicitly?
>
> 'pad' is a dummy variable... nobody cares about its value.

Also, for struct initializations if you don't specify a field explicitly
it will be initialized to zero anyways, so even "gdt_desc = { }" is enough
in this case to initialize all of the fields to zero.

Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://members.shaw.ca/adilger/ http://members.shaw.ca/golinux/

Attachment: pgp00000.pgp
Description: PGP signature