From owner-svn-src-user@FreeBSD.ORG Mon Nov 19 17:01:50 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 74918558; Mon, 19 Nov 2012 17:01:50 +0000 (UTC) (envelope-from mdf356@gmail.com) Received: from mail-pb0-f54.google.com (mail-pb0-f54.google.com [209.85.160.54]) by mx1.freebsd.org (Postfix) with ESMTP id 2C1038FC08; Mon, 19 Nov 2012 17:01:49 +0000 (UTC) Received: by mail-pb0-f54.google.com with SMTP id wz12so3764477pbc.13 for ; Mon, 19 Nov 2012 09:01:49 -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 :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=GTVr6WysR0+7993CUSlvEslUnJqh35SVPdN+QgfbXrQ=; b=Xyv+5vb0SAroMs+XORYjspC62enN+SQNTE42fOZftFpGKM8Kf4RdHN2GowyaMRTTNg WtN1BgRROuT1Z7U+wYkrZhvpXm2/zLeyooGPSfkHiD0gamYa194+xDXb/VNRn948QItq 9BDgPryqwY2NB/feUiyfsbqAUgZCIZXKbCJ0unX7YBhztic9eWhoexiYcLWZTiQ7rZ0X B9Y+oT52r7cW0MZ8jfCJrldPAeAoz9maU3zf5P+3iKuk2jS5KFx9+RBlae1dIxo6KAev rFipeR36r3eCs2NVDxCXJvBKRBZUz5WInZnHYkITINpuWsXHeC1X7hm1nfzWsp6D7jdd mrcA== MIME-Version: 1.0 Received: by 10.68.192.97 with SMTP id hf1mr34418054pbc.106.1353344509763; Mon, 19 Nov 2012 09:01:49 -0800 (PST) Sender: mdf356@gmail.com Received: by 10.68.132.136 with HTTP; Mon, 19 Nov 2012 09:01:49 -0800 (PST) In-Reply-To: <50AA3529.2030300@freebsd.org> References: <201211181217.qAICH7aH021497@svn.freebsd.org> <20121119114510.GQ38060@FreeBSD.org> <50AA3529.2030300@freebsd.org> Date: Mon, 19 Nov 2012 09:01:49 -0800 X-Google-Sender-Auth: ecTSZeVxnAIsZX3ZcN94S8frxPI Message-ID: Subject: Re: svn commit: r243215 - user/andre/tcp_workqueue/sys/sys From: mdf@FreeBSD.org To: Andre Oppermann Content-Type: text/plain; charset=ISO-8859-1 Cc: Gleb Smirnoff , src-committers@freebsd.org, svn-src-user@freebsd.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Nov 2012 17:01:50 -0000 On Mon, Nov 19, 2012 at 5:33 AM, Andre Oppermann wrote: > On 19.11.2012 12:45, Gleb Smirnoff wrote: >> >> On Sun, Nov 18, 2012 at 12:17:07PM +0000, Andre Oppermann wrote: >> A> Author: andre >> A> Date: Sun Nov 18 12:17:07 2012 >> A> New Revision: 243215 >> A> URL: http://svnweb.freebsd.org/changeset/base/243215 >> A> >> A> Log: >> A> Add mtodo(m, o, t) macro taking an additional offset into >> A> the mbuf data section before the casting to type 't'. >> >> IMHO, argument order of (m, t, o) is more intuitive, since >> matches order of mtod(). > > > Yes, but that looks rather horrible and counter-intuitive: > > th = mtodo(m, struct tcphdr *, 20); > > vs. > > th = mtodo(m, 20, struct tcphdr *); > > Reads m->m_data at offset 20 is struct tcphdr. > > Naming it mtood() wasn't convincing either. ;-) Why a cast at all? Perpetuating the mistake of mtod()'s casting isn't necessary. mtod() can't be fixed for source reasons, but the new one doesn't need to cast. Since C automatically casts from void * to any other pointer, the code gets shorter (usually) too: th = mtodo(m, 20); Not that I care much, it's just if we're having a bikeshed I have my favorite colors. :-) Cheers, matthew >> A> >> A> Modified: >> A> user/andre/tcp_workqueue/sys/sys/mbuf.h >> A> >> A> Modified: user/andre/tcp_workqueue/sys/sys/mbuf.h >> A> >> ============================================================================== >> A> --- user/andre/tcp_workqueue/sys/sys/mbuf.h Sun Nov 18 12:16:50 2012 >> (r243214) >> A> +++ user/andre/tcp_workqueue/sys/sys/mbuf.h Sun Nov 18 12:17:07 2012 >> (r243215) >> A> @@ -64,8 +64,10 @@ >> A> * type: >> A> * >> A> * mtod(m, t) -- Convert mbuf pointer to data pointer of correct >> type. >> A> + * mtodo(m, o, t) - Same as above but with offset 'o' into data. >> A> */ >> A> #define mtod(m, t) ((t)((m)->m_data)) >> A> +#define mtodo(m, o, t) ((t)(((m)->m_data) + (o))) >> A> >> A> /* >> A> * Argument structure passed to UMA routines during mbuf and packet >> >