From b30a4ea80be42663ca96ddf8bb90415c234469de Mon Sep 17 00:00:00 2001 From: pancake Date: Tue, 1 Feb 2022 11:07:46 +0100 Subject: [PATCH] Remove all the uses of %z as its not supported on Windows --- libr/bin/format/mach0/mach0.c | 14 +++++++------- libr/bin/p/bin_coff.c | 2 +- libr/bin/p/bin_dex.c | 5 ++--- libr/core/cconfig.c | 2 +- libr/core/p/core_java.c | 8 ++++---- libr/io/p/io_r2k_linux.c | 9 ++++----- libr/magic/funcs.c | 2 +- libr/util/print.c | 2 +- 8 files changed, 21 insertions(+), 23 deletions(-) diff --git a/libr/bin/format/mach0/mach0.c b/libr/bin/format/mach0/mach0.c index 5900d0d192..f40a6c5294 100644 --- a/libr/bin/format/mach0/mach0.c +++ b/libr/bin/format/mach0/mach0.c @@ -340,9 +340,9 @@ static bool parse_segments(struct MACH0_(obj_t) *bin, ut64 off) { char *segment_flagname = NULL; #if R_BIN_MACH064 - segment_flagname = r_str_newf ("mach0_segment64_%zu.offset", j); + segment_flagname = r_str_newf ("mach0_segment64_%u.offset", (ut32)j); #else - segment_flagname = r_str_newf ("mach0_segment_%zu.offset", j); + segment_flagname = r_str_newf ("mach0_segment_%u.offset", (ut32)j); #endif sdb_num_set (bin->kv, segment_flagname, off, 0); free (segment_flagname); @@ -2297,7 +2297,7 @@ RList *MACH0_(get_segments)(RBinFile *bf) { } } char *section_name = r_str_ndup (bin->sects[i].sectname, 16); - char *segment_name = r_str_newf ("%zu.%s", i, bin->segs[segment_index].segname); + char *segment_name = r_str_newf ("%u.%s", (ut32)i, bin->segs[segment_index].segname); s->name = r_str_newf ("%s.%s", segment_name, section_name); s->is_data = __isDataSection (s); if (strstr (section_name, "interpos") || strstr (section_name, "__mod_")) { @@ -2764,7 +2764,7 @@ const RList *MACH0_(get_symbols_list)(struct MACH0_(obj_t) *bin) { } } } else { - sym->name = r_str_newf ("unk%zu", i); + sym->name = r_str_newf ("unk%u", (ut32)i); } if (!inSymtab (hash, sym->name, sym->vaddr)) { r_list_append (list, sym); @@ -2787,7 +2787,7 @@ const RList *MACH0_(get_symbols_list)(struct MACH0_(obj_t) *bin) { sym->paddr = symbol.offset; sym->name = symbol.name; if (!sym->name) { - sym->name = r_str_newf ("unk%zu", i); + sym->name = r_str_newf ("unk%u", (ut32)i); } sym->is_imported = symbol.is_imported; r_list_append (list, sym); @@ -2829,7 +2829,7 @@ const RList *MACH0_(get_symbols_list)(struct MACH0_(obj_t) *bin) { } } } else { - sym->name = r_str_newf ("unk%zu", i); + sym->name = r_str_newf ("unk%u", (ut32)i); } r_list_append (list, sym); j++; @@ -4471,7 +4471,7 @@ RList *MACH0_(mach_fields)(RBinFile *bf) { char section_flagname[128]; for (i = 0; i < nsects && (addr + off) < length && off < lcSize; i++) { const char *sname = is64? "mach0_section64": "mach0_section"; - snprintf (section_flagname, sizeof (section_flagname), "section_%zu", j++); + snprintf (section_flagname, sizeof (section_flagname), "section_%u", (ut32)j++); RBinField *f = r_bin_field_new (addr + off, addr + off, 1, section_flagname, sname, sname, true); r_list_append (ret, f); off += is64? 80: 68; diff --git a/libr/bin/p/bin_coff.c b/libr/bin/p/bin_coff.c index 05cfd2ed87..448d4aec39 100644 --- a/libr/bin/p/bin_coff.c +++ b/libr/bin/p/bin_coff.c @@ -189,7 +189,7 @@ static RList *sections(RBinFile *bf) { free (tmp); return ret; } - ptr->name = r_str_newf ("%s-%zu", tmp, i); + ptr->name = r_str_newf ("%s-%u", tmp, (unsigned int)i); free (tmp); if (strstr (ptr->name, "data")) { ptr->is_data = true; diff --git a/libr/bin/p/bin_dex.c b/libr/bin/p/bin_dex.c index 3b0baed7df..0df1f9d853 100644 --- a/libr/bin/p/bin_dex.c +++ b/libr/bin/p/bin_dex.c @@ -1099,8 +1099,7 @@ static void parse_dex_class_fields(RBinFile *bf, RBinDexClass *c, RBinClass *cls if (dexdump) { char *accessStr = createAccessFlagStr ( accessFlags, kAccessForField); - bin->cb_printf (" #%zu : (in %s;)\n", i, - cls->name); + bin->cb_printf (" #%u : (in %s;)\n", (unsigned int)i, cls->name); bin->cb_printf (" name : '%s'\n", fieldName); bin->cb_printf (" type : '%s'\n", type_str); bin->cb_printf (" access : 0x%04x (%s)\n", @@ -1652,7 +1651,7 @@ static bool dex_loadcode(RBinFile *bf) { for (i = 0; i < dex->header.class_size; i++) { struct dex_class_t *c = &dex->classes[i]; if (dexdump) { - cb_printf ("Class #%zu -\n", i); + cb_printf ("Class #%u -\n", (unsigned int)i); } parse_class (bf, c, i, methods, &sym_count); } diff --git a/libr/core/cconfig.c b/libr/core/cconfig.c index d0c1f01a18..2cad0bab25 100644 --- a/libr/core/cconfig.c +++ b/libr/core/cconfig.c @@ -3666,7 +3666,7 @@ R_API int r_core_config_init(RCore *core) { update_cfgcharsets_options (core, n); SETBPREF ("cfg.r2wars", "false", "Enable some tweaks for the r2wars game"); SETBPREF ("cfg.plugins", "true", "Load plugins at startup"); - SETCB ("time.fmt", "%Y-%m-%d %H:%M:%S %z", &cb_cfgdatefmt, "Date format (%Y-%m-%d %H:%M:%S %z)"); + SETCB ("time.fmt", "%Y-%m-%d %H:%M:%S %u", &cb_cfgdatefmt, "Date format (%Y-%m-%d %H:%M:%S %u)"); SETICB ("time.zone", 0, &cb_timezone, "Time zone, in hours relative to GMT: +2, -1,.."); SETCB ("cfg.corelog", "false", &cb_cfgcorelog, "Log changes using the T api needed for realtime syncing"); SETBPREF ("cfg.newtab", "false", "Show descriptions in command completion"); diff --git a/libr/core/p/core_java.c b/libr/core/p/core_java.c index e4e0fe4a4b..044f27f92e 100644 --- a/libr/core/p/core_java.c +++ b/libr/core/p/core_java.c @@ -352,17 +352,17 @@ static const char *r_cmd_java_strtok(const char *str1, const char b, size_t len) if (len == (size_t)-1) { len = strlen (str1); } - IFDBG r_cons_printf ("Looking for char (%c) in (%s) up to %zu\n", b, p, len); + IFDBG r_cons_printf ("Looking for char (%c) in (%s) up to %u\n", b, p, (unsigned int)len); for (; i < len; i++, p++) { if (*p == b) { - IFDBG r_cons_printf ("Found? for char (%c) @ %zu: (%s)\n", b, i, p); + IFDBG r_cons_printf ("Found? for char (%c) @ %u: (%s)\n", b, (unsigned int)i, p); break; } } if (i == len) { p = NULL; } - IFDBG r_cons_printf ("Found? for char (%c) @ %zu: (%s)\n", b, len, p); + IFDBG r_cons_printf ("Found? for char (%c) @ %u: (%s)\n", b, (unsigned int)len, p); return p; } @@ -475,7 +475,7 @@ static RList *cpfind_str(RBinJavaObj *obj, const char *cmd) { if (!cmd) { return r_list_new (); } - IFDBG r_cons_printf ("Looking for str: %s (%zu)\n", cmd, strlen (cmd)); + IFDBG r_cons_printf ("Looking for str: %s (%u)\n", cmd, (unsigned int)strlen (cmd)); return r_bin_java_find_cp_const_by_val (obj, (const ut8 *)cmd, strlen (cmd), R_BIN_JAVA_CP_UTF8); } diff --git a/libr/io/p/io_r2k_linux.c b/libr/io/p/io_r2k_linux.c index dd29d3302e..4d89cdf341 100644 --- a/libr/io/p/io_r2k_linux.c +++ b/libr/io/p/io_r2k_linux.c @@ -64,7 +64,7 @@ static void x86_ctrl_reg_pretty_print(RIO *io, struct r2k_control_reg ctrl) { #if __x86_64__ io->cb_printf ("CR8: 0x%"PFMT64x"\n", (ut64) ctrl.cr8); - io->cb_printf (" [*] TPL: %zu\n", ctrl.cr8 & 0xf); + io->cb_printf (" [*] TPL: %u\n", (ut32)(ctrl.cr8 & 0xf)); #endif } @@ -760,14 +760,13 @@ int run_old_command(RIO *io, RIODesc *iodesc, const char *buf) { io->cb_printf (" %s\n", (char*)&(proc_data.vmareastruct[i + 7])); i = nextstart; } - io->cb_printf ("STACK BASE ADDRESS = 0x%zx\n", proc_data.stack); + io->cb_printf ("STACK BASE ADDRESS = 0x%p\n", (void*)proc_data.stack); } } break; default: - { - print_help (io, NULL, 1); - } + print_help (io, NULL, 1); + break; } end: free (databuf); diff --git a/libr/magic/funcs.c b/libr/magic/funcs.c index 0839a894ba..4f3499c225 100644 --- a/libr/magic/funcs.c +++ b/libr/magic/funcs.c @@ -152,7 +152,7 @@ void file_magerror(RMagic *ms, const char *f, ...) { } void file_oomem(RMagic *ms, size_t len) { - file_error (ms, errno, "cannot allocate %zu bytes", len); + file_error (ms, errno, "cannot allocate %u bytes", (unsigned int)len); } void file_badseek(RMagic *ms) { diff --git a/libr/util/print.c b/libr/util/print.c index 6bc1be8f6d..205f74111b 100644 --- a/libr/util/print.c +++ b/libr/util/print.c @@ -304,7 +304,7 @@ R_API RPrint* r_print_new(void) { if (!p) { return NULL; } - strcpy (p->datefmt, "%Y-%m-%d %H:%M:%S %z"); + strcpy (p->datefmt, "%Y-%m-%d %H:%M:%S %u"); r_io_bind_init (p->iob); p->pairs = true; p->resetbg = true;