tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Rationale for some rules in style guide



Hi Robert,

On Thu, Apr 13, 2023 at 04:03:38AM +0700, Robert Elz wrote:
>     Date:        Wed, 12 Apr 2023 22:01:36 +0200
>     From:        Reinoud Zandijk <reinoud%NetBSD.org@localhost>
>     Message-ID:  <ZDcOIBRFN4Rd0tHw%gorilla.13thmonkey.org@localhost>
> 
>   | Oh I do that for I think its more clear
> 
> You really write (and think it is more clear) stuff like:
> 
> 	char a;
> #if sizeof(struct small) == sizeof(char)	/* except you can't, I don't think */
> 	struct small b;
> #endif
> 	char c;
> 	short aa;
> #if sizeof(struct small) == sizeof(short) && sizeof(char) != sizeof(short)
> 	struct small b;
> #endif
...

> You really do that?    Where?   I have to look at that code!

Of course not :) but I tend to put pointers first as they are generally 4 or 8
bytes, then the uint64_t, uint32_ti, uint16_t, ... followed by the int and char though
normally char then int for it looks better ? ;)

So not so strict no and I generally avoid putting structs on the stack as in
kernel code stacks can get tight far too easily.

With regards,
Reinoud



Home | Main Index | Thread Index | Old Index