From b755895f0fc372e219849eeeac399922ea0549e9 Mon Sep 17 00:00:00 2001 From: couriersud Date: Thu, 2 Jul 2015 21:22:13 +0200 Subject: [PATCH] Identify size_t usage in printf by enclosing the argument in SIZET_PRINTF(). This is typesafe, can be identified and allows to use proper 64bit computing with compilers up to it. [Couriersud] --- src/emu/netlist/nl_parser.c | 2 +- src/emu/netlist/plib/pconfig.h | 10 ++++++++++ src/emu/netlist/plib/pparser.c | 2 +- src/emu/netlist/solver/nld_ms_direct.h | 2 +- src/emu/netlist/solver/nld_solver.c | 10 +++++----- src/emu/netlist/tools/nl_convert.c | 2 +- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/emu/netlist/nl_parser.c b/src/emu/netlist/nl_parser.c index dc219323a41..cbd9be4ec5a 100644 --- a/src/emu/netlist/nl_parser.c +++ b/src/emu/netlist/nl_parser.c @@ -376,7 +376,7 @@ void parser_t::device(const pstring &dev_type) tok = get_token(); } if (cnt != termlist.size()) - m_setup.netlist().error("netlist: input count mismatch for %s - expected %" SIZETFMT " found %" SIZETFMT "\n", devname.cstr(), termlist.size(), cnt); + m_setup.netlist().error("netlist: input count mismatch for %s - expected %" SIZETFMT " found %" SIZETFMT "\n", devname.cstr(), SIZET_PRINTF(termlist.size()), SIZET_PRINTF(cnt)); require_token(tok, m_tok_param_right); } } diff --git a/src/emu/netlist/plib/pconfig.h b/src/emu/netlist/plib/pconfig.h index 4ff0a07602d..2bf1a2f26c5 100644 --- a/src/emu/netlist/plib/pconfig.h +++ b/src/emu/netlist/plib/pconfig.h @@ -48,6 +48,11 @@ #undef ATTR_COLD #define ATTR_COLD +static inline std::size_t SIZET_PRINTF(const std::size_t &v) +{ + return (unsigned) v; +} + /* use MAME */ #if (USE_DELEGATE_TYPE == DELEGATE_TYPE_INTERNAL) #define PHAS_PMF_INTERNAL 1 @@ -148,6 +153,11 @@ typedef int64_t INT64; #endif #endif +static inline std::size_t SIZET_PRINTF(const std::size_t &v) +{ + return (unsigned) v; +} + #endif /* diff --git a/src/emu/netlist/plib/pparser.c b/src/emu/netlist/plib/pparser.c index a6e633f22bb..954b9048810 100644 --- a/src/emu/netlist/plib/pparser.c +++ b/src/emu/netlist/plib/pparser.c @@ -463,7 +463,7 @@ pstring ppreprocessor::process(const pstring &contents) } } else - error(pstring::sprintf("unknown directive on line %" SIZETFMT ": %s\n", i, line.cstr())); + error(pstring::sprintf("unknown directive on line %" SIZETFMT ": %s\n", SIZET_PRINTF(i), line.cstr())); } else { diff --git a/src/emu/netlist/solver/nld_ms_direct.h b/src/emu/netlist/solver/nld_ms_direct.h index 6f63d51db15..f715b9d074d 100644 --- a/src/emu/netlist/solver/nld_ms_direct.h +++ b/src/emu/netlist/solver/nld_ms_direct.h @@ -147,7 +147,7 @@ template ATTR_COLD void matrix_solver_direct_t::vsetup(analog_net_t::list_t &nets) { if (m_dim < nets.size()) - netlist().error("Dimension %d less than %" SIZETFMT, m_dim, nets.size()); + netlist().error("Dimension %d less than %" SIZETFMT, m_dim, SIZET_PRINTF(nets.size())); for (unsigned k = 0; k < N(); k++) { diff --git a/src/emu/netlist/solver/nld_solver.c b/src/emu/netlist/solver/nld_solver.c index d1f080bd176..46391bef3e6 100644 --- a/src/emu/netlist/solver/nld_solver.c +++ b/src/emu/netlist/solver/nld_solver.c @@ -162,7 +162,7 @@ ATTR_COLD void matrix_solver_t::setup(analog_net_t::list_t &nets) if (net_proxy_output == NULL) { net_proxy_output = palloc(analog_output_t); - net_proxy_output->init_object(*this, this->name() + "." + pstring::sprintf("m%" SIZETFMT, m_inps.size())); + net_proxy_output->init_object(*this, this->name() + "." + pstring::sprintf("m%" SIZETFMT, SIZET_PRINTF(m_inps.size()))); m_inps.add(net_proxy_output); net_proxy_output->m_proxied_net = &p->net().as_analog(); } @@ -511,7 +511,7 @@ ATTR_COLD void NETLIB_NAME(solver)::post_start() } // setup the solvers - netlist().log("Found %d net groups in %" SIZETFMT " nets\n", cur_group + 1, netlist().m_nets.size()); + netlist().log("Found %d net groups in %" SIZETFMT " nets\n", cur_group + 1, SIZET_PRINTF(netlist().m_nets.size())); for (int i = 0; i <= cur_group; i++) { matrix_solver_t *ms; @@ -576,19 +576,19 @@ ATTR_COLD void NETLIB_NAME(solver)::post_start() break; } - register_sub(pstring::sprintf("Solver_%" SIZETFMT,m_mat_solvers.size()), *ms); + register_sub(pstring::sprintf("Solver_%" SIZETFMT,SIZET_PRINTF(m_mat_solvers.size())), *ms); ms->vsetup(groups[i]); m_mat_solvers.add(ms); netlist().log("Solver %s", ms->name().cstr()); - netlist().log(" # %d ==> %" SIZETFMT " nets", i, groups[i].size()); //, (*(*groups[i].first())->m_core_terms.first())->name().cstr()); + netlist().log(" # %d ==> %" SIZETFMT " nets", i, SIZET_PRINTF(groups[i].size())); //, (*(*groups[i].first())->m_core_terms.first())->name().cstr()); netlist().log(" has %s elements", ms->is_dynamic() ? "dynamic" : "no dynamic"); netlist().log(" has %s elements", ms->is_timestep() ? "timestep" : "no timestep"); for (std::size_t j=0; jname().cstr()); + netlist().log("Net %" SIZETFMT ": %s", SIZET_PRINTF(j), groups[i][j]->name().cstr()); net_t *n = groups[i][j]; for (std::size_t k = 0; k < n->m_core_terms.size(); k++) { diff --git a/src/emu/netlist/tools/nl_convert.c b/src/emu/netlist/tools/nl_convert.c index 39fad2d7241..23e5c537b12 100644 --- a/src/emu/netlist/tools/nl_convert.c +++ b/src/emu/netlist/tools/nl_convert.c @@ -337,7 +337,7 @@ void nl_convert_spice_t::process_line(const pstring &line) add_device(tname, xname); for (std::size_t i=1; i < tt.size() - 1; i++) { - pstring term = pstring::sprintf("%s.%" SIZETFMT, xname.cstr(), i); + pstring term = pstring::sprintf("%s.%" SIZETFMT, xname.cstr(), SIZET_PRINTF(i)); add_term(tt[i], term); } break;