All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Miguel Ojeda <ojeda@kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1 4/4] auxdisplay: lcd2s: Use array size explicitly in lcd2s_gotoxy()
Date: Wed, 23 Mar 2022 20:15:57 +0100	[thread overview]
Message-ID: <CANiq72=0NLgH4rmRNXMTo2TXLd9KcqEZ2yX40ytcTxSYkq1xKQ@mail.gmail.com> (raw)
In-Reply-To: <CAHp75VfMHWObRFs=-fOQnkV=KkAKWuqRF=JLUfzqruTa2U9XjQ@mail.gmail.com>

Hi Andy,

On Sat, Mar 19, 2022 at 12:37 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> With [] and parameters not being bytes by type one needs an additional
> processing step to figure that out. When I see u8 ...[3] I immediately
> understand that there are 3 _bytes_. Moreover, [] is error prone when
> one may add something to the buffer with the expectation that it will
> work somehow (for example, with an old device you need 3, with new
> device revision you need 4 bytes and passing 4 bytes breaks the old
> device). Of course most of that quite likely won't happen.

I agree it is better to be explicit -- I just found the commit message
very confusing, i.e. the type will always be `u8`, what is unclear is
the total length, not so much the type change.

I think the best approach when one needs an array to stay a particular
size due to some external constraint (like hardware) would be to use a
`static_assert` with a comment mentioning where the requirement comes
from. Or at least a comment above the array.

Either way, I applied this one too to -next a few days ago. Thanks!

Cheers,
Miguel

  reply	other threads:[~2022-03-23 19:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-08 15:11 [PATCH v1 1/4] auxdisplay: lcd2s: make use of device property API Andy Shevchenko
2022-03-08 15:11 ` [PATCH v1 2/4] auxdisplay: lcd2s: use module_i2c_driver to simplify the code Andy Shevchenko
2022-03-08 15:11 ` [PATCH v1 3/4] auxdisplay: lcd2s: Switch to i2c ->probe_new() Andy Shevchenko
2022-03-08 15:11 ` [PATCH v1 4/4] auxdisplay: lcd2s: Use array size explicitly in lcd2s_gotoxy() Andy Shevchenko
2022-03-19  0:29   ` Miguel Ojeda
2022-03-19 11:37     ` Andy Shevchenko
2022-03-23 19:15       ` Miguel Ojeda [this message]
2022-03-24  9:21         ` Andy Shevchenko
2022-03-23 19:02 ` [PATCH v1 1/4] auxdisplay: lcd2s: make use of device property API Miguel Ojeda
2022-03-24  9:21   ` Andy Shevchenko

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='CANiq72=0NLgH4rmRNXMTo2TXLd9KcqEZ2yX40ytcTxSYkq1xKQ@mail.gmail.com' \
    --to=miguel.ojeda.sandonis@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojeda@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.