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

From:
Omar Polo <op@omarpolo.com>
Subject:
gotwebd: use nitems instead of ACTIONS__MAX
To:
gameoftrees@openbsd.org
Date:
Sun, 17 Dec 2023 19:28:36 +0100

Download raw body.

Thread
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?

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;