getline: fix the return type to ssize_t and small nits
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
diff --git a/got/got.c b/got/got.c
index e9a814c..212005d 100644
--- a/got/got.c
+++ b/got/got.c
@@ -2410,7 +2410,7 @@ blame_cb(void *arg, int nlines, int lineno, struct got_object_id *id)
char *smallerthan, *at, *nl, *committer;
size_t len;
- if (getline(&line, &linesize, a->f) == (ssize_t)-1) {
+ if (getline(&line, &linesize, a->f) == -1) {
if (ferror(a->f))
err = got_error_from_errno("getline");
break;
diff --git a/lib/diff3.c b/lib/diff3.c
index 87c3a41..7f642f7 100644
--- a/lib/diff3.c
+++ b/lib/diff3.c
@@ -655,7 +655,8 @@ static char *
get_line(FILE *b, size_t *n, struct diff3_state *d3s)
{
char *cp = NULL;
- size_t size, len;
+ size_t size;
+ ssize_t len;
char *new;
char *ret = NULL;
diff --git a/lib/worktree.c b/lib/worktree.c
index c6ccac6..729abd3 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -2864,9 +2864,12 @@ skip_one_line(FILE *f)
ssize_t linelen;
linelen = getline(&line, &linesize, f);
+ if (linelen == -1) {
+ if (ferror(f))
+ return got_error_from_errno("getline");
+ return NULL;
+ }
free(line);
- if (linelen == -1 && ferror(f))
- return got_error_from_errno("getline");
return NULL;
}