commit - f292b27176775cc4061f3da0be7fe0efcaf0325c
commit + 04b2c111f2cee68f0aa07855fcb7329a4913050b
blob - 49849c1f11676fb3f5efd0fbc0d00c2eae817bec
blob + 82e38605c1ffbff88bf742a36e48bb502581d804
--- gotwebd/got_operations.c
+++ gotwebd/got_operations.c
struct repo_commit *, struct got_commit_object *, struct got_reflist_head *,
struct got_object_id *);
static const struct got_error *got_gotweb_dupfd(int *, int *);
-static const struct got_error *got_gotweb_openfile(FILE **, int *, int *);
+static const struct got_error *got_gotweb_openfile(FILE **, int *);
static const struct got_error *got_gotweb_blame_cb(void *, int, int,
struct got_commit_object *,struct got_object_id *);
const struct got_error *
-got_gotweb_flushfile(FILE *f, int fd)
+got_gotweb_flushfile(FILE *f)
{
if (fseek(f, 0, SEEK_SET) == -1)
return got_error_from_errno("fseek");
- if (ftruncate(fd, 0) == -1)
+ if (ftruncate(fileno(f), 0) == -1)
return got_error_from_errno("ftruncate");
- if (fsync(fd) == -1)
+ if (fsync(fileno(f)) == -1)
return got_error_from_errno("fsync");
- if (f && fclose(f) == EOF)
+ if (fclose(f) == EOF)
return got_error_from_errno("fclose");
- if (fd != -1 && close(fd) != -1)
- return got_error_from_errno("close");
-
return NULL;
}
static const struct got_error *
-got_gotweb_openfile(FILE **f, int *priv_fd, int *fd)
+got_gotweb_openfile(FILE **f, int *priv_fd)
{
- *fd = dup(*priv_fd);
- if (*fd == -1)
+ int fd;
+
+ fd = dup(*priv_fd);
+ if (fd == -1)
return got_error_from_errno("dup");
- *f = fdopen(*fd, "w+");
+ *f = fdopen(fd, "w+");
if (*f == NULL) {
- close(*fd);
+ close(fd);
return got_error(GOT_ERR_PRIVSEP_NO_FD);
}
struct got_blob_object *blob = NULL;
char *path = NULL, *in_repo_path = NULL;
struct blame_cb_args bca;
- int i, obj_type, fd1 = -1, fd2 = -1, fd3 = -1, fd4 = -1, fd5 = -1;
- int fd6 = -1;
+ int i, obj_type, fd2 = -1, fd3 = -1, fd4 = -1;
off_t filesize;
FILE *f1 = NULL, *f2 = NULL;
goto done;
}
- error = got_gotweb_openfile(&bca.f, &c->priv_fd[BLAME_FD_1], &fd1);
+ error = got_gotweb_openfile(&bca.f, &c->priv_fd[BLAME_FD_1]);
if (error)
goto done;
if (error)
goto done;
- error = got_gotweb_openfile(&f1, &c->priv_fd[BLAME_FD_5], &fd5);
+ error = got_gotweb_openfile(&f1, &c->priv_fd[BLAME_FD_5]);
if (error)
goto done;
- error = got_gotweb_openfile(&f2, &c->priv_fd[BLAME_FD_6], &fd6);
+ error = got_gotweb_openfile(&f2, &c->priv_fd[BLAME_FD_6]);
if (error)
goto done;
if (fd4 != -1 && close(fd4) == -1 && error == NULL)
error = got_error_from_errno("close");
if (bca.f) {
- const struct got_error *bca_err =
- got_gotweb_flushfile(bca.f, fd1);
+ const struct got_error *bca_err = got_gotweb_flushfile(bca.f);
if (error == NULL)
error = bca_err;
}
if (f1) {
- const struct got_error *f1_err =
- got_gotweb_flushfile(f1, fd5);
+ const struct got_error *f1_err = got_gotweb_flushfile(f1);
if (error == NULL)
error = f1_err;
}
if (f2) {
- const struct got_error *f2_err =
- got_gotweb_flushfile(f2, fd6);
+ const struct got_error *f2_err = got_gotweb_flushfile(f2);
if (error == NULL)
error = f2_err;
}
}
const struct got_error *
-got_open_diff_for_output(FILE **fp, int *fd, struct request *c)
+got_open_diff_for_output(FILE **fp, struct request *c)
{
const struct got_error *error = NULL;
struct transport *t = c->t;
struct got_object_id *id1 = NULL, *id2 = NULL;
struct got_reflist_head refs;
FILE *f1 = NULL, *f2 = NULL, *f3 = NULL;
- int obj_type, fd1, fd2, fd3, fd4 = -1, fd5 = -1;
+ int obj_type, fd4 = -1, fd5 = -1;
*fp = NULL;
- *fd = -1;
TAILQ_INIT(&refs);
- error = got_gotweb_openfile(&f1, &c->priv_fd[DIFF_FD_1], &fd1);
+ error = got_gotweb_openfile(&f1, &c->priv_fd[DIFF_FD_1]);
if (error)
return error;
- error = got_gotweb_openfile(&f2, &c->priv_fd[DIFF_FD_2], &fd2);
+ error = got_gotweb_openfile(&f2, &c->priv_fd[DIFF_FD_2]);
if (error)
return error;
- error = got_gotweb_openfile(&f3, &c->priv_fd[DIFF_FD_3], &fd3);
+ error = got_gotweb_openfile(&f3, &c->priv_fd[DIFF_FD_3]);
if (error)
return error;
}
*fp = f3;
- *fd = fd3;
done:
if (fd4 != -1 && close(fd4) == -1 && error == NULL)
if (fd5 != -1 && close(fd5) == -1 && error == NULL)
error = got_error_from_errno("close");
if (f1) {
- const struct got_error *f1_err =
- got_gotweb_flushfile(f1, fd1);
+ const struct got_error *f1_err = got_gotweb_flushfile(f1);
if (error == NULL)
error = f1_err;
}
if (f2) {
- const struct got_error *f2_err =
- got_gotweb_flushfile(f2, fd2);
+ const struct got_error *f2_err = got_gotweb_flushfile(f2);
if (error == NULL)
error = f2_err;
}
if (error && f3) {
- got_gotweb_flushfile(f3, fd3);
+ got_gotweb_flushfile(f3);
*fp = NULL;
- *fd = -1;
}
got_ref_list_free(&refs);
free(id1);
blob - 7adff244e79d7255b82e75217b2f4ef08aea0a1c
blob + 73dbb1e0e2e499ffe8416b6d4afbca31e255970f
--- gotwebd/gotweb.c
+++ gotwebd/gotweb.c
log_warnx("%s: %s", __func__, error->msg);
goto err;
}
- error = got_open_diff_for_output(&c->t->fp, &c->t->fd, c);
+ error = got_open_diff_for_output(&c->t->fp, c);
if (error) {
log_warnx("%s: %s", __func__, error->msg);
goto err;
if (t->blob)
got_object_blob_close(t->blob);
if (t->fp) {
- err = got_gotweb_flushfile(t->fp, t->fd);
+ err = got_gotweb_flushfile(t->fp);
if (err)
log_warnx("%s: got_gotweb_flushfile failure: %s",
__func__, err->msg);
- t->fd = -1;
}
if (t->fd != -1)
close(t->fd);
blob - 9e8e0a7344f99e5a308fc5d0932d6f1dc7d81e61
blob + 6143eaf2f67efd948d7df9e1ce6ed0c28f584cce
--- gotwebd/gotwebd.h
+++ gotwebd/gotwebd.h
int fcgi_gen_binary_response(struct request *, const uint8_t *, int);
/* got_operations.c */
-const struct got_error *got_gotweb_flushfile(FILE *, int);
+const struct got_error *got_gotweb_flushfile(FILE *);
const struct got_error *got_get_repo_owner(char **, struct request *);
const struct got_error *got_get_repo_age(time_t *, struct request *,
const char *);
const struct got_error *got_get_repo_commits(struct request *, int);
const struct got_error *got_get_repo_tags(struct request *, int);
const struct got_error *got_get_repo_heads(struct request *);
-const struct got_error *got_open_diff_for_output(FILE **, int *,
- struct request *);
+const struct got_error *got_open_diff_for_output(FILE **, struct request *);
int got_output_repo_tree(struct request *,
int (*)(struct template *, struct got_tree_entry *));
const struct got_error *got_open_blob_for_output(struct got_blob_object **,