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.
This commit is contained in:
parent
adff859ba2
commit
8bd856de21
10
bin/ed/buf.c
10
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";
|
||||
|
Loading…
Reference in New Issue
Block a user