diff options
author | Pedro F. Giffuni <pfg@FreeBSD.org> | 2016-12-12 20:25:59 +0000 |
---|---|---|
committer | Pedro F. Giffuni <pfg@FreeBSD.org> | 2016-12-12 20:25:59 +0000 |
commit | 8bd856de216d9f46e0b028e7479099fb9d56324e (patch) | |
tree | 5e410015a905d787a1b74ebe6d8ccfff7ce90d46 /bin | |
parent | adff859ba29a4020ef33c7faf96e9ed5cf92e573 (diff) | |
download | src-8bd856de216d9f46e0b028e7479099fb9d56324e.tar.gz src-8bd856de216d9f46e0b028e7479099fb9d56324e.zip |
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.
Notes
Notes:
svn path=/head/; revision=309936
Diffstat (limited to 'bin')
-rw-r--r-- | bin/ed/buf.c | 10 |
1 files 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"; |