rem: int i, j;
add: int i, j, l;
context: int cmd_dump ( int fd, struct avrpart * p, int argc, char * argv[] ){  char * e;  int i, j;  unsigned short daddr;  char * buf;  int maxsize;  static AVRMEM memtype=AVR_FLASH;  static unsigned short addr=0;  static int len=64;  if (argc == 1) {    addr += len;  }  else {    if (argc != 4) {      fprintf(stderr, "Usage: dump flash|eeprom <addr> <len>\n");      return -1;    }    if (strcmp(argv[1],"flash")==0) {      memtype = AVR_FLASH;    }    else if (strcmp(argv[1],"eeprom")==0) {      memtype = AVR_EEPROM;    }    else {      fprintf(stderr, "%s (dump): invalid memory type \"%s\"\n",              progname, argv[1]);      return -1;    }    addr = strtoul(argv[2], &e, 0);    if (*e || (e == argv[2])) {      fprintf(stderr, "%s (dump): can't parse address \"%s\"\n",              progname, argv[2]);      return -1;    }    len = strtol(argv[3], &e, 0);    if (*e || (e == argv[3])) {      fprintf(stderr, "%s (dump): can't parse length \"%s\"\n",              progname, argv[3]);      return -1;    }  }  switch (memtype) {    case AVR_FLASH  : maxsize = p->flash_size; break;    case AVR_EEPROM : maxsize = p->eeprom_size; break;    default : return -1; /* this can't happen, but is silences gcc                            warnings */  }  if (addr > maxsize) {    fprintf(stderr,             "%s (dump): address 0x%04x is out of range for %s memory\n",            progname, addr, avr_memtstr(memtype));    return -1;  }  /* trim len if nessary to not read past the end of memory */  if ((addr + len) > maxsize)    len = maxsize - addr;  buf = malloc(len);  if (buf == NULL) {    fprintf(stderr, "%s (dump): out of memory\n", progname);    return -1;  }  j     = 0;  daddr = addr;  if (memtype == AVR_FLASH) {    daddr = addr / 2;    if (addr & 0x01) {      buf[j++] = avr_read_byte( fd, p, AVR_FLASH_HI, daddr);      daddr++;    }  }  i = daddr;  while (j < len) {    if (memtype == AVR_FLASH) {      buf[j++] = avr_read_byte( fd, p, AVR_FLASH_LO, i);      if (j < len) {        buf[j++] = avr_read_byte( fd, p, AVR_FLASH_HI, i);      }    }    else {      buf[j++] = avr_read_byte( fd, p, AVR_EEPROM, i);    }    i++;  }  hexdump_buf(stdout, addr, buf, len);  fprintf(stdout, "\n");  free(buf);  return 0;}