From owner-freebsd-hackers Mon May 19 06:56:04 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id GAA22111 for hackers-outgoing; Mon, 19 May 1997 06:56:04 -0700 (PDT) Received: from spinner.DIALix.COM (spinner.dialix.com [192.203.228.67]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id GAA22049; Mon, 19 May 1997 06:54:37 -0700 (PDT) Received: from spinner.DIALix.COM (localhost.dialix.com.au [127.0.0.1]) by spinner.DIALix.COM with ESMTP id VAA22545; Mon, 19 May 1997 21:47:19 +0800 (WST) Message-Id: <199705191347.VAA22545@spinner.DIALix.COM> X-Mailer: exmh version 2.0gamma 1/27/96 To: Luigi Rizzo cc: bde@zeta.org.au (Bruce Evans), hackers@FreeBSD.ORG, j@uriah.heep.sax.de, core@FreeBSD.ORG Subject: Re: Variable initialization In-reply-to: Your message of "Mon, 19 May 1997 13:48:30 +0200." <199705191148.NAA04574@labinfo.iet.unipi.it> Date: Mon, 19 May 1997 21:47:17 +0800 From: Peter Wemm Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk 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