Skip to contentSkip to conversation

iproute2: Check getline() return code correctly

PATCH In review Petr Sabata 2 participants 2 messages Jun 10, 2011 – Jul 11, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iproute2: Check getline() return code correctly

The current implementation is always false, no matter what happens.

---
 lib/utils.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/utils.c +1 -1
index 1b42222..76cadea 100644
@@ -702,7 +702,7 @@ ssize_t getcmdline(char **linep, size_t *lenp, FILE *in)
 		size_t len1 = 0;
 		size_t cc1;
 
-		if ((cc1 = getline(&line1, &len1, in)) < 0) {
+		if ((cc1 = getline(&line1, &len1, in)) == (size_t)-1) {
 			fprintf(stderr, "Missing continuation line\n");
 			return cc1;
 		}
Signature · 1 line
1.7.5.2
#1 lore raw
Quoted 12 lines · On Fri, 10 Jun 2011 14:49:27 +0200 Petr Sabata <[email protected]> wrote:

The current implementation is always false, no matter what happens.

---
 lib/utils.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/utils.c +0 -0
index 1b42222..76cadea 100644

lib/utils.c ssize_t getcmdline(char **linep, size_t *lenp, FILE *in) · line 708

Quoted 8 lines
lib/utils.c +1 -1
@@ -702,7 +702,7 @@ ssize_t getcmdline(char **linep, size_t *lenp, FILE *in)
 		size_t len1 = 0;
 		size_t cc1;
 
-		if ((cc1 = getline(&line1, &len1, in)) < 0) {
+		if ((cc1 = getline(&line1, &len1, in)) == (size_t)-1) {
 			fprintf(stderr, "Missing continuation line\n");
 			return cc1;
 		}

The correct fix is to make cc1 a signed variable.