From: Christoph Hellwig <hch@infradead.org>
To: Kees Cook <keescook@chromium.org>
Cc: Christoph Hellwig <hch@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: Converting struct timer_list callback argument to struct timer_list *
Date: Sun, 3 Sep 2017 00:37:57 -0700 [thread overview]
Message-ID: <20170903073757.GA28985@infradead.org> (raw)
In-Reply-To: <CAGXu5jKuqDk3RtC_QmsKqn2VDUMdM9LfqX4bbOraU38F+gqMeQ@mail.gmail.com>
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.
next prev parent reply other threads:[~2017-09-03 7:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-30 23:39 Converting struct timer_list callback argument to struct timer_list * Kees Cook
2017-08-31 20:13 ` Thomas Gleixner
2017-08-31 23:32 ` Kees Cook
2017-09-01 10:08 ` Christoph Hellwig
2017-09-01 10:21 ` Thomas Gleixner
2017-09-01 10:44 ` Christoph Hellwig
2017-09-01 16:24 ` Kees Cook
2017-09-03 7:37 ` Christoph Hellwig [this message]
2017-09-03 20:18 ` Kees Cook
2017-09-04 6:07 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170903073757.GA28985@infradead.org \
--to=hch@infradead.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox