[PATCH 2/3] Config file fixes.

Ian Jackson ijackson at chiark.greenend.org.uk
Thu Aug 4 15:16:21 BST 2011


Richard Kettlewell writes ("[PATCH 2/3] Config file fixes."):
> * Reject integers in excess of 2^32-1 (rather than reducing them mod
>   2^32).
> * ptree_dump():
>   - Remove a magic number.
>   - More realistic recursion limit.
> * Various bits of type hygeine.
...

> +#define T_IS_PRIMITIVE(NTYPE) ((NTYPE) < T_ASSIGNMENT)

Yes, much better.

>  /* Convert a node type to a string, for parse tree dump */
> -static string_t ntype(uint32_t type)
> +static const char *ntype(uint32_t type)

We seem to be gradually abolishing [c]string_t.  Perhaps we should do
so globally ?  (Says the guy with a huge outstanding patch serieses...)

> @@ -197,7 +197,7 @@ static void ptree_dump(struct p_node *n, uint32_t d)
>  	default:       printf("**unknown primitive type**\n"); break;
>  	}
>      } else {
> -	assert(d<INT_MAX);
> +	assert(d<10000);

This is an excessive recursion catch, isn't it ?  Why is it a uint32_t
even ?  I think my uint32_t => int changes should probably have
touched this too.

> diff --git a/conffile.fl b/conffile.fl
> index 2cfa21b..7228c9e 100644
> --- a/conffile.fl
> +++ b/conffile.fl
...
> -	uint32_t lineno;
> +	int lineno;

I remember spotting this and not changing it.  I can't remember why.

> @@ -71,8 +71,25 @@ static struct p_node *stringnode(string_t string)
>  static struct p_node *numnode(string_t number)
>  {
>  	struct p_node *r;
> +	unsigned long n;
>  	r=leafnode(T_NUMBER);
> -	r->data.number=atoi(number);
> +	errno = 0;
> +	n = strtoul(number, NULL, 10);
> +	/* The caller is expected to only give us [0-9]+,
> +	 * so we skip some of the usual syntax checking. */

By "the caller" you mean flex ?

Ian.



More information about the sgo-software-discuss mailing list