linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rv/monitors: Move monitor structure in rodata
@ 2022-11-18 16:20 Alessandro Carminati
  2022-11-22 14:13 ` Daniel Bristot de Oliveira
  0 siblings, 1 reply; 4+ messages in thread
From: Alessandro Carminati @ 2022-11-18 16:20 UTC (permalink / raw)
  To: linux-trace-devel
  Cc: alessandro.carminati, acarmina, bristot, rostedt, linux-kernel

It makes sense to move the important monitor structure into rodata to
prevent accidental structure modification.

Signed-off-by: Alessandro Carminati <acarmina@redhat.com>
---
 kernel/trace/rv/monitors/wip/wip.h   | 2 +-
 kernel/trace/rv/monitors/wwnr/wwnr.h | 2 +-
 tools/verification/dot2/dot2c.py     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/rv/monitors/wip/wip.h b/kernel/trace/rv/monitors/wip/wip.h
index dacc37b62a2c..9c0cd0ad5cd7 100644
--- a/kernel/trace/rv/monitors/wip/wip.h
+++ b/kernel/trace/rv/monitors/wip/wip.h
@@ -27,7 +27,7 @@ struct automaton_wip {
 	bool final_states[state_max_wip];
 };
 
-static struct automaton_wip automaton_wip = {
+const static struct automaton_wip automaton_wip = {
 	.state_names = {
 		"preemptive",
 		"non_preemptive"
diff --git a/kernel/trace/rv/monitors/wwnr/wwnr.h b/kernel/trace/rv/monitors/wwnr/wwnr.h
index 118e576b91b4..57dfb1c46cb8 100644
--- a/kernel/trace/rv/monitors/wwnr/wwnr.h
+++ b/kernel/trace/rv/monitors/wwnr/wwnr.h
@@ -27,7 +27,7 @@ struct automaton_wwnr {
 	bool final_states[state_max_wwnr];
 };
 
-static struct automaton_wwnr automaton_wwnr = {
+const static struct automaton_wwnr automaton_wwnr = {
 	.state_names = {
 		"not_running",
 		"running"
diff --git a/tools/verification/dot2/dot2c.py b/tools/verification/dot2/dot2c.py
index be8a364a469b..512c7a11830f 100644
--- a/tools/verification/dot2/dot2c.py
+++ b/tools/verification/dot2/dot2c.py
@@ -111,7 +111,7 @@ class Dot2c(Automata):
 
     def format_aut_init_header(self):
         buff = []
-        buff.append("static struct %s %s = {" % (self.struct_automaton_def, self.var_automaton_def))
+        buff.append("const static struct %s %s = {" % (self.struct_automaton_def, self.var_automaton_def))
         return buff
 
     def __get_string_vector_per_line_content(self, buff):
-- 
2.31.1


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

* Re: [PATCH] rv/monitors: Move monitor structure in rodata
  2022-11-18 16:20 [PATCH] rv/monitors: Move monitor structure in rodata Alessandro Carminati
@ 2022-11-22 14:13 ` Daniel Bristot de Oliveira
  2022-11-22 17:36   ` [PATCH v2] " Alessandro Carminati
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Bristot de Oliveira @ 2022-11-22 14:13 UTC (permalink / raw)
  To: Alessandro Carminati, linux-trace-devel
  Cc: alessandro.carminati, rostedt, linux-kernel

On 11/18/22 17:20, Alessandro Carminati wrote:
> It makes sense to move the important monitor structure into rodata to
> prevent accidental structure modification.
> 
> Signed-off-by: Alessandro Carminati <acarmina@redhat.com>
> ---
>  kernel/trace/rv/monitors/wip/wip.h   | 2 +-
>  kernel/trace/rv/monitors/wwnr/wwnr.h | 2 +-
>  tools/verification/dot2/dot2c.py     | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/trace/rv/monitors/wip/wip.h b/kernel/trace/rv/monitors/wip/wip.h
> index dacc37b62a2c..9c0cd0ad5cd7 100644
> --- a/kernel/trace/rv/monitors/wip/wip.h
> +++ b/kernel/trace/rv/monitors/wip/wip.h
> @@ -27,7 +27,7 @@ struct automaton_wip {
>  	bool final_states[state_max_wip];
>  };
>  
> -static struct automaton_wip automaton_wip = {
> +const static struct automaton_wip automaton_wip = {
>  	.state_names = {
>  		"preemptive",
>  		"non_preemptive"
> diff --git a/kernel/trace/rv/monitors/wwnr/wwnr.h b/kernel/trace/rv/monitors/wwnr/wwnr.h

checkpatch says:

WARNING: Move const after static - use 'static const struct automaton_wip '
#32: FILE: kernel/trace/rv/monitors/wip/wip.h:30:
+const static struct automaton_wip automaton_wip = {

WARNING: Move const after static - use 'static const struct automaton_wwnr '
#45: FILE: kernel/trace/rv/monitors/wwnr/wwnr.h:30:
+const static struct automaton_wwnr automaton_wwnr = {

and this is also true for the dot2c part.

Do you mind fixing that in a v2?

-- Daniel

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

* [PATCH v2] rv/monitors: Move monitor structure in rodata
  2022-11-22 14:13 ` Daniel Bristot de Oliveira
@ 2022-11-22 17:36   ` Alessandro Carminati
  2022-11-23  7:55     ` Daniel Bristot de Oliveira
  0 siblings, 1 reply; 4+ messages in thread
From: Alessandro Carminati @ 2022-11-22 17:36 UTC (permalink / raw)
  To: linux-trace-devel
  Cc: alessandro.carminati, acarmina, bristot, rostedt, linux-kernel

It makes sense to move the important monitor structure into rodata to
prevent accidental structure modification.

Signed-off-by: Alessandro Carminati <acarmina@redhat.com>
---
 kernel/trace/rv/monitors/wip/wip.h   | 2 +-
 kernel/trace/rv/monitors/wwnr/wwnr.h | 2 +-
 tools/verification/dot2/dot2c.py     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/rv/monitors/wip/wip.h b/kernel/trace/rv/monitors/wip/wip.h
index dacc37b62a2c..2e373f2c65ed 100644
--- a/kernel/trace/rv/monitors/wip/wip.h
+++ b/kernel/trace/rv/monitors/wip/wip.h
@@ -27,7 +27,7 @@ struct automaton_wip {
 	bool final_states[state_max_wip];
 };
 
-static struct automaton_wip automaton_wip = {
+static const struct automaton_wip automaton_wip = {
 	.state_names = {
 		"preemptive",
 		"non_preemptive"
diff --git a/kernel/trace/rv/monitors/wwnr/wwnr.h b/kernel/trace/rv/monitors/wwnr/wwnr.h
index 118e576b91b4..d0d9c4b8121b 100644
--- a/kernel/trace/rv/monitors/wwnr/wwnr.h
+++ b/kernel/trace/rv/monitors/wwnr/wwnr.h
@@ -27,7 +27,7 @@ struct automaton_wwnr {
 	bool final_states[state_max_wwnr];
 };
 
-static struct automaton_wwnr automaton_wwnr = {
+static const struct automaton_wwnr automaton_wwnr = {
 	.state_names = {
 		"not_running",
 		"running"
diff --git a/tools/verification/dot2/dot2c.py b/tools/verification/dot2/dot2c.py
index be8a364a469b..87d8a1e1470c 100644
--- a/tools/verification/dot2/dot2c.py
+++ b/tools/verification/dot2/dot2c.py
@@ -111,7 +111,7 @@ class Dot2c(Automata):
 
     def format_aut_init_header(self):
         buff = []
-        buff.append("static struct %s %s = {" % (self.struct_automaton_def, self.var_automaton_def))
+        buff.append("static const struct %s %s = {" % (self.struct_automaton_def, self.var_automaton_def))
         return buff
 
     def __get_string_vector_per_line_content(self, buff):
-- 
2.31.1


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

* Re: [PATCH v2] rv/monitors: Move monitor structure in rodata
  2022-11-22 17:36   ` [PATCH v2] " Alessandro Carminati
@ 2022-11-23  7:55     ` Daniel Bristot de Oliveira
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Bristot de Oliveira @ 2022-11-23  7:55 UTC (permalink / raw)
  To: Alessandro Carminati, linux-trace-devel
  Cc: alessandro.carminati, rostedt, linux-kernel

On 11/22/22 18:36, Alessandro Carminati wrote:
> It makes sense to move the important monitor structure into rodata to
> prevent accidental structure modification.
> 
> Signed-off-by: Alessandro Carminati <acarmina@redhat.com>

Acked-by: Daniel Bristot de Oliveira <bristot@kernel.org>

Thanks!
-- Daniel

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

end of thread, other threads:[~2022-11-23  7:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-18 16:20 [PATCH] rv/monitors: Move monitor structure in rodata Alessandro Carminati
2022-11-22 14:13 ` Daniel Bristot de Oliveira
2022-11-22 17:36   ` [PATCH v2] " Alessandro Carminati
2022-11-23  7:55     ` Daniel Bristot de Oliveira

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).