Skip to content

Commit

Permalink
Silence compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanrueger committed Aug 23, 2024
1 parent 79f85d0 commit 43fc4ff
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ static int is_jumpable(int address) {

// Format output for a label list r referenced by mnemonic m
static void output_references(const char *m, char *r) {
disasm_out("; %c%s from ", toupper(*m), m + 1);
disasm_out("; %c%s from ", toupper(*m & 0xff), m + 1);
for(char *s = r;;) {
char *c = strchr(s + 1, ',');

Expand Down Expand Up @@ -513,7 +513,7 @@ static void lineout(const char *code, const char *comment,
const char *mnestr = avr_opcodes[mne].opcode;

disasm_out("%-*s ; %s\n", commentcol(), str_ccprintf("%s:", name),
str_ccprintf("%c%s from %s", toupper(*mnestr), mnestr + 1, reflist));
str_ccprintf("%c%s from %s", toupper(*mnestr & 0xff), mnestr + 1, reflist));
} else {
output_references(avr_opcodes[mne].opcode, reflist);
if(comment)
Expand Down
12 changes: 6 additions & 6 deletions src/strutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ char *str_sprintf(const char *fmt, ...) {

// Compute size
va_start(ap, fmt);
size = vsnprintf(NULL, size, fmt, ap);
size = vsnprintf(NULL, 0, fmt, ap);
va_end(ap);

if(size < 0)
Expand All @@ -274,7 +274,7 @@ const char *str_ccprintf(const char *fmt, ...) {

// Compute size
va_start(ap, fmt);
size = vsnprintf(NULL, size, fmt, ap);
size = vsnprintf(NULL, 0, fmt, ap);
va_end(ap);

if(size < 0)
Expand Down Expand Up @@ -827,7 +827,7 @@ Str2data *str_todata(const char *s, int type, const AVRPART *part, const char *m

// Parse suffixes: ULL, LL, UL, L ... UHH, HH
for(char *p = end_ptr; *p; p++) {
switch(toupper(*p)) {
switch(toupper(*p & 0xff)) {
case 'U':
nu++;
break;
Expand All @@ -847,7 +847,7 @@ Str2data *str_todata(const char *s, int type, const AVRPART *part, const char *m

if(nx == 0 && nu < 2 && nl < 3 && nh < 3 && ns < 2) { // Could be valid integer suffix
// If U, then must be at start or end
if(nu == 0 || toupper(*end_ptr) == 'U' || toupper(str[arglen - 1]) == 'U') {
if(nu == 0 || toupper(*end_ptr & 0xff) == 'U' || toupper(str[arglen - 1] & 0xff) == 'U') {
bool is_hex, is_bin;
int ndigits;

Expand Down Expand Up @@ -940,7 +940,7 @@ Str2data *str_todata(const char *s, int type, const AVRPART *part, const char *m

if(type & STR_DOUBLE) { // Try double next, must have D suffix
sd->d = strtod(str, &end_ptr);
if(end_ptr != str && toupper(*end_ptr) == 'D' && end_ptr[1] == 0) {
if(end_ptr != str && toupper(*end_ptr & 0xff) == 'D' && end_ptr[1] == 0) {
sd->size = 8;
sd->type = STR_DOUBLE;
mmt_free(str);
Expand All @@ -951,7 +951,7 @@ Str2data *str_todata(const char *s, int type, const AVRPART *part, const char *m
if(type & STR_FLOAT) { // Try float next
sd->size = 0;
sd->f = strtof(str, &end_ptr);
if(end_ptr != str && toupper(*end_ptr) == 'F' && end_ptr[1] == 0)
if(end_ptr != str && toupper(*end_ptr & 0xff) == 'F' && end_ptr[1] == 0)
sd->size = 4;
// Do not accept valid mantissa-only floats that are integer rejects (eg, 078 or ULL overflows)
if(end_ptr != str && *end_ptr == 0 && !is_mantissa_only(str))
Expand Down
4 changes: 2 additions & 2 deletions src/term.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ static unsigned char *readbuf(const PROGRAMMER *pgm, const AVRPART *p, int argc,
if(mi < 0 || mi >= Nmems)
mi = 0;

const char *cmd = tolower(**argv) == 'r'? "read": str_casestarts(*argv, "di")? "disasm": "dump";
const char *cmd = tolower(**argv & 0xff) == 'r'? "read": str_casestarts(*argv, "di")? "disasm": "dump";
int is_disasm = cmd[1] == 'i';
int default_len = is_disasm? 32: 256;

Expand Down Expand Up @@ -1603,7 +1603,7 @@ static void printproperty(Cnfg *cc, int ii, Cfg_opts o) {
if(o.verb > 1)
term_out("# Mask 0x%02x of %s: %.*s\n", cc->t[ii].mask, cc[ii].memstr, cclen, ccom);
else if(*cc[ii].t->ccomment)
term_out("# %c%.*s\n", toupper(*cc[ii].t->ccomment), cclen - 1, cc[ii].t->ccomment + 1);
term_out("# %c%.*s\n", toupper(*cc[ii].t->ccomment & 0xff), cclen - 1, cc[ii].t->ccomment + 1);
else
term_out("# %s\n", cc[ii].t->name);
}
Expand Down
7 changes: 4 additions & 3 deletions src/xbee.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ static void xbeeStatsAdd(struct XBeeStaticticsSummary *summary, struct timeval c

static void xbeeStatsSummarise(struct XBeeStaticticsSummary const *summary) {
pmsg_notice(" Minimum response time: %lu.%06lu\n",
summary->minimum.tv_sec, (unsigned long) summary->minimum.tv_usec);
(unsigned long) summary->minimum.tv_sec, (unsigned long) summary->minimum.tv_usec);
pmsg_notice(" Maximum response time: %lu.%06lu\n",
summary->maximum.tv_sec, (unsigned long) summary->maximum.tv_usec);
(unsigned long) summary->maximum.tv_sec, (unsigned long) summary->maximum.tv_usec);

struct timeval average;

Expand All @@ -247,7 +247,8 @@ static void xbeeStatsSummarise(struct XBeeStaticticsSummary const *summary) {
average.tv_sec += usecs/1000000;
average.tv_usec = usecs%1000000;

pmsg_notice(" Average response time: %lu.%06lu\n", average.tv_sec, (unsigned long) average.tv_usec);
pmsg_notice(" Average response time: %lu.%06lu\n", (unsigned long) average.tv_sec,
(unsigned long) average.tv_usec);
}

static void XBeeBootSessionInit(struct XBeeBootSession *xbs) {
Expand Down

0 comments on commit 43fc4ff

Please sign in to comment.