Commit 4b60fecedffa10e9ad1531cab9b5827c17e9d059

Stefan Sperling 2020-01-29T13:25:54

call strdup("") instead of asprintf(&var, "")

diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index 639f859..1ec59fc 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -1348,10 +1348,7 @@ gw_get_repo_description(struct gw_trans *gw_trans, char *dir)
 	free(d_file);
 	return description;
 err:
-	if (asprintf(&description, "%s", "") == -1)
-		return NULL;
-
-	return description;
+	return strdup("");
 }
 
 static char *
@@ -1442,11 +1439,8 @@ gw_get_repo_age(struct gw_trans *gw_trans, char *dir, char *repo_ref,
 	if (strncmp(repo_ref, "refs/heads/", 11) == 0)
 		is_head = 1;
 
-	if (gw_trans->gw_conf->got_show_repo_age == false) {
-		if (asprintf(&repo_age, "") == -1)
-			return NULL;
-		return repo_age;
-	}
+	if (gw_trans->gw_conf->got_show_repo_age == false)
+		return strdup("");
 
 	error = got_repo_open(&repo, dir, NULL);
 	if (error)
@@ -1490,8 +1484,7 @@ gw_get_repo_age(struct gw_trans *gw_trans, char *dir, char *repo_ref,
 		committer_time = cmp_time;
 		repo_age = gw_get_time_str(committer_time, ref_tm);
 	} else
-		if (asprintf(&repo_age, "") == -1)
-			return NULL;
+		return strdup("");
 	got_ref_list_free(&refs);
 	free(id);
 	return repo_age;
@@ -1657,10 +1650,7 @@ gw_get_repo_owner(struct gw_trans *gw_trans, char *dir)
 	free(d_file);
 	return owner;
 err:
-	if (asprintf(&owner, "%s", "") == -1)
-		return NULL;
-
-	return owner;
+	return strdup("");
 }
 
 static char *