Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 May 1997 21:47:17 +0800
From:      Peter Wemm <peter@spinner.DIALix.COM>
To:        Luigi Rizzo <luigi@labinfo.iet.unipi.it>
Cc:        bde@zeta.org.au (Bruce Evans), hackers@FreeBSD.ORG, j@uriah.heep.sax.de, core@FreeBSD.ORG
Subject:   Re: Variable initialization 
Message-ID:  <199705191347.VAA22545@spinner.DIALix.COM>
In-Reply-To: Your message of "Mon, 19 May 1997 13:48:30 %2B0200." <199705191148.NAA04574@labinfo.iet.unipi.it> 

next in thread | previous in thread | raw e-mail | index | archive | help
Luigi Rizzo wrote:
> > >> Can someone tell me why this is called obfuscation ?
> > 
> > With old compilers, it was a pessimization to initalize variables
> > unnecessarily or long before they are used.  With modern compilers,
> > it defeats automatic checking for uninitialized variables and may
> > still prevent some optimizations.
[..]
> But anyways I was just trying to understand if there was something
> fundamentally wrong in my preference of 
> 
>     int a = 3;
> 
> in place of
> 
>     int a ;
>     a = 3 ;

This doesn't bother me, but the following example does:

int s = splnet();
struct inpcb *pcb = sotoinpcb(so);

[function code]

This makes life hard for the smp people, becase we will someday have to
change it to something like:

int s;
struct inpcb *pcb;

s = splnet();			/* stop interrupts from grabbing spinlock */
simplelock_lock(&netlock);	/* stop other cpus from entering */
pcb = sotoinpcb(so);
[rest of code]

(This isn't a good example since the "int s = splnet()" could be left 
where it was, and the net code isn't likely to be suitable for a 
boolean simplelock - but that's for later)

Anyway, I don't care too much about static initializers, but calling
functions from the initializer list does worry me.

Cheers,
-Peter





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