From owner-freebsd-net@freebsd.org Wed Jan 27 00:39:04 2016 Return-Path: Delivered-To: freebsd-net@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 8D14FA6E457 for ; Wed, 27 Jan 2016 00:39:04 +0000 (UTC) (envelope-from rizzo.unipi@gmail.com) 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 6B558C51 for ; Wed, 27 Jan 2016 00:39:04 +0000 (UTC) (envelope-from rizzo.unipi@gmail.com) Received: by mailman.ysv.freebsd.org (Postfix) id 67421A6E455; Wed, 27 Jan 2016 00:39:04 +0000 (UTC) Delivered-To: net@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 66B94A6E453; Wed, 27 Jan 2016 00:39:04 +0000 (UTC) (envelope-from rizzo.unipi@gmail.com) Received: from mail-lf0-x232.google.com (mail-lf0-x232.google.com [IPv6:2a00:1450:4010:c07::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DF80FC4E; Wed, 27 Jan 2016 00:39:03 +0000 (UTC) (envelope-from rizzo.unipi@gmail.com) Received: by mail-lf0-x232.google.com with SMTP id c192so116460603lfe.2; Tue, 26 Jan 2016 16:39:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=unqjzdiAU3Lsv07QAgQ5QKIqrqRb1aw8ueSz/wDpd84=; b=ondHbLGcP9dPXaJymV9/irHTjUER4wXCO4PKmemxXpWVqQavwS8TA23QY5ynOKliKf U4wy5VXO21h29dAREHqIzbzIj6GuU9DwM3ioLlzB+womDG7OOk8bKIR4mVdTdTtV41dW Mi5Pd/MnWH2OyQ/iGQw/HIGqvZDiuO0V63E/CQo1fO1oPF+M8jTCISxhTEMXyZZD0mmY XdHXErZoTBFTaPvzCiHmz0DsbP73n8gHRjGTxys6HBGyEJgTfi7avlebZI/PpUH6hSR1 cedSP1qu2sTD1T8v0jv0KL3iAM2XH7C7PQ8JicyaxAlC4EF2S1il54TV9hzXPOOc7DQa sd7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=unqjzdiAU3Lsv07QAgQ5QKIqrqRb1aw8ueSz/wDpd84=; b=kzAbwNsfTUB1l+SaHz/qVQebP1oyhYoWzlA80EUFpLuO8qKnRyuedNe1JXN4dFIFws TunWn6Q+LRNAOY/C25VRs6TA1tuc8ojeYqd6/iYV/MMpLQs0xR54iNqzq7qRwYDaPyp+ cm/vs/BJYFUGRr34i+nioXDFrGlSgmtLWJFZoBZlaDLpzA9aiTsC81SS45G9FNknFyMz V8M3SuKwS/vU4w4PkwUoCxI+ttiX5Fqz4i+xBHJ1q+lQTmTwSxj0iiOfsOGZ/5CAWPJQ BEy8UQ000s/k7eAPSJkhU5Z16RT+gHV+lO7vZaVdKMr2bZTc2aXfnJae2Wao14O6bUJ8 +CaQ== X-Gm-Message-State: AG10YOTuYBVZKRfYZzatbxIM+RP2K9kJjX7OkkcihNK3N8ZnrmhAB9+yZIIYrdOzvIkkHr24AUrMAw3ikJXTZQ== MIME-Version: 1.0 X-Received: by 10.25.21.208 with SMTP id 77mr9813445lfv.96.1453855140698; Tue, 26 Jan 2016 16:39:00 -0800 (PST) Sender: rizzo.unipi@gmail.com Received: by 10.114.4.232 with HTTP; Tue, 26 Jan 2016 16:39:00 -0800 (PST) In-Reply-To: <20160127013145.36f2aaef@ernst.home> 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> <20160127013145.36f2aaef@ernst.home> Date: Tue, 26 Jan 2016 16:39:00 -0800 X-Google-Sender-Auth: k4LwQVdu9Ah7Qo0jNU6CBodhdSw Message-ID: Subject: Re: Does FreeBSD have sendmmsg or recvmmsg system calls? From: Luigi Rizzo To: gljennjohn@gmail.com Cc: Daniel Eischen , threads@freebsd.org, Boris Astardzhiev , "freebsd-net@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jan 2016 00:39:04 -0000 On Tue, Jan 26, 2016 at 4:31 PM, Gary Jennejohn wrote: > On Tue, 26 Jan 2016 17:46:52 -0500 (EST) > Daniel Eischen wrote: > >> 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. >> > > Right. > > And code like this > > int func(void) > { > int baz, zot; > [some more code] > if (zot < 5) > { > int baz = 3; > [more code] > } > [some more code] > } > > is even worse. The compiler (clang) seems to consider this to > merely be a reinitialization of baz, but a human might be confused. oh please... :) This is simply an inner variable shadowing the outer one (which is another poor practice, flagged with -Wshadow ). When you exit the scope you get the external variable with its value, as you can see from the following code. #include int main(int ac, char *av[]) { int baz = 5; printf("1 baz %d\n", baz); { int baz = 3; printf("2 baz %d\n", baz); } printf("3 baz %d\n", baz); return 0; } cheers luigi