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

From:
Tracey Emery <tracey@traceyemery.net>
Subject:
Re: Get rid of (null) on the index page
To:
gameoftrees@openbsd.org
Date:
Tue, 30 Aug 2022 12:53:27 -0600

Download raw body.

Thread
On Tue, Aug 30, 2022 at 08:46:41PM +0200, Stefan Sperling wrote:
> On Tue, Aug 30, 2022 at 12:38:27PM -0600, Tracey Emery wrote:
> > This gets rid of that very annoying (null) displayed on the index page.
> > 
> > ok?
> 
> > diff /home/tracey/src/got
> > commit - 5e91dae4dd43b8024731223110ab18f505f453ac
> > path + /home/tracey/src/got
> > blob - 3c69584a92b6b958e709a94fbda0d8de2e82ccf9
> > file + gotwebd/got_operations.c
> > --- gotwebd/got_operations.c
> > +++ gotwebd/got_operations.c
> > @@ -131,6 +131,9 @@ got_get_repo_owner(char **owner, struct request *c, ch
> >  		*owner = strdup(gitconfig_owner);
> >  		if (*owner == NULL)
> >  			return got_error_from_errno("strdup");
> > +	} else {
> > +		if (asprintf(owner, "%s", "") == -1)
> 
> Couldn't this use owner = strdup("")?
> 
> > +			return got_error_from_errno("asprintf");
> >  	}
> >  	return error;
> >  }
> > blob - f42caf75b1d7617a6d2c489ec63602ed33a0957d
> > file + gotwebd/gotweb.c
> > --- gotwebd/gotweb.c
> > +++ gotwebd/gotweb.c
> > @@ -2058,8 +2058,11 @@ gotweb_get_repo_description(char **description, struct
> >  		goto done;
> >  	}
> >  
> > -	if (len == 0)
> > +	if (len == 0) {
> > +		if (asprintf(description, "%s", "") == -1)
> > +			return got_error_from_errno("asprintf");
> 
> Same here?
> 
> >  		goto done;
> > +	}
> >  
> >  	if (fseek(f, 0, SEEK_SET) == -1) {
> >  		error = got_ferror(f, GOT_ERR_IO);
> > 
> > 
> 

Sure.

-- 

Tracey Emery

diff /home/tracey/src/got
commit - 977259281baa8a7a2776eefc691db02976cae993
path + /home/tracey/src/got
blob - 3c69584a92b6b958e709a94fbda0d8de2e82ccf9
file + gotwebd/got_operations.c
--- gotwebd/got_operations.c
+++ gotwebd/got_operations.c
@@ -131,6 +131,10 @@ got_get_repo_owner(char **owner, struct request *c, ch
 		*owner = strdup(gitconfig_owner);
 		if (*owner == NULL)
 			return got_error_from_errno("strdup");
+	} else {
+		*owner = strdup("");
+		if (*owner == NULL)
+			return got_error_from_errno("strdup");
 	}
 	return error;
 }
blob - f42caf75b1d7617a6d2c489ec63602ed33a0957d
file + gotwebd/gotweb.c
--- gotwebd/gotweb.c
+++ gotwebd/gotweb.c
@@ -2058,8 +2058,12 @@ gotweb_get_repo_description(char **description, struct
 		goto done;
 	}
 
-	if (len == 0)
+	if (len == 0) {
+		*description = strdup("");
+		if (*description == NULL)
+			return got_error_from_errno("strdup");
 		goto done;
+	}
 
 	if (fseek(f, 0, SEEK_SET) == -1) {
 		error = got_ferror(f, GOT_ERR_IO);