Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Drop cgit_read_first_line's unread size output
Diffstat (limited to 'source')
| -rw-r--r-- | source/scan-tree.c | 3 | |
| -rw-r--r-- | source/shared.c | 6 | |
| -rw-r--r-- | source/shared.h | 2 | |
| -rw-r--r-- | source/ui-repolist.c | 3 |
4 files changed, 5 insertions, 9 deletions
diff --git a/source/scan-tree.c b/source/scan-tree.c index 7caa5eb..f29738c 100644 --- a/source/scan-tree.c +++ b/source/scan-tree.c @@ -150,7 +150,6 @@ static void add_repo(const char *base, struct strbuf *path) size_t pathlen; struct strbuf relpath = STRBUF_INIT; char *comma; - size_t desc_size; if (stat(path->buf, &st)) { fprintf(stderr, "[cgit] Unable to access %s: %s (%d)\n", path->buf, strerror(errno), errno); @@ -235,7 +234,7 @@ static void add_repo(const char *base, struct strbuf *path) if (current_repo->desc == cgit_default_repo_desc) { strbuf_addstr(path, "description"); - cgit_read_first_line(path->buf, ¤t_repo->desc, &desc_size); + cgit_read_first_line(path->buf, ¤t_repo->desc); strbuf_setlen(path, pathlen); if (current_repo->desc && !strcmp(current_repo->desc, default_git_desc)) { free(current_repo->desc); diff --git a/source/shared.c b/source/shared.c index d159a7a..30e2e12 100644 --- a/source/shared.c +++ b/source/shared.c @@ -505,7 +505,7 @@ void cgit_prepare_repo_env(struct cgit_repo *repo) vars[i].name, vars[i].value, strerror(errno), errno); } -int cgit_read_first_line(const char *path, char **buf, size_t *size) +int cgit_read_first_line(const char *path, char **buf) { int fd, err; ssize_t got; @@ -533,12 +533,10 @@ int cgit_read_first_line(const char *path, char **buf, size_t *size) err = errno; free(*buf); *buf = NULL; - *size = 0; close(fd); return err; } - *size = got; - (*buf)[*size] = '\0'; + (*buf)[got] = '\0'; *strchrnul(*buf, '\n') = '\0'; close(fd); return 0; diff --git a/source/shared.h b/source/shared.h index e22eb57..09e9296 100644 --- a/source/shared.h +++ b/source/shared.h @@ -98,7 +98,7 @@ extern void strbuf_ensure_end(struct strbuf *sb, char c); * Read the first line of a file into a newly allocated, zero terminated * buffer. Returns 0 on success and an errno value otherwise. */ -extern int cgit_read_first_line(const char *path, char **buf, size_t *size); +extern int cgit_read_first_line(const char *path, char **buf); extern char *cgit_strdup_first_line(const char *text); /* diff --git a/source/ui-repolist.c b/source/ui-repolist.c index 001e51b..4e4f61b 100644 --- a/source/ui-repolist.c +++ b/source/ui-repolist.c @@ -27,11 +27,10 @@ struct sort_column { static time_t read_agefile(const char *path) { time_t result; - size_t size; char *buf = NULL; struct strbuf date = STRBUF_INIT; - if (cgit_read_first_line(path, &buf, &size)) { + if (cgit_read_first_line(path, &buf)) { free(buf); return 0; } |
