From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751604AbdICHiA (ORCPT ); Sun, 3 Sep 2017 03:38:00 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:38795 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751129AbdICHh7 (ORCPT ); Sun, 3 Sep 2017 03:37:59 -0400 Date: Sun, 3 Sep 2017 00:37:57 -0700 From: Christoph Hellwig To: Kees Cook Cc: Christoph Hellwig , Thomas Gleixner , LKML Subject: Re: Converting struct timer_list callback argument to struct timer_list * Message-ID: <20170903073757.GA28985@infradead.org> References: <20170901100838.GA8891@infradead.org> <20170901104456.GA25892@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.3 (2017-05-23) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 01, 2017 at 09:24:22AM -0700, Kees Cook wrote: > #define list_entry(ptr, type, member) container_of(ptr, type, member) > #define rb_entry(ptr, type, member) container_of(ptr, type, member) > > The use of a "timer_entry()" at the start of callbacks repeats the > struct name, which I find irritating (and it usually results in split > lines). For example: > > #define timer_entry(ptr, type, member) container_of(ptr, type, member) > > -static void snd_card_asihpi_timer_function(unsigned long data) > +static void snd_card_asihpi_timer_function(struct timer_list *t) > { > - struct snd_card_asihpi_pcm *dpcm = (struct snd_card_asihpi_pcm *)data; > + struct snd_card_asihpi_pcm *dpcm = > + timer_entry(t, struct > snd_card_asihpi_pcm, timer); > > I prefer to tie this directly to the variable, so how about renaming > TIMER_CONTAINER to timer_of(): The TIMER_CONTAINER semantics are more useful indeed, and I which we'd have a general purpose variant of that. But I was complaining about the name anyway. timer_of sounds ok, but timer_entry still sounds a bit more descriptive. As for the split lines: you'll generally get a lot of these, even TIMER_CONTAINER has a quite a few. I generally prefer to move everything right of the = to the next line as that becomes a lot more redable.