From owner-freebsd-hackers Fri Sep 17 1:34: 9 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from mycenae.ilion.eu.org (mycenae.ilion.eu.org [203.35.206.129]) by hub.freebsd.org (Postfix) with ESMTP id C478014F90 for ; Fri, 17 Sep 1999 01:34:02 -0700 (PDT) (envelope-from patrykz@mycenae.ilion.eu.org) Received: from mycenae.ilion.eu.org (localhost [127.0.0.1]) by mycenae.ilion.eu.org (8.9.3/8.9.3) with ESMTP id SAA55426; Fri, 17 Sep 1999 18:33:49 +1000 (EST) (envelope-from patrykz@mycenae.ilion.eu.org) Message-Id: <199909170833.SAA55426@mycenae.ilion.eu.org> To: Gregory Bond Cc: hackers@FreeBSD.ORG Subject: Re: "style" question In-reply-to: Your message of "Fri, 17 Sep 1999 18:21:35 +1000." <199909170821.SAA15276@lightning.itga.com.au> Date: Fri, 17 Sep 1999 18:33:48 +1000 From: Patryk Zadarnowski Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > I'm looking at cleaning up a few compile nits and I'm wondering what the > officially approved way of silencing "may not be used" warnings: > > int > foo(int flag) > { > int j; > > if (flag) > j = 1; > > /* > * This noop statement is enough to confuse the optimiser so it > * forgets that j is initialised iff flag != 0 > */ > flag = !!flag; I don't know about the "official" way to silence the compiler (a well placed else statement or a "default" switch case usually does the trick for me) That is to say, I'm willing to argue that fixing the flow of control is the only clean way of getting rid of these warnings, unless you know something special about the allowed values of the offending variable (eg. you know that your switch case is exhaustive), in which case a dummy "default" or initializer cannot hurt you much. Also !!x IS NOT a noop. For example, !!5 == 1. I think you meant to say `flag = ~~flag', which indeed is a NOP. Pat. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message