Skip to content

Commit

Permalink
Suppress overzealous compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanrueger committed Jul 14, 2024
1 parent 43c915a commit 99bd83c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/config_gram.y
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ part_def :
if(mem_is_signature(m))
m->type &= ~MEM_IN_SIGROW;
}
if(fileio_mem_offset(current_part, m) == -1U)
if(fileio_mem_offset(current_part, m) == ~0U)
yywarning("revise fileio_mem_offset(), avrdude.conf entry or memory type assignment");
}

Expand Down
12 changes: 6 additions & 6 deletions src/fileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,22 +232,22 @@ unsigned fileio_mem_offset(const AVRPART *p, const AVRMEM *mem) {
mem_is_sib(mem)? MBASE(SIGROW) + 0x1000: // Arbitrary 0x1000 offset in signature section for sib
mem_is_userrow(mem)? MBASE(USERROW):
mem_is_bootrow(mem)? MBASE(BOOTROW):
-1U;
~0U;

if(location == -1U)
if(location == ~0U)
pmsg_error("unable to locate %s's %s in multi-memory address space\n", p->desc, mem->desc);
else if(location >= ANY_MEM_SIZE || location + mem->size > ANY_MEM_SIZE) { // Overflow
pmsg_error("%s's %s location [0x%06x, 0x%06x] outside flat address space [0, 0x%06x]\n",
p->desc, mem->desc, location, location + mem->size-1, ANY_MEM_SIZE-1);
location = -1U;
location = ~0U;
} else if(location <= MEND(FLASH) && location + mem->size > MEND(FLASH)+1) {
pmsg_error("%s's %s location [0x%06x, 0x%06x] straddles flash section boundary 0x%06x\n",
p->desc, mem->desc, location, location + mem->size-1, MEND(FLASH)+1);
location = -1U;
location = ~0U;
} else if(location > MEND(FLASH) && location/0x10000 != (location + mem->size-1)/0x10000) {
pmsg_error("%s's %s memory location [0x%06x, 0x%06x] straddles memory section boundary 0x%02x0000\n",
p->desc, mem->desc, location, location + mem->size-1, 1+location/0x10000);
location = -1U;
location = ~0U;
}

return location;
Expand Down Expand Up @@ -465,7 +465,7 @@ static int any2mem(const AVRPART *p, const AVRMEM *mem, const Segment *segp,
// Compute location for multi-memory file input
unsigned location = maxsize > MEND(FLASH)+1? fileio_mem_offset(p, mem): 0;

if(location == -1U)
if(location == ~0U)
return -1;

unsigned ret = 0;
Expand Down
5 changes: 2 additions & 3 deletions src/strutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -1331,9 +1331,8 @@ size_t str_weighted_damerau_levenshtein(const char *s1, const char *s2) {

// Puts a comma-separated list of matching MCU names into array p with n chars space
int str_mcunames_signature(const unsigned char *sigs, int pm, char *p, size_t n) {
int matching = 0, k;
const int N = 100;
const char *matches[N];
const char *matches[100];
int matching = 0, k, N = sizeof matches/sizeof*matches;

if(!pm || (pm & PM_ALL) == PM_ALL) // Look up uP table when unrestricted by prog modes
for(size_t i=0; i < sizeof uP_table/sizeof *uP_table; i++)
Expand Down
2 changes: 1 addition & 1 deletion src/update.c
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat
continue;
}
unsigned off = fileio_mem_offset(p, m);
if(off == -1U) {
if(off == ~0U) {
pmsg_warning("cannot map %s to flat address space, skipping ...\n", m_name);
rwvproblem = 1;
continue;
Expand Down

0 comments on commit 99bd83c

Please sign in to comment.