Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Nov 1995 08:27:52 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        davidg@Root.COM, peter@jhome.dialix.com
Cc:        ache@astral.msk.su, committers@freebsd.org, security@freebsd.org
Subject:   Re: cvs commit: CVSROOT log_accum.pl
Message-ID:  <199511132127.IAA07800@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>BTW: I suspect "struct ucred" should be reordered for better internal 
>alignment..  
>It is currently:
>struct ucred {
>  short cr_ref;
>  long  cr_uid;
>  short cr_ngroups;
>  long  cr_groups[NGROUPS];
>}

Actually, it is currently:

struct ucred {
  u_short cr_ref;
  ^^
  uid_t  cr_uid;
  ^^^^^
  short cr_ngroups;
  gid_t  cr_groups[NGROUPS];
  ^^^^^
}

uid_t and gid_t just happen to be unsigned long.  This is bogus.  They
are u_int32_t in NetBSD.  I think they should be machine dependent and
normally u_int if u_int has more than 32 bits, otherwise u_long.

>The order of cr_ngroups and cr_uid could be swapped making the whole 
>thing 4 bytes smaller (assuming that I understand structure packing.. :-)

You can't tell the best packing in general.  Putting the explicit char,
short, int and long types at the beginning of the struct is probably
best in general and works well here.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199511132127.IAA07800>