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

From:
Tracey Emery <tracey@traceyemery.net>
Subject:
Re: const-ify more tables
To:
Christian Weisgerber <naddy@mips.inka.de>
Cc:
gameoftrees@openbsd.org
Date:
Thu, 17 Mar 2022 12:32:14 -0600

Download raw body.

Thread
On Thu, Mar 17, 2022 at 06:51:44PM +0100, Christian Weisgerber wrote:
> The ongoing const-ification commits for the OpenBSD kernel made me
> look again at got; this const-ifies some more tables.
> 
> OK?
> 
> (tracey, gotweb doesn't build because of a write-only variable
> warning.)

Thanks. I'll look when I get some time. I think we're up to at least
three users. :D

> 
> diff refs/heads/main refs/heads/const
> blob - ec7d4be738eed407bdd0ad0b89f270f2dc05237f
> blob + 3d41e56213bc4d3fd6b1706e030dcca8520d7b4f
> --- gotweb/gotweb.c
> +++ gotweb/gotweb.c
> @@ -251,7 +251,7 @@ enum gw_query_actions {
>  	GW_TREE,
>  };
>  
> -static struct gw_query_action gw_query_funcs[] = {
> +static const struct gw_query_action gw_query_funcs[] = {
>  	{ GW_BLAME,	"blame",	gw_blame,	"gw_tmpl/blame.tmpl" },
>  	{ GW_BLOB,	"blob",		NULL,		NULL },
>  	{ GW_BRIEFS,	"briefs",	gw_briefs,	"gw_tmpl/briefs.tmpl" },
> @@ -2022,7 +2022,7 @@ gw_parse_querystring(struct gw_trans *gw_trans)
>  {
>  	const struct got_error *error = NULL;
>  	struct kpair *p;
> -	struct gw_query_action *action = NULL;
> +	const struct gw_query_action *action = NULL;
>  	unsigned int i;
>  
>  	if (gw_trans->gw_req->fieldnmap[0]) {
> blob - 3580b0e0d35257395481742823e17c91ea06d00c
> blob + b3bbf0b189575c109c8b935c3519ade298fed3aa
> --- lib/deltify.c
> +++ lib/deltify.c
> @@ -41,7 +41,7 @@
>   * https://www.usenix.org/conference/atc16/technical-sessions/presentation/xia
>   */
>  
> -static uint32_t geartab[256] = {
> +static const uint32_t geartab[256] = {
>      0x67ed26b7, 0x32da500c, 0x53d0fee0, 0xce387dc7, 0xcd406d90, 0x2e83a4d4,
>      0x9fc9a38d, 0xb67259dc, 0xca6b1722, 0x6d2ea08c, 0x235cea2e, 0x3149bb5f,
>      0x1beda787, 0x2a6b77d5, 0x2f22d9ac, 0x91fc0544, 0xe413acfa, 0x5a30ff7a,
> blob - 11c0b2dbe393420ad16b7edafd58d2091f9c1c8e
> blob + e3a4b185b73dabfec5854af9ec5c835f0a9c610d
> --- libexec/got-send-pack/got-send-pack.c
> +++ libexec/got-send-pack/got-send-pack.c
> @@ -339,7 +339,7 @@ send_pack(int fd, struct got_pathlist_head *refs,
>  {
>  	const struct got_error *err = NULL;
>  	char buf[GOT_PKT_MAX];
> -	unsigned char zero_id[SHA1_DIGEST_LENGTH] = { 0 };
> +	const unsigned char zero_id[SHA1_DIGEST_LENGTH] = { 0 };
>  	char old_hashstr[SHA1_DIGEST_STRING_LENGTH];
>  	char new_hashstr[SHA1_DIGEST_STRING_LENGTH];
>  	struct got_pathlist_head their_refs;
> blob - 984dc73376528f545472d7e802bb1dc495fb001d
> blob + 377ea9cd19e22c07f1348e7110a49defd8cb974d
> --- regress/delta/delta_test.c
> +++ regress/delta/delta_test.c
> @@ -33,7 +33,7 @@
>  #define nitems(_a) (sizeof(_a) / sizeof((_a)[0]))
>  #endif
>  
> -struct delta_test {
> +const struct delta_test {
>  	const char *base;
>  	size_t base_len;
>  	const char *delta;
> @@ -67,7 +67,7 @@ delta_apply(void)
>  		return 1;
>  
>  	for (i = 0; i < nitems(delta_tests); i++) {
> -		struct delta_test *dt = &delta_tests[i];
> +		const struct delta_test *dt = &delta_tests[i];
>  		FILE *base_file;
>  		char buf[1024];
>  		size_t n, result_len;
> blob - 4afec393aaf467cb872d53e452b471df35ae6c9b
> blob + 5077275c15513b4be193788a5f50ce0fff48b24a
> --- regress/fetch/fetch_test.c
> +++ regress/fetch/fetch_test.c
> @@ -62,7 +62,7 @@ static int
>  fetch_parse_uri(void)
>  {
>  	const struct got_error *err = NULL;
> -	struct parse_uri_test {
> +	const struct parse_uri_test {
>  		const char *uri;
>  		const char *proto;
>  		const char *host;
> blob - cb17e05405edca193cab8ab4da47e83af9ed79a6
> blob + 76b5b1f6f53409fd36f72543864785faa2adb4bc
> --- regress/path/path_test.c
> +++ regress/path/path_test.c
> @@ -49,7 +49,7 @@ test_printf(char *fmt, ...)
>  static int
>  path_cmp(void)
>  {
> -	struct path_cmp_test {
> +	const struct path_cmp_test {
>  		const char *path1;
>  		const char *path2;
>  		int expected;
> -- 
> Christian "naddy" Weisgerber                          naddy@mips.inka.de
> 

-- 

Tracey Emery