Rename variable for clarity in avrcache.c

This commit is contained in:
Stefan Rueger 2022-10-12 15:55:22 +01:00
parent 8a3864d263
commit 714c2fbf95
No known key found for this signature in database
GPG Key ID: B0B4F1FD86B1EC55
1 changed files with 11 additions and 11 deletions

View File

@ -137,21 +137,21 @@ int avr_read_page_default(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM
if(!avr_has_paged_access(pgm, mem) || addr < 0 || addr >= mem->size) if(!avr_has_paged_access(pgm, mem) || addr < 0 || addr >= mem->size)
return LIBAVRDUDE_GENERAL_FAILURE; return LIBAVRDUDE_GENERAL_FAILURE;
int rc, pgsize = mem->page_size, off = addr & ~(pgsize-1); int rc, pgsize = mem->page_size, base = addr & ~(pgsize-1);
unsigned char *pagecopy = cfg_malloc("avr_read_page_default()", pgsize); unsigned char *pagecopy = cfg_malloc("avr_read_page_default()", pgsize);
if(pgsize == 1) if(pgsize == 1)
return pgm->read_byte(pgm, p, mem, addr, buf); return pgm->read_byte(pgm, p, mem, addr, buf);
memcpy(pagecopy, mem->buf + off, pgsize); memcpy(pagecopy, mem->buf + base, pgsize);
if((rc = pgm->paged_load(pgm, p, mem, pgsize, off, pgsize)) >= 0) if((rc = pgm->paged_load(pgm, p, mem, pgsize, base, pgsize)) >= 0)
memcpy(buf, mem->buf + off, pgsize); memcpy(buf, mem->buf + base, pgsize);
memcpy(mem->buf + off, pagecopy, pgsize); memcpy(mem->buf + base, pagecopy, pgsize);
if(rc < 0) { if(rc < 0) {
rc = LIBAVRDUDE_SUCCESS; rc = LIBAVRDUDE_SUCCESS;
for(int i=0; i<pgsize; i++) { for(int i=0; i<pgsize; i++) {
if(pgm->read_byte(pgm, p, mem, off+i, pagecopy+i) < 0) { if(pgm->read_byte(pgm, p, mem, base+i, pagecopy+i) < 0) {
rc = LIBAVRDUDE_GENERAL_FAILURE; rc = LIBAVRDUDE_GENERAL_FAILURE;
break; break;
} }
@ -175,16 +175,16 @@ int avr_write_page_default(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM
if(!avr_has_paged_access(pgm, mem) || addr < 0 || addr >= mem->size) if(!avr_has_paged_access(pgm, mem) || addr < 0 || addr >= mem->size)
return LIBAVRDUDE_GENERAL_FAILURE; return LIBAVRDUDE_GENERAL_FAILURE;
int rc, pgsize = mem->page_size, off = addr & ~(pgsize-1); int rc, pgsize = mem->page_size, base = addr & ~(pgsize-1);
unsigned char *pagecopy = cfg_malloc("avr_write_page_default()", pgsize); unsigned char *pagecopy = cfg_malloc("avr_write_page_default()", pgsize);
if(pgsize == 1) if(pgsize == 1)
return pgm->write_byte(pgm, p, mem, addr, *data); return pgm->write_byte(pgm, p, mem, addr, *data);
memcpy(pagecopy, mem->buf + off, pgsize); memcpy(pagecopy, mem->buf + base, pgsize);
memcpy(mem->buf + off, data, pgsize); memcpy(mem->buf + base, data, pgsize);
rc = pgm->paged_write(pgm, p, mem, pgsize, off, pgsize); rc = pgm->paged_write(pgm, p, mem, pgsize, base, pgsize);
memcpy(mem->buf + off, pagecopy, pgsize); memcpy(mem->buf + base, pagecopy, pgsize);
free(pagecopy); free(pagecopy);
return rc; return rc;