rem: fname = filename;
context: int fileio(int op, char * filename, FILEFMT format,              struct avrpart * p, char * memtype, int size){  int rc;  FILE * f;  char * fname;  unsigned char * buf;  struct fioparms fio;  int i;  AVRMEM * mem;  int using_stdio;  mem = avr_locate_mem(p, memtype);  if (mem == NULL) {    fprintf(stderr,             "fileio(): memory type \"%s\" not configured for device \"%s\"\n",            memtype, p->desc);    return -1;  }  rc = fileio_setparms(op, &fio);  if (rc < 0)    return -1;  #if defined(__CYGWIN__)  /* Open Raw Binary format in binary mode on Windows.*/  if(format == FMT_RBIN)  {      if(fio.op == FIO_READ)      {          fio.mode = "rb";      }      if(fio.op == FIO_WRITE)      {          fio.mode = "wb";      }  }  #endif  /* point at the requested memory buffer */  buf = mem->buf;  if (fio.op == FIO_READ)    size = mem->size;  if (fio.op == FIO_READ) {    /* 0xff fill unspecified memory */    for (i=0; i<size; i++) {      buf[i] = 0xff;    }  }  using_stdio = 0;  if (strcmp(filename, "-")==0) {    if (fio.op == FIO_READ) {      fname = "<stdin>";      f = stdin;    }    else {      fname = "<stdout>";      f = stdout;    }    using_stdio = 1;  }  else {    fname = filename;    f = NULL;  }  if (format == FMT_AUTO) {    if (using_stdio) {      fprintf(stderr,               "%s: can't auto detect file format when using stdin/out.\n"              "     Please specify a file format using the -f option and try again.\n",               progname);      exit(1);    }    format = fmt_autodetect(fname);    if (format < 0) {      fprintf(stderr,               "%s: can't determine file format for %s, specify explicitly\n",              progname, fname);      return -1;    }    fprintf(stderr, "%s: %s file %s auto detected as %s\n",             progname, fio.iodesc, fname, fmtstr(format));  }  if (format != FMT_IMM) {    if (!using_stdio) {      fname = filename;      f = fopen(fname, fio.mode);      if (f == NULL) {        fprintf(stderr, "%s: can't open %s file %s: %s\n",                progname, fio.iodesc, fname, strerror(errno));        return -1;      }    }  }  switch (format) {    case FMT_IHEX:      rc = fileio_ihex(&fio, fname, f, buf, size);      break;    case FMT_SREC:      rc = fileio_srec(&fio, fname, f, buf, size);      break;    case FMT_RBIN:      rc = fileio_rbin(&fio, fname, f, buf, size);      break;    case FMT_IMM:      rc = fileio_imm(&fio, fname, f, buf, size);      break;    default:      fprintf(stderr, "%s: invalid %s file format: %d\n",              progname, fio.iodesc, format);      return -1;  }  return rc;}