From owner-svn-src-head@FreeBSD.ORG Fri Jun 1 17:16:59 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C14681065675; Fri, 1 Jun 2012 17:16:59 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id 92F968FC1F; Fri, 1 Jun 2012 17:16:59 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 095A9B94A; Fri, 1 Jun 2012 13:16:59 -0400 (EDT) From: John Baldwin To: Eitan Adler Date: Fri, 1 Jun 2012 13:16:58 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p13; KDE/4.5.5; amd64; ; ) References: <201206010423.q514NKtf083043@svn.freebsd.org> <201206011024.49122.jhb@freebsd.org> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201206011316.58330.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Fri, 01 Jun 2012 13:16:59 -0400 (EDT) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Bruce Evans Subject: Re: svn commit: r236377 - head/sys/dev/vxge/vxgehal X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Jun 2012 17:16:59 -0000 On Friday, June 01, 2012 12:39:48 pm Eitan Adler wrote: > On 1 June 2012 07:24, John Baldwin wrote: > > This is why I personally loathe assignment side effects in boolean expressions > > for control flow. I tend to write this sort of thing instead as: > > > > channel->dtr_arr[dtr_index].dtr = dtrh; > > if (dtrh != NULL) { > > Same here. I was told to use the assignment is style(9) by multiple > people though. If it really is, I wish it would change. style(9) doesn't make a clear statement either way, but it has contradicting examples. First: while ((ch = getopt(argc, argv, "abNn:")) != -1) (and this one I use all the time myself as that is the common idiom for getopt()) Second: error = function(a1, a2); if (error != 0) exit(error); Also, style(9) tends to frown on assignments that are side-effects in other places, for example: Be careful to not obfuscate the code by initializing variables in the declarations. Use this feature only thoughtfully. DO NOT use function calls in initializers. struct foo one, *two; double three; int *four, five; char *six, seven, eight, nine, ten, eleven, twelve; four = myfunction(); Some newer changes added at the end do use assignment side-effects while demonstrating other rules (the !p example and err(3) and warn(3) examples, this last I find particularly obfuscated and painful to read). Note that I do not consider this to be an assignment side effect: if (ioctl(...) < 0) err(1, "ioctl"); That is, I don't write that out as: i = ioctl(...); if (i < 0) However, I do split it out if the return value is used for more than error checking, e.g.: fd = open(...); if (fd < 0) err(1, "open"); -- John Baldwin