diff mbox series

[v3,1/4] libselinux: constify global strings

Message ID 20250314131751.28289-4-cgoettsche@seltendoof.de (mailing list archive)
State New
Delegated to: Petr Lautrbach
Headers show
Series [v3,1/4] libselinux: constify global strings | expand

Commit Message

Christian Göttsche March 14, 2025, 1:17 p.m. UTC
From: Christian Göttsche <cgzones@googlemail.com>

Declare the read-only encode table const.
Drop the only once used global variable selinux_rootpath.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libselinux/src/compute_create.c | 2 +-
 libselinux/src/selinux_config.c | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

Comments

James Carter March 18, 2025, 6:34 p.m. UTC | #1
On Fri, Mar 14, 2025 at 9:18 AM Christian Göttsche
<cgoettsche@seltendoof.de> wrote:
>
> From: Christian Göttsche <cgzones@googlemail.com>
>
> Declare the read-only encode table const.
> Drop the only once used global variable selinux_rootpath.
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>

For these four patches:
Acked-by: James Carter <jwcart2@gmail.com>

> ---
>  libselinux/src/compute_create.c | 2 +-
>  libselinux/src/selinux_config.c | 3 +--
>  2 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/libselinux/src/compute_create.c b/libselinux/src/compute_create.c
> index d19baa0b..ff8553bc 100644
> --- a/libselinux/src/compute_create.c
> +++ b/libselinux/src/compute_create.c
> @@ -33,7 +33,7 @@ static int object_name_encode(const char *objname, char *buffer, size_t buflen)
>                                 return -1;
>                         buffer[offset++] = '+';
>                 } else {
> -                       static const char *table = "0123456789ABCDEF";
> +                       static const char *const table = "0123456789ABCDEF";
>                         int     l = (code & 0x0f);
>                         int     h = (code & 0xf0) >> 4;
>
> diff --git a/libselinux/src/selinux_config.c b/libselinux/src/selinux_config.c
> index 1d8cfb71..75db14ba 100644
> --- a/libselinux/src/selinux_config.c
> +++ b/libselinux/src/selinux_config.c
> @@ -153,7 +153,6 @@ static int setpolicytype(const char *type)
>  }
>
>  static char *selinux_policyroot = NULL;
> -static const char *selinux_rootpath = SELINUXDIR;
>
>  static void init_selinux_config(void)
>  {
> @@ -312,7 +311,7 @@ int selinux_set_policy_root(const char *path)
>
>  const char *selinux_path(void)
>  {
> -       return selinux_rootpath;
> +       return SELINUXDIR;
>  }
>
>
> --
> 2.47.2
>
>
diff mbox series

Patch

diff --git a/libselinux/src/compute_create.c b/libselinux/src/compute_create.c
index d19baa0b..ff8553bc 100644
--- a/libselinux/src/compute_create.c
+++ b/libselinux/src/compute_create.c
@@ -33,7 +33,7 @@  static int object_name_encode(const char *objname, char *buffer, size_t buflen)
 				return -1;
 			buffer[offset++] = '+';
 		} else {
-			static const char *table = "0123456789ABCDEF";
+			static const char *const table = "0123456789ABCDEF";
 			int	l = (code & 0x0f);
 			int	h = (code & 0xf0) >> 4;
 
diff --git a/libselinux/src/selinux_config.c b/libselinux/src/selinux_config.c
index 1d8cfb71..75db14ba 100644
--- a/libselinux/src/selinux_config.c
+++ b/libselinux/src/selinux_config.c
@@ -153,7 +153,6 @@  static int setpolicytype(const char *type)
 }
 
 static char *selinux_policyroot = NULL;
-static const char *selinux_rootpath = SELINUXDIR;
 
 static void init_selinux_config(void)
 {
@@ -312,7 +311,7 @@  int selinux_set_policy_root(const char *path)
 
 const char *selinux_path(void)
 {
-	return selinux_rootpath;
+	return SELINUXDIR;
 }