Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Matti Vaittinen <mazziesaccount@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Shreeya Patel <shreeya.patel@collabora.com>,
	Paul Gazzillo <paul@pgazz.com>,
	Dmitry Osipenko <dmitry.osipenko@collabora.com>,
	Zhigang Shi <Zhigang.Shi@liteon.com>,
	linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org
Subject: Re: [PATCH v3 2/6] iio: light: Add gain-time-scale helpers
Date: Sat, 18 Mar 2023 17:29:41 +0000	[thread overview]
Message-ID: <20230318172941.36e41a79@jic23-huawei> (raw)
In-Reply-To: <b4bf8587-d3cd-ff88-0276-7e394c110757@gmail.com>


> >   
> >>>> +		kfree(gts->avail_all_scales_table);  
> > 
> > ...
> >   
> >>>> +	per_time_gains = kcalloc(gts->num_itime, sizeof(int *), GFP_KERNEL);  
> >>>
> >>> sizeof(type) is error prone in comparison to sizeof(*var).  
> >>
> >> Yes and no. In majority of cases where we see sizeof(*var) - the *var is no
> >> longer a pointer as having pointers to pointers is not _that_ common. When
> >> we see sizeof(type *) - we instantly know it is a size of a pointer and not
> >> a size of some other type.
> >>
> >> So yes, while having sizeof(*var) makes us tolerant to errors caused by
> >> variable type changes - it makes us prone to human reader errors. Also, if
> >> someone changes type of *var from pointer to some other type - then he/she
> >> is likely to in any case need to revise the array alloactions too.
> >>
> >> While I in general agree with you that the sizeof(variable) is better than
> >> sizeof(type) - I see that in cases like this the sizeof(type *) is clearer.  
> > 
> > Still get a fundamental disagreement on this. I would insist, but I'm not
> > a maintainer, so you are lucky :-) if Jonathan will not force you to follow
> > my way.  
> 
> In a code you are maintaining it is good to have it in your way as 
> you're responsible for it. This is also why I insist on having things in 
> a way I can read best for a code I plan to maintain - unless the 
> subsystem maintainers see it hard to maintain for them. So, let's see if 
> Jonathan has strong opinions on this one :)

This is one where I strongly prefer sizeof(*per_time_gains)
because it's easier to review.  I don't care so much if it's easier to
modify as reality is these rarely get modified.

I often just 'fix' these up whilst applying.

Jonathan

  parent reply	other threads:[~2023-03-18 17:15 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-06  9:15 [PATCH v3 0/6] Support ROHM BU27034 ALS sensor Matti Vaittinen
2023-03-06  9:15 ` [PATCH v3 1/6] dt-bindings: iio: light: Support ROHM BU27034 Matti Vaittinen
2023-03-06  9:17 ` [PATCH v3 2/6] iio: light: Add gain-time-scale helpers Matti Vaittinen
2023-03-06 12:52   ` Andy Shevchenko
2023-03-12 16:51     ` Jonathan Cameron
2023-03-13 12:56       ` Matti Vaittinen
2023-03-13 13:14         ` Andy Shevchenko
2023-03-14  6:19           ` Vaittinen, Matti
2023-03-14 11:12             ` Andy Shevchenko
2023-03-18 17:17             ` Jonathan Cameron
2023-03-19 14:28               ` Matti Vaittinen
2023-03-18 17:24         ` Jonathan Cameron
2023-03-13 12:47     ` Matti Vaittinen
2023-03-13 13:25       ` Andy Shevchenko
2023-03-13 13:59         ` Matti Vaittinen
2023-03-13 14:17           ` Andy Shevchenko
2023-03-13 14:25             ` Matti Vaittinen
2023-03-18 17:29           ` Jonathan Cameron [this message]
2023-03-12 17:06   ` Jonathan Cameron
2023-03-12 17:08     ` Jonathan Cameron
2023-03-13 12:40       ` Andy Shevchenko
2023-03-13 13:11         ` Matti Vaittinen
2023-03-13 13:29           ` Andy Shevchenko
2023-03-13 13:59             ` Matti Vaittinen
2023-03-15 10:51               ` Matti Vaittinen
2023-03-15 14:12                 ` Andy Shevchenko
2023-03-15 14:14                   ` Andy Shevchenko
2023-03-17 10:19                 ` Maxime Ripard
2023-03-17 10:57                   ` Vaittinen, Matti
2023-03-13 12:52     ` Matti Vaittinen
2023-03-06  9:17 ` [PATCH v3 3/6] iio: test: test " Matti Vaittinen
2023-03-06  9:19 ` [PATCH v3 4/6] MAINTAINERS: Add IIO " Matti Vaittinen
2023-03-06  9:23 ` [PATCH v3 5/6] iio: light: ROHM BU27034 Ambient Light Sensor Matti Vaittinen
2023-03-12 17:39   ` Jonathan Cameron
2023-03-13 13:34     ` Matti Vaittinen
2023-03-06  9:27 ` [PATCH v3 6/6] MAINTAINERS: Add ROHM BU27034 Matti Vaittinen
2023-03-06 12:25 ` [PATCH v3 0/6] Support ROHM BU27034 ALS sensor 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=20230318172941.36e41a79@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Zhigang.Shi@liteon.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=dmitry.osipenko@collabora.com \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matti.vaittinen@fi.rohmeurope.com \
    --cc=mazziesaccount@gmail.com \
    --cc=paul@pgazz.com \
    --cc=shreeya.patel@collabora.com \
    /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