A few structures containing function pointers that could and should be
const are not. Change that.
Signed-off-by: Thomas Weißschuh <[email protected]>
---
Changes in v2:
- Use correct syntax for const array of function pointers.
Reported by LKP bot.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
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 <[email protected]>
The array is never modified so it can be const.
Reported-by: kernel test robot <[email protected]>
Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Signed-off-by: Thomas Weißschuh <[email protected]>
---
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
The struct is never modified so it can be const.
Signed-off-by: Thomas Weißschuh <[email protected]>
---
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
The struct is never modified so it can be const.
Signed-off-by: Thomas Weißschuh <[email protected]>
---
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
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 <[email protected]>
> ---
> Changes in v2:
> - Use correct syntax for const array of function pointers.
> Reported by LKP bot.
> - Link to v1: https://lore.kernel.org/r/[email protected]
>
> ---
> 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 <[email protected]>
>
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