From owner-freebsd-threads@freebsd.org Tue Jan 26 22:47:00 2016 Return-Path: Delivered-To: freebsd-threads@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2AEE8A6E6B8 for ; Tue, 26 Jan 2016 22:47:00 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 0FC4F19FE for ; Tue, 26 Jan 2016 22:47:00 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: by mailman.ysv.freebsd.org (Postfix) id 0ABD3A6E6B4; Tue, 26 Jan 2016 22:47:00 +0000 (UTC) Delivered-To: threads@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 09033A6E6B2; Tue, 26 Jan 2016 22:47:00 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.netplex.net", Issuer "RapidSSL SHA256 CA - G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C4E6219FC; Tue, 26 Jan 2016 22:46:59 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.15.1/8.15.1/NETPLEX) with ESMTP id u0QMkqI1036585; Tue, 26 Jan 2016 17:46:52 -0500 X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.4.3 (mail.netplex.net [204.213.176.9]); Tue, 26 Jan 2016 17:46:52 -0500 (EST) Date: Tue, 26 Jan 2016 17:46:52 -0500 (EST) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net Reply-To: Daniel Eischen To: Gary Jennejohn cc: Luigi Rizzo , threads@freebsd.org, Boris Astardzhiev , "freebsd-net@freebsd.org" Subject: Re: Does FreeBSD have sendmmsg or recvmmsg system calls? In-Reply-To: <20160126182543.64050678@ernst.home> Message-ID: References: <20160118140811.GW3942@kib.kiev.ua> <20160120073154.GB3942@kib.kiev.ua> <20160121093509.GK3942@kib.kiev.ua> <20160121233040.E1864@besplex.bde.org> <20160124050634.GS3942@kib.kiev.ua> <20160124100747.551f8e3f@ernst.home> <20160126134005.GD3942@kib.kiev.ua> <20160126182543.64050678@ernst.home> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jan 2016 22:47:00 -0000 On Tue, 26 Jan 2016, Gary Jennejohn wrote: > On Tue, 26 Jan 2016 09:06:39 -0800 > Luigi Rizzo wrote: > >> On Tue, Jan 26, 2016 at 5:40 AM, Konstantin Belousov >> wrote: >>> On Mon, Jan 25, 2016 at 11:22:13AM +0200, Boris Astardzhiev wrote: >>>> +ssize_t >>>> +recvmmsg(int s, struct mmsghdr *__restrict msgvec, size_t vlen, int flags, >>>> + const struct timespec *__restrict timeout) >>>> +{ >>>> + size_t i, rcvd; >>>> + ssize_t ret; >>>> + >>>> + if (timeout != NULL) { >>>> + fd_set fds; >>>> + int res; >>> Please move all local definitions to the beginning of the function. >> >> This style recommendation was from 30 years ago and is >> bad programming practice, as it tends to complicate analysis >> for the human and increase the chance of improper usage of >> variables. >> >> We should move away from this for new code. >> > > Really? I personally find having all variables grouped together > much easier to understand. Stumbling across declarations in the > middle of the code in a for-loop, for example, takes me by surprise. > > I also greatly dislike initializing variables in their declarations. > > Maybe I'm just old fashioned since I have been writing C-code for > more than 30 years. +1 Probably should be discouraged, but allowed on a case-by-case basis. One could argue that if you need to declaration blocks in the middle of code, then that code is too complex and should be broken out into a separate function. -- DE