commit 03e70dd4d41906645718ee5b780d7e948404f292 from: Omar Polo date: Thu Nov 16 21:28:34 2023 UTC gotwebd: improve gotwebd_assign_querystring() This prevents the issues that we just hit with forgetting to remove PREVID: instead of relying on the enum value to yield the size of a table, use nitems(). Also, quit as soon as the matching key was found, no need to iterate further. ok stsp@ commit - abe89edb698f9d165b74d1fe146b13fade5b52bd commit + 03e70dd4d41906645718ee5b780d7e948404f292 blob - 5d1283460327c8a36e76c5f8ed29b5fd573a5ce8 blob + 072c326702282d6c37c250bb57b593f5ce07776f --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -559,7 +559,7 @@ gotweb_assign_querystring(struct querystring **qs, cha if (error) return error; - for (el_cnt = 0; el_cnt < QSELEM__MAX; el_cnt++) { + for (el_cnt = 0; el_cnt < nitems(querystring_keys); el_cnt++) { if (strcmp(key, querystring_keys[el_cnt].name) != 0) continue; @@ -645,9 +645,10 @@ qa_found: if ((*qs)->page < 0) (*qs)->page = 0; break; - default: - break; } + + /* entry found */ + break; } done: return error; blob - 87f3ab6f87b6831ca7b065a759bc71c251bdcf2d blob + f2e1d1c756973046a69181f403f1187c8b7432cc --- gotwebd/gotwebd.h +++ gotwebd/gotwebd.h @@ -416,7 +416,6 @@ enum querystring_elements { INDEX_PAGE, PATH, PAGE, - QSELEM__MAX, }; enum query_actions {