Skip to contentSkip to conversation

rv/monitors: Move monitor structure in rodata

PATCH Superseded Alessandro Carminati 2 participants 4 messages Nov 18, 2022 – Nov 23, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rv/monitors: Move monitor structure in rodata

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

---
 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(-)
kernel/trace/rv/monitors/wip/wip.h +1 -1
index dacc37b62a2c..9c0cd0ad5cd7 100644
@@ -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"
kernel/trace/rv/monitors/wwnr/wwnr.h +1 -1
index 118e576b91b4..57dfb1c46cb8 100644
@@ -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"
tools/verification/dot2/dot2c.py +1 -1
index be8a364a469b..512c7a11830f 100644
@@ -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):
Signature · 1 line
2.31.1
#1 lore raw

kernel/trace/rv/monitors/wwnr/wwnr.h

Quoted 24 lines · Alessandro Carminati

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

---
 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(-)
kernel/trace/rv/monitors/wip/wip.h +1 -1
index dacc37b62a2c..9c0cd0ad5cd7 100644
@@ -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"
kernel/trace/rv/monitors/wwnr/wwnr.h +0 -0

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

#2 lore raw

PATCH v2 1/1 rv/monitors: Move monitor structure in rodata

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

---
 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(-)
kernel/trace/rv/monitors/wip/wip.h +1 -1
index dacc37b62a2c..2e373f2c65ed 100644
@@ -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"
kernel/trace/rv/monitors/wwnr/wwnr.h +1 -1
index 118e576b91b4..d0d9c4b8121b 100644
@@ -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"
tools/verification/dot2/dot2c.py +1 -1
index be8a364a469b..87d8a1e1470c 100644
@@ -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):
Signature · 1 line
2.31.1