[PATCH v2 1/1] Add system-wide tunables: implement overridability

Andreas Schwab schwab@suse.de
Mon Jul 6 07:35:23 GMT 2026


On Jul 02 2026, DJ Delorie wrote:

> diff --git a/elf/tunconf.c b/elf/tunconf.c
> index a5ca755abd..c27b50b1de 100644
> --- a/elf/tunconf.c
> +++ b/elf/tunconf.c
> @@ -194,34 +194,40 @@ add_tunable (char *line, const char *filename, int lineno)
>    /* Parse modifiers.  */
>    while (*line)
>      {
> -      if (strncmp (line, "overridable ", 13) == 0)
> +      int prefix_len;
> +
> +#define TUN_PREFIX(s)				\
> +      prefix_len = sizeof(s) - 1,			\
> +	strncmp (line, s " ", prefix_len + 1) == 0
> +
> +      if (TUN_PREFIX("overridable"))
>  	{
>  	  top = TOP_ALLOW;
>  	  /* The line++ below skips the space.  */
> -	  line += 12;
> +	  line += prefix_len;
>  	}
> -      else if (strncmp (line, "nonoverridable ", 16) == 0)
> +      else if (TUN_PREFIX ("nonoverridable"))
>  	{
>  	  top = TOP_DENY;
> -	  line += 15;
> +	  line += prefix_len;
>  	}
> -      else if (strncmp (line, "onlysecure ", 11) == 0)
> +      else if (TUN_PREFIX ("onlysecure"))
>  	{
>  	  exclude_nonsecure = 1;
>  	  exclude_secure = 0;
> -	  line += 10;
> +	  line += prefix_len;
>  	}
> -      else if (strncmp (line, "nonsecure ", 10) == 0)
> +      else if (TUN_PREFIX ("nonsecure"))
>  	{
>  	  exclude_secure = 1;
>  	  exclude_nonsecure = 0;
> -	  line += 9;
> +	  line += prefix_len;
>  	}
> -      else if (strncmp (line, "anysecure ", 10) == 0)
> +      else if (TUN_PREFIX ("anysecure"))
>  	{
>  	  exclude_secure = 0;
>  	  exclude_nonsecure = 0;
> -	  line += 9;
> +	  line += prefix_len;
>  	}
>        else switch (*line)
>  	{

This looks good.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


More information about the Libc-alpha mailing list