All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/4] block: constify some structures of partitions/core.c
@ 2023-05-30 17:09 Thomas Weißschuh
  2023-05-30 17:09 ` [PATCH v3 1/4] block: constify partition prober array Thomas Weißschuh
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Thomas Weißschuh @ 2023-05-30 17:09 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 v3:
- Rebase on for-6.5/block
- Link to v2: https://lore.kernel.org/r/20230419-const-partition-v2-0-817b58f85cd1@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: 403b6fb8dac1e9407c04652cedd92285c5ae9aa5
change-id: 20230419-const-partition-a06b9f76b2f3

Best regards,
-- 
Thomas Weißschuh <linux@weissschuh.net>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v3 1/4] block: constify partition prober array
  2023-05-30 17:09 [PATCH v3 0/4] block: constify some structures of partitions/core.c Thomas Weißschuh
@ 2023-05-30 17:09 ` Thomas Weißschuh
  2023-05-30 17:09 ` [PATCH v3 2/4] block: constify struct part_type part_type Thomas Weißschuh
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Thomas Weißschuh @ 2023-05-30 17:09 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>
Closes: 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 49e0496ff23c..650603dbe557 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.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 2/4] block: constify struct part_type part_type
  2023-05-30 17:09 [PATCH v3 0/4] block: constify some structures of partitions/core.c Thomas Weißschuh
  2023-05-30 17:09 ` [PATCH v3 1/4] block: constify partition prober array Thomas Weißschuh
@ 2023-05-30 17:09 ` Thomas Weißschuh
  2023-05-30 17:09 ` [PATCH v3 3/4] block: constify struct part_attr_group Thomas Weißschuh
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Thomas Weißschuh @ 2023-05-30 17:09 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 650603dbe557..2bc21063edef 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -256,7 +256,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 b2ac587e3402..d89c2da14698 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;
 
 /*

-- 
2.40.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 3/4] block: constify struct part_attr_group
  2023-05-30 17:09 [PATCH v3 0/4] block: constify some structures of partitions/core.c Thomas Weißschuh
  2023-05-30 17:09 ` [PATCH v3 1/4] block: constify partition prober array Thomas Weißschuh
  2023-05-30 17:09 ` [PATCH v3 2/4] block: constify struct part_type part_type Thomas Weißschuh
@ 2023-05-30 17:09 ` Thomas Weißschuh
  2023-05-30 17:10 ` [PATCH v3 4/4] block: constify the whole_disk device_attribute Thomas Weißschuh
  2023-05-30 17:13 ` [PATCH v3 0/4] block: constify some structures of partitions/core.c Jens Axboe
  4 siblings, 0 replies; 6+ messages in thread
From: Thomas Weißschuh @ 2023-05-30 17:09 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 2bc21063edef..d5f5633bf725 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -228,7 +228,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.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 4/4] block: constify the whole_disk device_attribute
  2023-05-30 17:09 [PATCH v3 0/4] block: constify some structures of partitions/core.c Thomas Weißschuh
                   ` (2 preceding siblings ...)
  2023-05-30 17:09 ` [PATCH v3 3/4] block: constify struct part_attr_group Thomas Weißschuh
@ 2023-05-30 17:10 ` Thomas Weißschuh
  2023-05-30 17:13 ` [PATCH v3 0/4] block: constify some structures of partitions/core.c Jens Axboe
  4 siblings, 0 replies; 6+ messages in thread
From: Thomas Weißschuh @ 2023-05-30 17:10 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 d5f5633bf725..82d26427deae 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -288,7 +288,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.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v3 0/4] block: constify some structures of partitions/core.c
  2023-05-30 17:09 [PATCH v3 0/4] block: constify some structures of partitions/core.c Thomas Weißschuh
                   ` (3 preceding siblings ...)
  2023-05-30 17:10 ` [PATCH v3 4/4] block: constify the whole_disk device_attribute Thomas Weißschuh
@ 2023-05-30 17:13 ` Jens Axboe
  4 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2023-05-30 17:13 UTC (permalink / raw)
  To: Thomas Weißschuh; +Cc: linux-block, linux-kernel, kernel test robot


On Tue, 30 May 2023 19:09:56 +0200, Thomas Weißschuh wrote:
> A few structures containing function pointers that could and should be
> const are not. Change that.
> 
> 

Applied, thanks!

[1/4] block: constify partition prober array
      commit: 539050f92ea7666bca17c2c380d8071d2f93dcde
[2/4] block: constify struct part_type part_type
      commit: cdb37f73cf05631c4f7401f2cd99878733c0c3d9
[3/4] block: constify struct part_attr_group
      commit: 0bd478005cfc7f50ccb769744d952e9687ee75b4
[4/4] block: constify the whole_disk device_attribute
      commit: a378f6a40fac4a2f1812adea7017613d2bd5dab6

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-05-30 17:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-30 17:09 [PATCH v3 0/4] block: constify some structures of partitions/core.c Thomas Weißschuh
2023-05-30 17:09 ` [PATCH v3 1/4] block: constify partition prober array Thomas Weißschuh
2023-05-30 17:09 ` [PATCH v3 2/4] block: constify struct part_type part_type Thomas Weißschuh
2023-05-30 17:09 ` [PATCH v3 3/4] block: constify struct part_attr_group Thomas Weißschuh
2023-05-30 17:10 ` [PATCH v3 4/4] block: constify the whole_disk device_attribute Thomas Weißschuh
2023-05-30 17:13 ` [PATCH v3 0/4] block: constify some structures of partitions/core.c 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.