Linux kernel staging patches
 help / color / mirror / Atom feed
* [PATCH v3] staging: greybus: Constify static struct kobj_type gb_audio_module_type
@ 2024-03-14  8:13 Ayush Tiwari
  2024-03-14  8:15 ` Julia Lawall
  2024-03-14 13:27 ` Fabio M. De Francesco
  0 siblings, 2 replies; 3+ messages in thread
From: Ayush Tiwari @ 2024-03-14  8:13 UTC (permalink / raw)
  To: Larry.Finger, florian.c.schilhabel, gregkh, linux-kernel,
	linux-staging
  Cc: outreachy

Constify static struct kobj_type gb_audio_module_type to prevent
modification of data shared across many instances, ensuring that the
structure's usage is consistent and predictable throughout the driver
and allows the compiler to place it in read-only memory.
The kernel builds successfully without errors or new warnings,
verifying the change.

Signed-off-by: Ayush Tiwari <ayushtiw0110@gmail.com>
---
Changes in v3: added the message that verifies the change,
as suggested by Julia

Changes in v2: incorporated changes in commit message
as suggested by Alison
---
 drivers/staging/greybus/audio_manager_module.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/greybus/audio_manager_module.c b/drivers/staging/greybus/audio_manager_module.c
index 5f9dcbdbc191..4a4dfb42f50f 100644
--- a/drivers/staging/greybus/audio_manager_module.c
+++ b/drivers/staging/greybus/audio_manager_module.c
@@ -144,7 +144,7 @@ static struct attribute *gb_audio_module_default_attrs[] = {
 };
 ATTRIBUTE_GROUPS(gb_audio_module_default);
 
-static struct kobj_type gb_audio_module_type = {
+static const struct kobj_type gb_audio_module_type = {
 	.sysfs_ops = &gb_audio_module_sysfs_ops,
 	.release = gb_audio_module_release,
 	.default_groups = gb_audio_module_default_groups,
-- 
2.40.1


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

* Re: [PATCH v3] staging: greybus: Constify static struct kobj_type gb_audio_module_type
  2024-03-14  8:13 [PATCH v3] staging: greybus: Constify static struct kobj_type gb_audio_module_type Ayush Tiwari
@ 2024-03-14  8:15 ` Julia Lawall
  2024-03-14 13:27 ` Fabio M. De Francesco
  1 sibling, 0 replies; 3+ messages in thread
From: Julia Lawall @ 2024-03-14  8:15 UTC (permalink / raw)
  To: Ayush Tiwari
  Cc: Larry.Finger, florian.c.schilhabel, gregkh, linux-kernel,
	linux-staging, outreachy



On Thu, 14 Mar 2024, Ayush Tiwari wrote:

> Constify static struct kobj_type gb_audio_module_type to prevent
> modification of data shared across many instances, ensuring that the
> structure's usage is consistent and predictable throughout the driver
> and allows the compiler to place it in read-only memory.
> The kernel builds successfully without errors or new warnings,
> verifying the change.

Actually, casts can hide issues with const, so building successfully is
not a sufficient answer.  Where is this structure used, and how?

julia

>
> Signed-off-by: Ayush Tiwari <ayushtiw0110@gmail.com>
> ---
> Changes in v3: added the message that verifies the change,
> as suggested by Julia
>
> Changes in v2: incorporated changes in commit message
> as suggested by Alison
> ---
>  drivers/staging/greybus/audio_manager_module.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/greybus/audio_manager_module.c b/drivers/staging/greybus/audio_manager_module.c
> index 5f9dcbdbc191..4a4dfb42f50f 100644
> --- a/drivers/staging/greybus/audio_manager_module.c
> +++ b/drivers/staging/greybus/audio_manager_module.c
> @@ -144,7 +144,7 @@ static struct attribute *gb_audio_module_default_attrs[] = {
>  };
>  ATTRIBUTE_GROUPS(gb_audio_module_default);
>
> -static struct kobj_type gb_audio_module_type = {
> +static const struct kobj_type gb_audio_module_type = {
>  	.sysfs_ops = &gb_audio_module_sysfs_ops,
>  	.release = gb_audio_module_release,
>  	.default_groups = gb_audio_module_default_groups,
> --
> 2.40.1
>
>
>

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

* Re: [PATCH v3] staging: greybus: Constify static struct kobj_type gb_audio_module_type
  2024-03-14  8:13 [PATCH v3] staging: greybus: Constify static struct kobj_type gb_audio_module_type Ayush Tiwari
  2024-03-14  8:15 ` Julia Lawall
@ 2024-03-14 13:27 ` Fabio M. De Francesco
  1 sibling, 0 replies; 3+ messages in thread
From: Fabio M. De Francesco @ 2024-03-14 13:27 UTC (permalink / raw)
  To: Ayush Tiwari
  Cc: Larry.Finger, florian.c.schilhabel, gregkh, linux-kernel,
	linux-staging, outreachy

On Thursday, 14 March 2024 09:13:22 CET Ayush Tiwari wrote:
> Constify static struct kobj_type gb_audio_module_type to prevent
> modification of data shared across many instances, ensuring that the
> structure's usage is consistent and predictable throughout the driver
> and allows the compiler to place it in read-only memory.
> The kernel builds successfully without errors or new warnings,
> verifying the change.
> 
> Signed-off-by: Ayush Tiwari <ayushtiw0110@gmail.com>
> ---

I think that the "Subject" line should be made shorter by deleting all the 
unnecessary information. I'm not asking you to make a new version just to 
address my comment, but please keep the following in mind for your next 
patches.

The "Subject" line is provided (1) to briefly explain what this patch is 
doing and (2) to uniquely identify the patch (e.g., in git-log output).

I'd write something like the following:

"staging: greybus: Constify gb_audio_module_type"

Who reads the subject doesn't need, and probably doesn't want, to know that 
the variable you are making "const" has a "static" modifier or that its type 
is "struct kobj_type". These information add nothing relevant to what the 
patch is doing.

Examples of shorter, yet sufficient, "Subject" lines:

7ab4de60028e virtio-mem: Constify mem_id_table
01e1932a1748 iommu/vt-d: Constify intel_dma_ops

Thanks,

Fabio

> Changes in v3: added the message that verifies the change,
> as suggested by Julia
> 
> Changes in v2: incorporated changes in commit message
> as suggested by Alison
> ---

>  drivers/staging/greybus/audio_manager_module.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/greybus/audio_manager_module.c
> b/drivers/staging/greybus/audio_manager_module.c index
> 5f9dcbdbc191..4a4dfb42f50f 100644
> --- a/drivers/staging/greybus/audio_manager_module.c
> +++ b/drivers/staging/greybus/audio_manager_module.c
> @@ -144,7 +144,7 @@ static struct attribute 
*gb_audio_module_default_attrs[]
> = { };
>  ATTRIBUTE_GROUPS(gb_audio_module_default);
> 
> -static struct kobj_type gb_audio_module_type = {
> +static const struct kobj_type gb_audio_module_type = {
>  	.sysfs_ops = &gb_audio_module_sysfs_ops,
>  	.release = gb_audio_module_release,
>  	.default_groups = gb_audio_module_default_groups,





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

end of thread, other threads:[~2024-03-14 13:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-14  8:13 [PATCH v3] staging: greybus: Constify static struct kobj_type gb_audio_module_type Ayush Tiwari
2024-03-14  8:15 ` Julia Lawall
2024-03-14 13:27 ` Fabio M. De Francesco

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox