"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: gotwebd: use nitems instead of ACTIONS__MAX
To:
Omar Polo <op@omarpolo.com>
Cc:
gameoftrees@openbsd.org
Date:
Mon, 18 Dec 2023 12:15:34 +0100

Download raw body.

Thread
On Sun, Dec 17, 2023 at 07:28:36PM +0100, Omar Polo wrote:
> I feel safer by using the explicit size of the table we're iterating on
> rather than an hypothetical enum value.  Mostly because in the past I
> edited a table and forgot to remove the corresponding enum value.
> 
> ok?

ok stsp

> 
> diff /home/op/w/got
> commit - ec6805e0ef19cc0722e52c13ff1d4564871874f8
> path + /home/op/w/got
> blob - b239682d6facfbcf008dbdd483553041b26e7565
> file + gotwebd/gotweb.c
> --- gotwebd/gotweb.c
> +++ gotwebd/gotweb.c
> @@ -574,7 +574,7 @@ gotweb_assign_querystring(struct querystring **qs, cha
>  
>  		switch (querystring_keys[el_cnt].element) {
>  		case ACTION:
> -			for (a_cnt = 0; a_cnt < ACTIONS__MAX; a_cnt++) {
> +			for (a_cnt = 0; a_cnt < nitems(action_keys); a_cnt++) {
>  				if (strcmp(value, action_keys[a_cnt].name) != 0)
>  					continue;
>  				else if (strcmp(value,
> blob - bc6ca2997db0f950005a8273f15b3b9e79eebb6a
> file + gotwebd/gotwebd.h
> --- gotwebd/gotwebd.h
> +++ gotwebd/gotwebd.h
> @@ -439,7 +439,6 @@ enum query_actions {
>  	TAGS,
>  	TREE,
>  	RSS,
> -	ACTIONS__MAX,
>  };
>  
>  extern struct gotwebd	*gotwebd_env;
> 
>