* [PATCH v2 0/4] block: constify some structures of partitions/core.c
@ 2023-04-19 13:22 Thomas Weißschuh
2023-04-19 13:22 ` [PATCH v2 1/4] block: constify partition prober array Thomas Weißschuh
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Thomas Weißschuh @ 2023-04-19 13:22 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, linux-kernel, Thomas Weißschuh, kernel test robot
A few structures containing function pointers that could and should be
const are not. Change that.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
Changes in v2:
- Use correct syntax for const array of function pointers.
Reported by LKP bot.
- Link to v1: https://lore.kernel.org/r/20230419-const-partition-v1-0-2d66f2d83873@weissschuh.net
---
Thomas Weißschuh (4):
block: constify partition prober array
block: constify struct part_type part_type
block: constify struct part_attr_group
block: constify the whole_disk device_attribute
block/partitions/core.c | 8 ++++----
include/linux/blkdev.h | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
---
base-commit: af67688dca57999fd848f051eeea1d375ba546b2
change-id: 20230419-const-partition-a06b9f76b2f3
Best regards,
--
Thomas Weißschuh <linux@weissschuh.net>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/4] block: constify partition prober array
2023-04-19 13:22 [PATCH v2 0/4] block: constify some structures of partitions/core.c Thomas Weißschuh
@ 2023-04-19 13:22 ` Thomas Weißschuh
2023-04-19 13:22 ` [PATCH v2 2/4] block: constify struct part_type part_type Thomas Weißschuh
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Thomas Weißschuh @ 2023-04-19 13:22 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, linux-kernel, Thomas Weißschuh, kernel test robot
The array is never modified so it can be const.
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/oe-kbuild-all/202304191640.SkNk7kVN-lkp@intel.com/
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
block/partitions/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/partitions/core.c b/block/partitions/core.c
index 7b8ef6296abd..890072ae5c7c 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -12,7 +12,7 @@
#include <linux/raid/detect.h>
#include "check.h"
-static int (*check_part[])(struct parsed_partitions *) = {
+static int (*const check_part[])(struct parsed_partitions *) = {
/*
* Probe partition formats with tables at disk address 0
* that also have an ADFS boot block at 0xdc0.
--
2.40.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/4] block: constify struct part_type part_type
2023-04-19 13:22 [PATCH v2 0/4] block: constify some structures of partitions/core.c Thomas Weißschuh
2023-04-19 13:22 ` [PATCH v2 1/4] block: constify partition prober array Thomas Weißschuh
@ 2023-04-19 13:22 ` Thomas Weißschuh
2023-04-19 13:22 ` [PATCH v2 3/4] block: constify struct part_attr_group Thomas Weißschuh
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Thomas Weißschuh @ 2023-04-19 13:22 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, linux-kernel, Thomas Weißschuh
The struct is never modified so it can be const.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
block/partitions/core.c | 2 +-
include/linux/blkdev.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/block/partitions/core.c b/block/partitions/core.c
index 890072ae5c7c..43bde8118a78 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -264,7 +264,7 @@ static int part_uevent(const struct device *dev, struct kobj_uevent_env *env)
return 0;
}
-struct device_type part_type = {
+const struct device_type part_type = {
.name = "partition",
.groups = part_attr_groups,
.release = part_release,
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 941304f17492..de783481ec71 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -41,7 +41,7 @@ struct blk_stat_callback;
struct blk_crypto_profile;
extern const struct device_type disk_type;
-extern struct device_type part_type;
+extern const struct device_type part_type;
extern struct class block_class;
/* Must be consistent with blk_mq_poll_stats_bkt() */
--
2.40.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 3/4] block: constify struct part_attr_group
2023-04-19 13:22 [PATCH v2 0/4] block: constify some structures of partitions/core.c Thomas Weißschuh
2023-04-19 13:22 ` [PATCH v2 1/4] block: constify partition prober array Thomas Weißschuh
2023-04-19 13:22 ` [PATCH v2 2/4] block: constify struct part_type part_type Thomas Weißschuh
@ 2023-04-19 13:22 ` Thomas Weißschuh
2023-04-19 13:22 ` [PATCH v2 4/4] block: constify the whole_disk device_attribute Thomas Weißschuh
2023-05-30 16:52 ` [PATCH v2 0/4] block: constify some structures of partitions/core.c Thomas Weißschuh
4 siblings, 0 replies; 7+ messages in thread
From: Thomas Weißschuh @ 2023-04-19 13:22 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, linux-kernel, Thomas Weißschuh
The struct is never modified so it can be const.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
block/partitions/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/partitions/core.c b/block/partitions/core.c
index 43bde8118a78..cb37ac71868e 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -236,7 +236,7 @@ static struct attribute *part_attrs[] = {
NULL
};
-static struct attribute_group part_attr_group = {
+static const struct attribute_group part_attr_group = {
.attrs = part_attrs,
};
--
2.40.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 4/4] block: constify the whole_disk device_attribute
2023-04-19 13:22 [PATCH v2 0/4] block: constify some structures of partitions/core.c Thomas Weißschuh
` (2 preceding siblings ...)
2023-04-19 13:22 ` [PATCH v2 3/4] block: constify struct part_attr_group Thomas Weißschuh
@ 2023-04-19 13:22 ` Thomas Weißschuh
2023-05-30 16:52 ` [PATCH v2 0/4] block: constify some structures of partitions/core.c Thomas Weißschuh
4 siblings, 0 replies; 7+ messages in thread
From: Thomas Weißschuh @ 2023-04-19 13:22 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, linux-kernel, Thomas Weißschuh
The struct is never modified so it can be const.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
block/partitions/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/partitions/core.c b/block/partitions/core.c
index cb37ac71868e..302ac06708e6 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -296,7 +296,7 @@ static ssize_t whole_disk_show(struct device *dev,
{
return 0;
}
-static DEVICE_ATTR(whole_disk, 0444, whole_disk_show, NULL);
+static const DEVICE_ATTR(whole_disk, 0444, whole_disk_show, NULL);
/*
* Must be called either with open_mutex held, before a disk can be opened or
--
2.40.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/4] block: constify some structures of partitions/core.c
2023-04-19 13:22 [PATCH v2 0/4] block: constify some structures of partitions/core.c Thomas Weißschuh
` (3 preceding siblings ...)
2023-04-19 13:22 ` [PATCH v2 4/4] block: constify the whole_disk device_attribute Thomas Weißschuh
@ 2023-05-30 16:52 ` Thomas Weißschuh
2023-05-30 17:02 ` Jens Axboe
4 siblings, 1 reply; 7+ messages in thread
From: Thomas Weißschuh @ 2023-05-30 16:52 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, linux-kernel, kernel test robot
Hi Jens,
could you take a look at this?
Thanks,
Thomas
On 2023-04-19 15:22:52+0200, Thomas Weißschuh wrote:
> A few structures containing function pointers that could and should be
> const are not. Change that.
>
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
> Changes in v2:
> - Use correct syntax for const array of function pointers.
> Reported by LKP bot.
> - Link to v1: https://lore.kernel.org/r/20230419-const-partition-v1-0-2d66f2d83873@weissschuh.net
>
> ---
> Thomas Weißschuh (4):
> block: constify partition prober array
> block: constify struct part_type part_type
> block: constify struct part_attr_group
> block: constify the whole_disk device_attribute
>
> block/partitions/core.c | 8 ++++----
> include/linux/blkdev.h | 2 +-
> 2 files changed, 5 insertions(+), 5 deletions(-)
> ---
> base-commit: af67688dca57999fd848f051eeea1d375ba546b2
> change-id: 20230419-const-partition-a06b9f76b2f3
>
> Best regards,
> --
> Thomas Weißschuh <linux@weissschuh.net>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/4] block: constify some structures of partitions/core.c
2023-05-30 16:52 ` [PATCH v2 0/4] block: constify some structures of partitions/core.c Thomas Weißschuh
@ 2023-05-30 17:02 ` Jens Axboe
0 siblings, 0 replies; 7+ messages in thread
From: Jens Axboe @ 2023-05-30 17:02 UTC (permalink / raw)
To: Thomas Weißschuh; +Cc: linux-block, linux-kernel, kernel test robot
On 5/30/23 10:52 AM, Thomas Weißschuh wrote:
> Hi Jens,
>
> could you take a look at this?
Looks fine to me, more const always a good thing. Can you respin
it against for-6.5/block?
--
Jens Axboe
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-05-30 17:03 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-19 13:22 [PATCH v2 0/4] block: constify some structures of partitions/core.c Thomas Weißschuh
2023-04-19 13:22 ` [PATCH v2 1/4] block: constify partition prober array Thomas Weißschuh
2023-04-19 13:22 ` [PATCH v2 2/4] block: constify struct part_type part_type Thomas Weißschuh
2023-04-19 13:22 ` [PATCH v2 3/4] block: constify struct part_attr_group Thomas Weißschuh
2023-04-19 13:22 ` [PATCH v2 4/4] block: constify the whole_disk device_attribute Thomas Weißschuh
2023-05-30 16:52 ` [PATCH v2 0/4] block: constify some structures of partitions/core.c Thomas Weißschuh
2023-05-30 17:02 ` Jens Axboe
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.