Commit 500467ff1bf0dbd15c0941dd741e80c35c708818

Hiltjo Posthuma 2019-09-25T22:02:03

getline: fix the return type to ssize_t and small nits

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;
 }