Skip to contentSkip to conversation

xsm/flask: mkflash.sh: Use const when generating initial_sid_to_string[]

PATCH In review Julien Grall 2 participants 3 messages Dec 12, 2022 – Dec 20, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xsm/flask: mkflash.sh: Use const when generating initial_sid_to_string[]

From: Julien Grall <[email protected]>

The array initial_sid_to_string is storing pointer to literal strings and is not meant to be modified. So change the type of the variable to "const char * const ...[]".

---
 xen/xsm/flask/policy/mkflask.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/xsm/flask/policy/mkflask.sh +1 -1
index 591ce832a1d1..611689768167 100755
@@ -34,7 +34,7 @@ BEGIN	{
 		printf("/*\n * Security object class definitions\n */\n") > debugfile;
 		printf("    S_(\"null\")\n") > debugfile;
 		printf("/* This file is automatically generated.  Do not edit. */\n") > debugfile2;
-		printf("static char *initial_sid_to_string[] =\n{\n") > debugfile2;
+		printf("static const char * const initial_sid_to_string[] =\n{\n") > debugfile2;
 		printf("    \"null\",\n") > debugfile2;
 	}
 /^[ \t]*#/	{
Signature · 1 line
2.38.1
#1 lore raw
Quoted 16 lines · Julien Grall

From: Julien Grall <[email protected]>

The array initial_sid_to_string is storing pointer to literal strings and is not meant to be modified. So change the type of the variable to "const char * const ...[]".

---
  xen/xsm/flask/policy/mkflask.sh | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
xen/xsm/flask/policy/mkflask.sh +0 -0
index 591ce832a1d1..611689768167 100755

xen/xsm/flask/policy/mkflask.sh BEGIN { · line 40

Quoted 8 lines
xen/xsm/flask/policy/mkflask.sh +1 -1
@@ -34,7 +34,7 @@ BEGIN	{
  		printf("/*\n * Security object class definitions\n */\n") > debugfile;
  		printf("    S_(\"null\")\n") > debugfile;
  		printf("/* This file is automatically generated.  Do not edit. */\n") > debugfile2;
-		printf("static char *initial_sid_to_string[] =\n{\n") > debugfile2;
+		printf("static const char * const initial_sid_to_string[] =\n{\n") > debugfile2;
  		printf("    \"null\",\n") > debugfile2;
  	}
  /^[ \t]*#/	{
#2 lore raw

Hi Daniel,

Quoted 21 lines · Daniel P. Smith
Quoted 20 lines · Julien Grall

From: Julien Grall <[email protected]>

The array initial_sid_to_string is storing pointer to literal strings and is not meant to be modified. So change the type of the variable to "const char * const ...[]".

---
  xen/xsm/flask/policy/mkflask.sh | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
xen/xsm/flask/policy/mkflask.sh +0 -1
index 591ce832a1d1..611689768167 100755
@@ -34,7 +34,7 @@ BEGIN    {
           printf("/*\n * Security object class definitions\n */\n") > debugfile;
           printf("    S_(\"null\")\n") > debugfile;
           printf("/* This file is automatically generated.  Do not edit. */\n") > debugfile2;
-        printf("static char *initial_sid_to_string[] =\n{\n") > 
Quoted 8 lines
Quoted 6 lines
xen/xsm/flask/policy/mkflask.sh +1 -0
 debugfile2;
+        printf("static const char * const initial_sid_to_string[] 
 =\n{\n") > debugfile2;
           printf("    \"null\",\n") > debugfile2;

      }
  /^[ \t]*#/    {

Thanks. Not sure if this was intended, but the tag is technically Acked-by rather than Ack-by.

I have committed the patch.

Cheers,

Signature · 1 line
Julien Grall