From 8bd856de216d9f46e0b028e7479099fb9d56324e Mon Sep 17 00:00:00 2001 From: "Pedro F. Giffuni" Date: Mon, 12 Dec 2016 20:25:59 +0000 Subject: [PATCH] ed(1): Simplify some checks. The return type for both fread(3) and fwrite(3) cannot be negative, this renders some checks invalid and variable 'ct' unnecessary. Also bump 'len' to size_t to avoid signed/unsigned comparison warnings. --- bin/ed/buf.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/ed/buf.c b/bin/ed/buf.c index 6d8a6ed4f559..35b5d4d55dc1 100644 --- a/bin/ed/buf.c +++ b/bin/ed/buf.c @@ -46,9 +46,9 @@ char * get_sbuf_line(line_t *lp) { static char *sfbuf = NULL; /* buffer */ - static int sfbufsz = 0; /* buffer size */ + static size_t sfbufsz; /* buffer size */ - int len, ct; + size_t len; if (lp == &buffer_head) return NULL; @@ -64,7 +64,7 @@ get_sbuf_line(line_t *lp) } len = lp->len; REALLOC(sfbuf, sfbufsz, len + 1, NULL); - if ((ct = fread(sfbuf, sizeof(char), len, sfp)) < 0 || ct != len) { + if ((fread(sfbuf, sizeof(char), len, sfp)) != len) { fprintf(stderr, "%s\n", strerror(errno)); errmsg = "cannot read temp file"; return NULL; @@ -81,7 +81,7 @@ const char * put_sbuf_line(const char *cs) { line_t *lp; - int len, ct; + size_t len; const char *s; if ((lp = (line_t *) malloc(sizeof(line_t))) == NULL) { @@ -110,7 +110,7 @@ put_sbuf_line(const char *cs) seek_write = 0; } /* assert: SPL1() */ - if ((ct = fwrite(cs, sizeof(char), len, sfp)) < 0 || ct != len) { + if ((fwrite(cs, sizeof(char), len, sfp)) != len) { sfseek = -1; fprintf(stderr, "%s\n", strerror(errno)); errmsg = "cannot write temp file";