commit - a02d5f81107cb783552f0f456fccf21a313ec9c9
commit + 4619e1f27d033f60048feafe2ed45e81271931ef
blob - a8bbb9d6f6ab87b8cde03db11f8b6466786710b2
blob + 8e779895f04d77918cf216dd1a834a21a830eaf9
--- gotweb/gotweb.c
+++ gotweb/gotweb.c
{ kvalid_stringne, "path" },
};
-static struct gw_dir *gw_init_gw_dir(char *);
+static const struct got_error *gw_init_gw_dir(struct gw_dir **, char *);
static struct gw_header *gw_init_header(void);
static void gw_free_headers(struct gw_header *);
strcmp(sd_dent[d_i]->d_name, "..") == 0)
continue;
- if ((gw_dir = gw_init_gw_dir(sd_dent[d_i]->d_name)) == NULL)
- return got_error_from_errno("gw_dir malloc");
+ error = gw_init_gw_dir(&gw_dir, sd_dent[d_i]->d_name);
+ if (error)
+ return error;
error = gw_load_got_path(gw_trans, gw_dir);
if (error && error->code == GOT_ERR_NOT_GIT_REPO) {
error = got_error_from_errno("invalid action");
return error;
}
- if ((gw_trans->gw_dir =
- gw_init_gw_dir(gw_trans->repo_name)) == NULL)
- return got_error_from_errno("gw_dir malloc");
+ error = gw_init_gw_dir(&gw_trans->gw_dir, gw_trans->repo_name);
+ if (error)
+ return error;
error = gw_load_got_path(gw_trans, gw_trans->gw_dir);
if (error)
return error;
}
-static struct gw_dir *
-gw_init_gw_dir(char *dir)
-{
- struct gw_dir *gw_dir;
+static const struct got_error *
+gw_init_gw_dir(struct gw_dir **gw_dir, char *dir)
+{
+ const struct got_error *error;
- if ((gw_dir = malloc(sizeof(*gw_dir))) == NULL)
- return NULL;
+ *gw_dir = malloc(sizeof(**gw_dir));
+ if (*gw_dir == NULL)
+ return got_error_from_errno("malloc");
- if (asprintf(&gw_dir->name, "%s", dir) == -1)
+ if (asprintf(&(*gw_dir)->name, "%s", dir) == -1) {
+ error = got_error_from_errno("asprintf");
+ free(*gw_dir);
+ *gw_dir = NULL;
return NULL;
+ }
- return gw_dir;
+ return NULL;
}
static const struct got_error *