mirror of
https://github.com/avrdudes/avrdude.git
synced 2026-09-28 20:09:12 +03:00
Rope str_sprintf() into mmt_...() family of functions
This commit is contained in:
@@ -44,6 +44,7 @@ extern const char *pgmid; // Programmer -c string
|
||||
#define mmt_strdup(s) cfg_strdup(__func__, s)
|
||||
#define mmt_malloc(n) cfg_malloc(__func__, n)
|
||||
#define mmt_realloc(p, n) cfg_realloc(__func__, p, n)
|
||||
#define mmt_sprintf(...) str_sprintf(__VA_ARGS__)
|
||||
#define mmt_free(p) free(p)
|
||||
|
||||
int avrdude_message2(FILE *fp, int lno, const char *file, const char *func, int msgmode, int msglvl, const char *format, ...)
|
||||
|
||||
@@ -766,7 +766,7 @@ int avr_set_config_value(const PROGRAMMER *pgm, const AVRPART *p, const char *cn
|
||||
|
||||
|
||||
static char *print_num(const char *fmt, int n) {
|
||||
return str_sprintf(n<10? "%d": fmt, n);
|
||||
return mmt_sprintf(n<10? "%d": fmt, n);
|
||||
}
|
||||
|
||||
static int num_len(const char *fmt, int n) {
|
||||
@@ -835,7 +835,7 @@ void avr_mem_display(FILE *f, const AVRPART *p, const char *prefix) {
|
||||
|
||||
// Create mem desc string including alias if present
|
||||
AVRMEM_ALIAS *a = avr_find_memalias(p, m);
|
||||
char *m_desc_str = str_sprintf("%s%s%s", m->desc, a? "/": "", a? a->desc: "");
|
||||
char *m_desc_str = mmt_sprintf("%s%s%s", m->desc, a? "/": "", a? a->desc: "");
|
||||
|
||||
// Print memory table content
|
||||
if(p->prog_modes & (PM_PDI | PM_UPDI)) {
|
||||
|
||||
@@ -218,8 +218,8 @@ static void usage(void)
|
||||
char *home = getenv("HOME");
|
||||
size_t l = home? strlen(home): 0;
|
||||
char *cfg = home && str_casestarts(usr_config, home)?
|
||||
str_sprintf("~/%s", usr_config+l+(usr_config[l]=='/')):
|
||||
str_sprintf("%s", usr_config);
|
||||
mmt_sprintf("~/%s", usr_config+l+(usr_config[l]=='/')):
|
||||
mmt_sprintf("%s", usr_config);
|
||||
|
||||
msg_error(
|
||||
"Usage: %s [options]\n"
|
||||
|
||||
@@ -217,7 +217,7 @@ static char **sa_list_specs(const SERPORT *sp, int n, int i) {
|
||||
if(sa_unique_by_sea(sea, "", sp, n, i))
|
||||
Plist[Pi++] = mmt_strdup(id);
|
||||
else if(*sn && sa_unique_by_sea(sea, sn, sp, n, i))
|
||||
Plist[Pi++] = str_sprintf("%s:%s", id, sn);
|
||||
Plist[Pi++] = mmt_sprintf("%s:%s", id, sn);
|
||||
else if(!via && sa_num_matches_by_sea(sea, "", sp+i, 1))
|
||||
via = id;
|
||||
|
||||
@@ -232,11 +232,11 @@ static char **sa_list_specs(const SERPORT *sp, int n, int i) {
|
||||
|
||||
if(Pi == 0 && sp[i].vid) { // No unique serial adapter, so maybe vid:pid[:sn] works?
|
||||
if(sa_unique_by_ids(sp[i].vid, sp[i].pid, "", sp, n, i))
|
||||
Plist[Pi++] = str_sprintf("usb:%04x:%04x", sp[i].vid, sp[i].pid);
|
||||
Plist[Pi++] = mmt_sprintf("usb:%04x:%04x", sp[i].vid, sp[i].pid);
|
||||
else if(*sn && sa_unique_by_ids(sp[i].vid, sp[i].pid, sn, sp, n, i))
|
||||
Plist[Pi++] = str_sprintf("usb:%04x:%04x:%s", sp[i].vid, sp[i].pid, sn);
|
||||
Plist[Pi++] = mmt_sprintf("usb:%04x:%04x:%s", sp[i].vid, sp[i].pid, sn);
|
||||
else if(via && Pi == 0)
|
||||
Plist[Pi++] = str_sprintf("(via %s serial adapter)", via);
|
||||
Plist[Pi++] = mmt_sprintf("(via %s serial adapter)", via);
|
||||
}
|
||||
|
||||
Plist[Pi] = NULL;
|
||||
|
||||
@@ -570,7 +570,7 @@ unsigned long long int str_ull(const char *str, char **endptr, int base) {
|
||||
*/
|
||||
|
||||
#define Return(...) do { \
|
||||
sd->errstr = str_sprintf(__VA_ARGS__); \
|
||||
sd->errstr = mmt_sprintf(__VA_ARGS__); \
|
||||
sd->type = 0; \
|
||||
mmt_free(str); \
|
||||
return sd; \
|
||||
@@ -579,7 +579,7 @@ unsigned long long int str_ull(const char *str, char **endptr, int base) {
|
||||
#define Warning(...) do { \
|
||||
if(sd->warnstr) \
|
||||
mmt_free(sd->warnstr); \
|
||||
sd->warnstr = str_sprintf(__VA_ARGS__); \
|
||||
sd->warnstr = mmt_sprintf(__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define sizeforsigned(ll) ( \
|
||||
|
||||
@@ -133,9 +133,9 @@ void free_update(UPDATE *u) {
|
||||
|
||||
char *update_str(const UPDATE *upd) {
|
||||
if(upd->cmdline)
|
||||
return str_sprintf("-%c %s",
|
||||
return mmt_sprintf("-%c %s",
|
||||
str_eq("interactive terminal", upd->cmdline)? 't': 'T', upd->cmdline);
|
||||
return str_sprintf("-U %s:%c:%s:%c",
|
||||
return mmt_sprintf("-U %s:%c:%s:%c",
|
||||
upd->memstr,
|
||||
upd->op == DEVICE_READ? 'r': upd->op == DEVICE_WRITE? 'w': 'v',
|
||||
upd->filename,
|
||||
|
||||
Reference in New Issue
Block a user