mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andreas Mohr <andi@lisas.de>
To: Ondrej Zary <linux@rainbow-software.org>
Cc: alsa-devel@alsa-project.org, Andreas Mohr <andi@lisas.de>,
	Kernel development list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] ES938 support for ES18xx driver
Date: Mon, 29 Sep 2014 22:40:04 +0200	[thread overview]
Message-ID: <20140929204004.GA5037@rhlx01.hs-esslingen.de> (raw)
In-Reply-To: <1412020242-8752-1-git-send-email-linux@rainbow-software.org>

Hi,

On Mon, Sep 29, 2014 at 09:50:42PM +0200, Ondrej Zary wrote:
> +	if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT)
> +		/* no error if this fails because ES938 is optional */
> +		if (snd_es938_init(&chip->es938, card, 0, 0) == 0)
> +			snd_printk(KERN_DEBUG "found ES938 audio processor\n");
> +
> +	return 0;

Hmm, how's the braces policy here?
Given a double "if" I'd suspect that the outer "if" would want braces then.
(perhaps checkpatch.pl has something to say here)

Not to mention that I'm having strong doubts about the kernel's
"if" coding style guidelines in general:
IMHO *all* uses of "if" ought to be braced:
witness the Apple-specific OpenSSL bug catastrophy ("goto fail;"),
where people said that adding braces to conditionals would have made things
obvious.
Plus the annoyance that for an addition commit to an existing conditional
the diff will *not* contain the addition only (one line),
but rather *three* lines, and the first line rather needlessly getting
modified even!

+ if (is_foo)
+   bar;

So, given a ridiculously simple one-line addition:

- if (is_foo)
+ if (is_foo) {
    bar;
+   boo;
+ }

Rather than:

+ if (is_foo) {
+   bar;
+ }

if (is_foo) {
  bar;
+ boo;
}


(SIX changed lines vs. 4!)


Not to mention my pet peeve about large sections of coding style documents -
they establish Golden Rules to never be broken, but then
Fail To Elaborate Why - STUPID!
(that does not fully apply to our "if" CodingStyle paragraph though)
What a great way to hamper properly thought out evolution of guidelines...

Perhaps we should have a seasoned discussion about that coding style issue,
and others? (any update of Documentation/CodingStyle
would need to directly include an update to checkpatch.pl, too, though)

(sorry about that part being rather OT to your particular nice patch)

> +	struct snd_es938_sysex_reg req = {
> +		.midi_cmd = MIDI_CMD_COMMON_SYSEX,
> +		.id = ES938_ID,
> +		.cmd = ES938_CMD_REG_R,
> +		.reg = reg,
> +		.midi_end = MIDI_CMD_COMMON_SYSEX_END,
> +	};

Hmm, perhaps const? :)
(and dito probably a const void * cast further below, to forego receiving
the optionally activated gcc non-const cast warnings)

> +	end_time = ktime_add_ms(ktime_get(), 100);

Yay! One driver less which is advertising
less precise deprecated implementation style :)

> +	/* check if the reply is our and has SYSEX_END at the end */

"ours"

Thanks,

Andreas Mohr

      reply	other threads:[~2014-09-29 20:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-29 19:50 Ondrej Zary
2014-09-29 20:40 ` Andreas Mohr [this message]

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=20140929204004.GA5037@rhlx01.hs-esslingen.de \
    --to=andi@lisas.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rainbow-software.org \
    /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

all inboxes | Powered by JetHome®