rem: rc = write(fd, p, 1);
add: rc = write(fd, p, (len > 1024) ? 1024 : len);
context: int serial_send(int fd, char * buf, size_t buflen){  struct timeval timeout;  fd_set wfds;  int nfds;  int rc;  char * p = buf;  size_t len = buflen;  if (!len)    return 0;  if (verbose > 3)  {      fprintf(stderr, "%s: Send: ", progname);      while (buflen) {        unsigned char c = *buf;        if (isprint(c)) {          fprintf(stderr, "%c ", c);        }        else {          fprintf(stderr, ". ");        }        fprintf(stderr, "[%02x] ", c);        buf++;        buflen--;      }      fprintf(stderr, "\n");  }  timeout.tv_sec = 0;  timeout.tv_usec = 500000;  while (len) {    FD_ZERO(&wfds);    FD_SET(fd, &wfds);  reselect:    nfds = select(fd+1, NULL, &wfds, NULL, &timeout);    if (nfds == 0) {      if (verbose >= 1)	fprintf(stderr,		"%s: serial_send(): programmer is not responding\n",		progname);      exit(1);    }    else if (nfds == -1) {      if (errno == EINTR) {        goto reselect;      }      else {        fprintf(stderr, "%s: serial_send(): select(): %s\n",                progname, strerror(errno));        exit(1);      }    }    rc = write(fd, p, 1);    if (rc < 0) {      fprintf(stderr, "%s: serial_send(): write error: %s\n",              progname, strerror(errno));      exit(1);    }    p++;    len--;  }  return 0;}