From owner-freebsd-current@FreeBSD.ORG Sat Jul 28 06:41:17 2012 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 718AA106566B for ; Sat, 28 Jul 2012 06:41:17 +0000 (UTC) (envelope-from tim@kientzle.com) Received: from monday.kientzle.com (99-115-135-74.uvs.sntcca.sbcglobal.net [99.115.135.74]) by mx1.freebsd.org (Postfix) with ESMTP id 4C4FE8FC16 for ; Sat, 28 Jul 2012 06:41:17 +0000 (UTC) Received: (from root@localhost) by monday.kientzle.com (8.14.4/8.14.4) id q6S6fAaB027375; Sat, 28 Jul 2012 06:41:10 GMT (envelope-from tim@kientzle.com) Received: from [192.168.2.143] (CiscoE3000 [192.168.1.65]) by kientzle.com with SMTP id tv7nsrthxjcz9tjd863ask9iaw; Sat, 28 Jul 2012 06:41:10 +0000 (UTC) (envelope-from tim@kientzle.com) Mime-Version: 1.0 (Apple Message framework v1278) Content-Type: text/plain; charset=windows-1252 From: Tim Kientzle In-Reply-To: <20120727093824.GB56662@onelab2.iet.unipi.it> Date: Fri, 27 Jul 2012 23:41:10 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: References: <20120727093824.GB56662@onelab2.iet.unipi.it> To: Luigi Rizzo X-Mailer: Apple Mail (2.1278) Cc: current@freebsd.org Subject: Re: (void)foo or __unused foo ? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Jul 2012 06:41:17 -0000 On Jul 27, 2012, at 2:38 AM, Luigi Rizzo wrote: >=20 > The alternative way to avoid an 'unused' warning from the compiler > is an empty statement >=20 > (void)foo; >=20 > that the compiler hopefully optimizes away. I learned the void-cast convention many years ago. I used it throughout the libarchive code and have yet to run into any problems. I always use it in exactly this form (with the exact comment here) so that I can easily search on it: int foo(int a) { (void) a; /* UNUSED */ =85 } I agree with PHK that it would be nice to express this intent in a way that static checkers could verify. I also agree that having static checkers interpret comments is Evil. But I have yet to see any alternative that was as straightforward and widely-supported as this one. Every other viable alternative seems to require tangled clumps of macros. Tim