* [PATCH] regmap: fix kcalloc() arguments order
@ 2023-12-20 17:58 Dmitry Antipov
2023-12-20 21:31 ` Mark Brown
2024-01-04 14:08 ` Charles Keepax
0 siblings, 2 replies; 3+ messages in thread
From: Dmitry Antipov @ 2023-12-20 17:58 UTC (permalink / raw)
To: Mark Brown; +Cc: Greg Kroah-Hartman, linux-kernel, Dmitry Antipov
When compiling with gcc version 14.0.0 20231220 (experimental)
and W=1, I've noticed a bunch of four similar warnings like:
drivers/base/regmap/regmap-ram.c: In function '__regmap_init_ram':
drivers/base/regmap/regmap-ram.c:68:37: warning: 'kcalloc' sizes specified with
'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
68 | data->read = kcalloc(sizeof(bool), config->max_register + 1,
| ^~~~
Since 'n' and 'size' arguments of 'kcalloc()' are multiplied to
calculate the final size, their actual order doesn't affect the
result and so this is not a bug. But it's still worth to fix it.
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
drivers/base/regmap/regmap-ram.c | 4 ++--
drivers/base/regmap/regmap-raw-ram.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/base/regmap/regmap-ram.c b/drivers/base/regmap/regmap-ram.c
index 85f34a5dee04..192d6b131dff 100644
--- a/drivers/base/regmap/regmap-ram.c
+++ b/drivers/base/regmap/regmap-ram.c
@@ -65,12 +65,12 @@ struct regmap *__regmap_init_ram(const struct regmap_config *config,
return ERR_PTR(-EINVAL);
}
- data->read = kcalloc(sizeof(bool), config->max_register + 1,
+ data->read = kcalloc(config->max_register + 1, sizeof(bool),
GFP_KERNEL);
if (!data->read)
return ERR_PTR(-ENOMEM);
- data->written = kcalloc(sizeof(bool), config->max_register + 1,
+ data->written = kcalloc(config->max_register + 1, sizeof(bool),
GFP_KERNEL);
if (!data->written)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/base/regmap/regmap-raw-ram.c b/drivers/base/regmap/regmap-raw-ram.c
index c9b800885f3b..ecd33128f0c3 100644
--- a/drivers/base/regmap/regmap-raw-ram.c
+++ b/drivers/base/regmap/regmap-raw-ram.c
@@ -111,12 +111,12 @@ struct regmap *__regmap_init_raw_ram(const struct regmap_config *config,
return ERR_PTR(-EINVAL);
}
- data->read = kcalloc(sizeof(bool), config->max_register + 1,
+ data->read = kcalloc(config->max_register + 1, sizeof(bool),
GFP_KERNEL);
if (!data->read)
return ERR_PTR(-ENOMEM);
- data->written = kcalloc(sizeof(bool), config->max_register + 1,
+ data->written = kcalloc(config->max_register + 1, sizeof(bool),
GFP_KERNEL);
if (!data->written)
return ERR_PTR(-ENOMEM);
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] regmap: fix kcalloc() arguments order
2023-12-20 17:58 [PATCH] regmap: fix kcalloc() arguments order Dmitry Antipov
@ 2023-12-20 21:31 ` Mark Brown
2024-01-04 14:08 ` Charles Keepax
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2023-12-20 21:31 UTC (permalink / raw)
To: Dmitry Antipov; +Cc: Greg Kroah-Hartman, linux-kernel
On Wed, 20 Dec 2023 20:58:19 +0300, Dmitry Antipov wrote:
> When compiling with gcc version 14.0.0 20231220 (experimental)
> and W=1, I've noticed a bunch of four similar warnings like:
>
> drivers/base/regmap/regmap-ram.c: In function '__regmap_init_ram':
> drivers/base/regmap/regmap-ram.c:68:37: warning: 'kcalloc' sizes specified with
> 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
> 68 | data->read = kcalloc(sizeof(bool), config->max_register + 1,
> | ^~~~
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next
Thanks!
[1/1] regmap: fix kcalloc() arguments order
commit: 3b201c9af7c0cad2e8311d96c0c1b399606c70fa
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] regmap: fix kcalloc() arguments order
2023-12-20 17:58 [PATCH] regmap: fix kcalloc() arguments order Dmitry Antipov
2023-12-20 21:31 ` Mark Brown
@ 2024-01-04 14:08 ` Charles Keepax
1 sibling, 0 replies; 3+ messages in thread
From: Charles Keepax @ 2024-01-04 14:08 UTC (permalink / raw)
To: Dmitry Antipov; +Cc: Mark Brown, Greg Kroah-Hartman, linux-kernel
On Wed, Dec 20, 2023 at 08:58:19PM +0300, Dmitry Antipov wrote:
> When compiling with gcc version 14.0.0 20231220 (experimental)
> and W=1, I've noticed a bunch of four similar warnings like:
>
> drivers/base/regmap/regmap-ram.c: In function '__regmap_init_ram':
> drivers/base/regmap/regmap-ram.c:68:37: warning: 'kcalloc' sizes specified with
> 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
> 68 | data->read = kcalloc(sizeof(bool), config->max_register + 1,
> | ^~~~
>
> Since 'n' and 'size' arguments of 'kcalloc()' are multiplied to
> calculate the final size, their actual order doesn't affect the
> result and so this is not a bug. But it's still worth to fix it.
>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> ---
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Thanks,
Charles
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-04 14:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-20 17:58 [PATCH] regmap: fix kcalloc() arguments order Dmitry Antipov
2023-12-20 21:31 ` Mark Brown
2024-01-04 14:08 ` Charles Keepax
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®