From owner-freebsd-current Wed Jan 27 18:33:10 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id SAA21574 for freebsd-current-outgoing; Wed, 27 Jan 1999 18:33:10 -0800 (PST) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from apollo.backplane.com (apollo.backplane.com [209.157.86.2]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id SAA21568 for ; Wed, 27 Jan 1999 18:33:09 -0800 (PST) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.9.2/8.9.1) id SAA92303; Wed, 27 Jan 1999 18:33:01 -0800 (PST) (envelope-from dillon) Date: Wed, 27 Jan 1999 18:33:01 -0800 (PST) From: Matthew Dillon Message-Id: <199901280233.SAA92303@apollo.backplane.com> To: Peter Jeremy Cc: current@FreeBSD.ORG Subject: Re: btokup() macro in sys/malloc.h References: <99Jan28.131753est.40347@border.alcanet.com.au> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG :Matthew Dillon wrote: :>:> NEW :>:> :>:> #define btokup(addr) (&kmemusage[((caddr_t)(addr) - kmembase) >> PAGE_SHIFT]) :>: :>:The added parentheses don't make any difference, semantically. This :>:change probably wouldn't meet the criteria spelled out in style(9): :> :> Then style(9) needs to be updated, because we have to add parenthesis :> to be able to not get warnings with -Wall. : :I'll support that. The example given in style(9): : : a = b->c[0] + ~d == (e || f) || g && h ? i : j >> 1; : :should rate as an entry in the Obfuscated C competition rather than :an example of maintainable code. : :style(9) should emphasize legibility and maintainability, rather than :minimizing the number of extraneous (from the compiler's perspective) :parenthesis. The code you're writing has to be maintained for many years :- and the maintainers will not always have your in-depth expertise. :The code also forms a `reference implementation' for someone who wants :to do something similar. : :Peter As far as parenthesis go, it's irrelevant because -Wall pretty much covers the most common mistakes. If your code compiles without generating a warning, your parenthesization is in good shape. Braces and indentation and other purely visual effects are a different matter. -Matt Matthew Dillon To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message