Fix formatting warnings for sdb_fmt() ##refactor

This commit is contained in:
Anton Kochkov 2020-11-12 12:54:09 +08:00
parent 739feec0e0
commit 14f82ee301
10 changed files with 33 additions and 31 deletions

View File

@ -330,9 +330,9 @@ static bool parse_segments(struct MACH0_(obj_t) *bin, ut64 off) {
bin->segs[j].flags = r_read_ble32 (&segcom[i], bin->big_endian);
#if R_BIN_MACH064
sdb_num_set (bin->kv, sdb_fmt ("mach0_segment64_%d.offset", j), off, 0);
sdb_num_set (bin->kv, sdb_fmt ("mach0_segment64_%zu.offset", j), off, 0);
#else
sdb_num_set (bin->kv, sdb_fmt ("mach0_segment_%d.offset", j), off, 0);
sdb_num_set (bin->kv, sdb_fmt ("mach0_segment_%zu.offset", j), off, 0);
#endif
sdb_num_set (bin->kv, "mach0_segments.count", 0, 0);
@ -393,11 +393,14 @@ static bool parse_segments(struct MACH0_(obj_t) *bin, ut64 off) {
memcpy (&bin->sects[k].segname, &sec[i], 16);
i += 16;
sdb_num_set (bin->kv, sdb_fmt ("mach0_section_%.16s_%.16s.offset", &bin->sects[k].segname, &bin->sects[k].sectname), offset, 0);
sdb_num_set (bin->kv, sdb_fmt ("mach0_section_%.16s_%.16s.offset",
bin->sects[k].segname, bin->sects[k].sectname), offset, 0);
#if R_BIN_MACH064
sdb_set (bin->kv, sdb_fmt ("mach0_section_%.16s_%.16s.format", &bin->sects[k].segname, &bin->sects[k].sectname), "mach0_section64", 0);
sdb_set (bin->kv, sdb_fmt ("mach0_section_%.16s_%.16s.format",
bin->sects[k].segname, bin->sects[k].sectname), "mach0_section64", 0);
#else
sdb_set (bin->kv, sdb_fmt ("mach0_section_%.16s_%.16s.format", &bin->sects[k].segname, &bin->sects[k].sectname), "mach0_section", 0);
sdb_set (bin->kv, sdb_fmt ("mach0_section_%.16s_%.16s.format",
bin->sects[k].segname, bin->sects[k].sectname), "mach0_section", 0);
#endif
#if R_BIN_MACH064

View File

@ -391,7 +391,7 @@ static bool r_bin_mdmp_init_directory_entry(struct r_bin_mdmp_obj *obj, struct m
sdb_num_set (obj->kv, "mdmp_thread_list.offset",
entry->location.rva, 0);
sdb_set (obj->kv, "mdmp_thread_list.format",
sdb_fmt ("d[%i]? "
sdb_fmt ("d[%d]? "
"NumberOfThreads (mdmp_thread)Threads",
thread_list.number_of_threads),
0);
@ -414,10 +414,9 @@ static bool r_bin_mdmp_init_directory_entry(struct r_bin_mdmp_obj *obj, struct m
sdb_num_set (obj->kv, "mdmp_module_list.offset",
entry->location.rva, 0);
sdb_set (obj->kv, "mdmp_module_list.format",
sdb_fmt ("d[%i]? "
sdb_fmt ("d[%d]? "
"NumberOfModule (mdmp_module)Modules",
module_list.number_of_modules,
0),
module_list.number_of_modules),
0);
offset = entry->location.rva + sizeof (module_list);
@ -443,11 +442,10 @@ static bool r_bin_mdmp_init_directory_entry(struct r_bin_mdmp_obj *obj, struct m
sdb_num_set (obj->kv, "mdmp_memory_list.offset",
entry->location.rva, 0);
sdb_set (obj->kv, "mdmp_memory_list.format",
sdb_fmt ("d[%i]? "
sdb_fmt ("d[%d]? "
"NumberOfMemoryRanges "
"(mdmp_memory_descriptor)MemoryRanges ",
memory_list.number_of_memory_ranges,
0),
memory_list.number_of_memory_ranges),
0);
offset = entry->location.rva + sizeof (memory_list);
@ -528,9 +526,9 @@ static bool r_bin_mdmp_init_directory_entry(struct r_bin_mdmp_obj *obj, struct m
sdb_num_set (obj->kv, "mdmp_thread_ex_list.offset",
entry->location.rva, 0);
sdb_set (obj->kv, "mdmp_thread_ex_list.format",
sdb_fmt ("d[%i]? NumberOfThreads "
sdb_fmt ("d[%d]? NumberOfThreads "
"(mdmp_thread_ex)Threads",
thread_ex_list.number_of_threads, 0),
thread_ex_list.number_of_threads),
0);
offset = entry->location.rva + sizeof (thread_ex_list);
@ -556,7 +554,7 @@ static bool r_bin_mdmp_init_directory_entry(struct r_bin_mdmp_obj *obj, struct m
sdb_num_set (obj->kv, "mdmp_memory64_list.offset",
entry->location.rva, 0);
sdb_set (obj->kv, "mdmp_memory64_list.format",
sdb_fmt ("qq[%i]? NumberOfMemoryRanges "
sdb_fmt ("qq[%"PFMT64d"]? NumberOfMemoryRanges "
"BaseRva "
"(mdmp_memory_descriptor64)MemoryRanges",
memory64_list.number_of_memory_ranges),
@ -711,7 +709,7 @@ static bool r_bin_mdmp_init_directory_entry(struct r_bin_mdmp_obj *obj, struct m
sdb_num_set (obj->kv, "mdmp_memory_info_list.offset",
entry->location.rva, 0);
sdb_set (obj->kv, "mdmp_memory_info_list.format",
sdb_fmt ("ddq[%i]? SizeOfHeader SizeOfEntry "
sdb_fmt ("ddq[%"PFMT64d"]? SizeOfHeader SizeOfEntry "
"NumberOfEntries (mdmp_memory_info)MemoryInfo",
memory_info_list.number_of_entries),
0);
@ -826,7 +824,7 @@ static bool r_bin_mdmp_init_directory_entry(struct r_bin_mdmp_obj *obj, struct m
/* Silently ignore reserved streams */
break;
default:
eprintf ("[WARN] Invalid or unsupported enumeration encountered %i\n", entry->stream_type);
eprintf ("[WARN] Invalid or unsupported enumeration encountered %d\n", entry->stream_type);
break;
}
return true;

View File

@ -1089,9 +1089,9 @@ static void get_class_ro_t(mach0_ut p, RBinFile *bf, ut32 *is_meta_class, RBinCl
sdb_num_set (bin->kv, sdb_fmt ("objc_class_%s.offset", klass->name), s, 0);
}
#ifdef R_BIN_MACH064
sdb_set (bin->kv, sdb_fmt ("objc_class.format", 0), "lllll isa super cache vtable data", 0);
sdb_set (bin->kv, sdb_fmt ("objc_class.format"), "lllll isa super cache vtable data", 0);
#else
sdb_set (bin->kv, sdb_fmt ("objc_class.format", 0), "xxxxx isa super cache vtable data", 0);
sdb_set (bin->kv, sdb_fmt ("objc_class.format"), "xxxxx isa super cache vtable data", 0);
#endif
if (cro.baseMethods > 0) {

View File

@ -283,7 +283,7 @@ static void r_dyld_locsym_entries_by_offset(RDyldCache *cache, RList *symbols, H
for (j = 0; j != entry->nlistCount; j++) {
struct MACH0_(nlist) *nlist = &locsym->nlists[j + entry->nlistStartIndex];
bool found;
const char *key = sdb_fmt ("%"PFMT64x, nlist->n_value);
const char *key = sdb_fmt ("%"PFMT64x, (ut64)nlist->n_value);
ht_pp_find (hash, key, &found);
if (found) {
continue;

View File

@ -1118,21 +1118,21 @@ static RBinInfo* info(RBinFile *bf) {
if (!(str = Elf_(r_bin_elf_get_head_flag) (obj))) {
free (ret);
return NULL;
}
}
ret->head_flag = str;
if (!(str = Elf_(r_bin_elf_get_arch) (obj))) {
free (ret);
return NULL;
}
ret->arch = str;
if ((str = Elf_(r_bin_elf_get_cpu) (obj))) {
ret->cpu = str;
ret->cpu = str;
}
if ((str = Elf_(r_bin_elf_get_abi) (obj))) {
ret->features = str;
}
ret->rclass = strdup ("elf");
ret->bits = Elf_(r_bin_elf_get_bits) (obj);
if (!strcmp (ret->arch, "avr")) {
@ -1164,7 +1164,7 @@ static RList* fields(RBinFile *bf) {
}
#define ROW(nam, siz, val, fmt) \
r_list_append (ret, r_bin_field_new (addr, addr, siz, nam, sdb_fmt ("0x%08x", val), fmt, false));
r_list_append (ret, r_bin_field_new (addr, addr, siz, nam, sdb_fmt ("0x%08"PFMT64x, (ut64)val), fmt, false));
if (r_buf_size (bf->buf) < sizeof (Elf_ (Ehdr))) {
return ret;
}

View File

@ -66,7 +66,7 @@ static RBinInfo *info(RBinFile *bf) {
// FIXME: Needed to fix issue with PLT resolving. Can we get away with setting this for all children bins?
ret->has_lit = true;
sdb_set (bf->sdb, "mdmp.flags", sdb_fmt ("0x%08x", obj->hdr->flags), 0);
sdb_set (bf->sdb, "mdmp.flags", sdb_fmt ("0x%08"PFMT64x, obj->hdr->flags), 0);
sdb_num_set (bf->sdb, "mdmp.streams", obj->hdr->number_of_streams, 0);
if (obj->streams.system_info) {
@ -338,7 +338,7 @@ static RList *mem(RBinFile *bf) {
a_protect = mem_info->allocation_protect;
}
location = &(module->memory);
ptr->name = strdup (sdb_fmt ("paddr=0x%08"PFMT64x" state=0x%08"PFMT64x
ptr->name = strdup (sdb_fmt ("paddr=0x%08"PFMT32x" state=0x%08"PFMT64x
" type=0x%08"PFMT64x" allocation_protect=0x%08"PFMT64x" Memory_Section",
location->rva, state, type, a_protect));

View File

@ -34,7 +34,8 @@ static RList *fields(RBinFile *bf) {
}
#define ROWL(nam,siz,val,fmt) \
r_list_append (ret, r_bin_field_new (addr, addr, siz, nam, sdb_fmt ("0x%08x", val), fmt, false));
r_list_append (ret, r_bin_field_new (addr, addr, siz, nam, \
sdb_fmt ("0x%08"PFMT64x, (ut64)val), fmt, false));
struct PE_(r_bin_pe_obj_t) * bin = bf->o->bin_obj;
ut64 addr = bin->rich_header_offset ? bin->rich_header_offset : 128;

View File

@ -431,7 +431,7 @@ static bool __tableItemCallback(RFlagItem *flag, void *user) {
RTable *t = ftd->t;
const char *spaceName = (flag->space && flag->space->name)? flag->space->name: "";
const char *addr = sdb_fmt ("0x%08"PFMT64x, flag->offset);
r_table_add_row (t, addr, sdb_fmt ("%d", flag->size), spaceName, flag->name, NULL);
r_table_add_row (t, addr, sdb_fmt ("%"PFMT64d, flag->size), spaceName, flag->name, NULL);
}
return true;
}

View File

@ -247,7 +247,7 @@ R_API int r_core_pseudo_code(RCore *core, const char *input) {
r_cons_push ();
bool html = r_config_get_i (core->config, "scr.html");
r_config_set_i (core->config, "scr.html", 0);
char *code = r_core_cmd_str (core, sdb_fmt ("pD %d @ 0x%08"PFMT64x"\n", bb->size, bb->addr));
char *code = r_core_cmd_str (core, sdb_fmt ("pD %"PFMT64d" @ 0x%08"PFMT64x"\n", bb->size, bb->addr));
r_cons_pop ();
r_config_set_i (core->config, "scr.html", html);
if (indent * I_TAB + 2 >= sizeof (indentstr)) {

View File

@ -358,7 +358,7 @@ static void serialize_checkpoints(Sdb *db, RVector *checkpoints) {
pj_end (j);
pj_end (j);
sdb_set (db, sdb_fmt ("0x%"PFMT64x, chkpt->cnum), pj_string (j), 0);
sdb_set (db, sdb_fmt ("0x%x", chkpt->cnum), pj_string (j), 0);
pj_free (j);
}
}