Change array for copy mem->desc to const char * in term.c

This commit is contained in:
Stefan Rueger 2022-08-15 14:25:58 +01:00
parent a4bfa8247d
commit e332ecf0b4
No known key found for this signature in database
GPG Key ID: B0B4F1FD86B1EC55
2 changed files with 3 additions and 5 deletions

View File

@ -283,7 +283,6 @@ typedef struct avrpart {
int lineno; /* config file line number */ int lineno; /* config file line number */
} AVRPART; } AVRPART;
#define AVR_MEMDESCLEN 64
typedef struct avrmem { typedef struct avrmem {
const char *desc; /* memory description ("flash", "eeprom", etc) */ const char *desc; /* memory description ("flash", "eeprom", etc) */
LISTID comments; // Used by developer options -p*/[ASsr...] LISTID comments; // Used by developer options -p*/[ASsr...]

View File

@ -252,7 +252,7 @@ static int cmd_dump(PROGRAMMER * pgm, struct avrpart * p,
} }
enum { read_size = 256 }; enum { read_size = 256 };
static char prevmem[AVR_MEMDESCLEN] = {0x00}; static const char *prevmem = "";
char * memtype = argv[1]; char * memtype = argv[1];
AVRMEM * mem = avr_locate_mem(p, memtype); AVRMEM * mem = avr_locate_mem(p, memtype);
if (mem == NULL) { if (mem == NULL) {
@ -282,7 +282,7 @@ static int cmd_dump(PROGRAMMER * pgm, struct avrpart * p,
// Get no. bytes to read if present // Get no. bytes to read if present
static int len = read_size; static int len = read_size;
if (argc >= 3) { if (argc >= 3) {
memset(prevmem, 0x00, sizeof(prevmem)); prevmem = cache_string("");
if (strcmp(argv[argc - 1], "...") == 0) { if (strcmp(argv[argc - 1], "...") == 0) {
if (argc == 3) if (argc == 3)
addr = 0; addr = 0;
@ -303,8 +303,7 @@ static int cmd_dump(PROGRAMMER * pgm, struct avrpart * p,
if (strncmp(prevmem, memtype, strlen(memtype)) != 0) { if (strncmp(prevmem, memtype, strlen(memtype)) != 0) {
addr = 0; addr = 0;
len = read_size; len = read_size;
strncpy(prevmem, memtype, sizeof(prevmem) - 1); prevmem = cache_string(mem->desc);
prevmem[sizeof(prevmem) - 1] = 0;
} }
if (addr >= maxsize) if (addr >= maxsize)
addr = 0; // Wrap around addr = 0; // Wrap around