From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1521) id 89DAD3857026; Fri, 11 Nov 2022 15:08:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 89DAD3857026 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668179315; bh=iWxZ3WMX/bv7ZUnW5o/zs/fvok4I0lkVLHXq4O2VUa0=; h=From:To:Subject:Date:From; b=PB82wvAssa6bcDa91ruUxBr1sCo0PIokyLEPFRs/YLnkFYrrc+Lw0yBG+O7oUkerx Zh1ZyBNE4693BgcdHKCJPt4XmvtInQHHbHDZ/hUAlpkybV3kYzP868TpErKRN2ZFMp kMJJt/GwBzHibuBMk66or+ycA8BrnQ9iVdpU+WkY= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Frysinger To: gdb-cvs@sourceware.org Subject: [binutils-gdb] sim: igen: cleanup archaic pointer-to-long printf casts X-Act-Checkin: binutils-gdb X-Git-Author: Mike Frysinger X-Git-Refname: refs/heads/master X-Git-Oldrev: ac42aa228f3f1ebda16ddb53b993d6341dbbf100 X-Git-Newrev: 36895e5335bcfaab939c7e8d2f271face79bc45c Message-Id: <20221111150835.89DAD3857026@sourceware.org> Date: Fri, 11 Nov 2022 15:08:35 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D36895e5335bc= faab939c7e8d2f271face79bc45c commit 36895e5335bcfaab939c7e8d2f271face79bc45c Author: Mike Frysinger Date: Fri Nov 11 22:02:39 2022 +0700 sim: igen: cleanup archaic pointer-to-long printf casts =20 Use proper %p to printf a pointer instead of casting it to long and using 0x%lx. It's cleaner, more correct, and doesn't break on LLP64. Diff: --- sim/igen/gen.c | 20 ++++++++--------- sim/igen/ld-decode.c | 16 +++++++------- sim/igen/ld-insn.c | 62 ++++++++++++++++++++++++------------------------= ---- sim/igen/table.c | 4 ++-- 4 files changed, 49 insertions(+), 53 deletions(-) diff --git a/sim/igen/gen.c b/sim/igen/gen.c index 9f48e5cb857..f0f7482d878 100644 --- a/sim/igen/gen.c +++ b/sim/igen/gen.c @@ -1511,7 +1511,7 @@ dump_opcode_field (lf *file, char *prefix, opcode_field *field, char *suffix, int levels) { - lf_printf (file, "%s(opcode_field *) 0x%lx", prefix, (long) field); + lf_printf (file, "%s(opcode_field *) %p", prefix, field); if (levels && field !=3D NULL) { lf_indent (file, +1); @@ -1531,7 +1531,7 @@ static void dump_opcode_bits (lf *file, char *prefix, opcode_bits *bits, char *suffix, int levels) { - lf_printf (file, "%s(opcode_bits *) 0x%lx", prefix, (long) bits); + lf_printf (file, "%s(opcode_bits *) %p", prefix, bits); =20 if (levels && bits !=3D NULL) { @@ -1550,13 +1550,13 @@ dump_opcode_bits (lf *file, static void dump_insn_list (lf *file, char *prefix, insn_list *entry, char *suffix) { - lf_printf (file, "%s(insn_list *) 0x%lx", prefix, (long) entry); + lf_printf (file, "%s(insn_list *) %p", prefix, entry); =20 if (entry !=3D NULL) { lf_indent (file, +1); dump_insn_entry (file, "\n(insn ", entry->insn, ")"); - lf_printf (file, "\n(next 0x%lx)", (long) entry->next); + lf_printf (file, "\n(next %p)", entry->next); lf_indent (file, -1); } lf_printf (file, "%s", suffix); @@ -1583,7 +1583,7 @@ dump_gen_entry (lf *file, char *prefix, gen_entry *table, char *suffix, int levels) { =20 - lf_printf (file, "%s(gen_entry *) 0x%lx", prefix, (long) table); + lf_printf (file, "%s(gen_entry *) %p", prefix, table); =20 if (levels && table !=3DNULL) { @@ -1614,9 +1614,9 @@ dump_gen_list (lf *file, { while (entry !=3D NULL) { - lf_printf (file, "%s(gen_list *) 0x%lx", prefix, (long) entry); + lf_printf (file, "%s(gen_list *) %p", prefix, entry); dump_gen_entry (file, "\n(", entry->table, ")", levels); - lf_printf (file, "\n(next (gen_list *) 0x%lx)", (long) entry->next); + lf_printf (file, "\n(next (gen_list *) %p)", entry->next); lf_printf (file, "%s", suffix); } } @@ -1626,9 +1626,9 @@ static void dump_gen_table (lf *file, char *prefix, gen_table *gen, char *suffix, int levels) { - lf_printf (file, "%s(gen_table *) 0x%lx", prefix, (long) gen); - lf_printf (file, "\n(isa (insn_table *) 0x%lx)", (long) gen->isa); - lf_printf (file, "\n(rules (decode_table *) 0x%lx)", (long) gen->rules); + lf_printf (file, "%s(gen_table *) %p", prefix, gen); + lf_printf (file, "\n(isa (insn_table *) %p)", gen->isa); + lf_printf (file, "\n(rules (decode_table *) %p)", gen->rules); dump_gen_list (file, "\n(", gen->tables, ")", levels); lf_printf (file, "%s", suffix); } diff --git a/sim/igen/ld-decode.c b/sim/igen/ld-decode.c index 51bb3e0b0a3..badfa95f50b 100644 --- a/sim/igen/ld-decode.c +++ b/sim/igen/ld-decode.c @@ -309,15 +309,15 @@ static void dump_decode_cond (lf *file, const char *prefix, const decode_cond *cond, const char *suffix) { - lf_printf (file, "%s(decode_cond *) 0x%lx", prefix, (long) cond); + lf_printf (file, "%s(decode_cond *) %p", prefix, cond); if (cond !=3D NULL) { lf_indent (file, +1); lf_printf (file, "\n(word_nr %d)", cond->word_nr); - lf_printf (file, "\n(mask 0x%lx)", (long) cond->mask); - lf_printf (file, "\n(value 0x%lx)", (long) cond->value); - lf_printf (file, "\n(is_equal 0x%lx)", (long) cond->is_equal); - lf_printf (file, "\n(next (decode_cond *) 0%lx)", (long) cond->next); + lf_printf (file, "\n(mask %p)", cond->mask); + lf_printf (file, "\n(value %p)", cond->value); + lf_printf (file, "\n(is_equal %d)", cond->is_equal); + lf_printf (file, "\n(next (decode_cond *) %p)", cond->next); lf_indent (file, -1); } lf_printf (file, "%s", suffix); @@ -328,7 +328,7 @@ static void dump_decode_conds (lf *file, const char *prefix, const decode_cond *cond, const char *suffix) { - lf_printf (file, "%s(decode_cond *) 0x%lx", prefix, (long) cond); + lf_printf (file, "%s(decode_cond *) %p", prefix, cond); while (cond !=3D NULL) { dump_decode_cond (file, "\n(", cond, ")"); @@ -342,7 +342,7 @@ void dump_decode_rule (lf *file, const char *prefix, const decode_table *rule, const char *suffix) { - lf_printf (file, "%s(decode_table *) 0x%lx", prefix, (long) rule); + lf_printf (file, "%s(decode_table *) %p", prefix, rule); if (rule !=3D NULL) { lf_indent (file, +1); @@ -363,7 +363,7 @@ dump_decode_rule (lf *file, const char *prefix, const d= ecode_table *rule, dump_filter (file, "\n(format_names \"", rule->format_names, "\")"); dump_filter (file, "\n(model_names \"", rule->model_names, "\")"); dump_decode_conds (file, "\n(conditions ", rule->conditions, ")"); - lf_printf (file, "\n(next 0x%lx)", (long) rule->next); + lf_printf (file, "\n(next %p)", rule->next); lf_indent (file, -1); } lf_printf (file, "%s", suffix); diff --git a/sim/igen/ld-insn.c b/sim/igen/ld-insn.c index a823b3f6cf6..473c6ff9c71 100644 --- a/sim/igen/ld-insn.c +++ b/sim/igen/ld-insn.c @@ -1388,7 +1388,7 @@ dump_function_entry (lf *file, const function_entry *entry, const char *suffix) { - lf_printf (file, "%s(function_entry *) 0x%lx", prefix, (long) entry); + lf_printf (file, "%s(function_entry *) %p", prefix, entry); if (entry !=3D NULL) { dump_line_ref (file, "\n(line ", entry->line, ")"); @@ -1398,7 +1398,7 @@ dump_function_entry (lf *file, lf_printf (file, "\n(param \"%s\")", entry->param); dump_table_entry (file, "\n(code ", entry->code, ")"); lf_printf (file, "\n(is_internal %d)", entry->is_internal); - lf_printf (file, "\n(next 0x%lx)", (long) entry->next); + lf_printf (file, "\n(next %p)", entry->next); } lf_printf (file, "%s", suffix); } @@ -1442,7 +1442,7 @@ dump_cache_entry (lf *file, const cache_entry *entry, const char *suffix) { - lf_printf (file, "%s(cache_entry *) 0x%lx", prefix, (long) entry); + lf_printf (file, "%s(cache_entry *) %p", prefix, entry); if (entry !=3D NULL) { dump_line_ref (file, "\n(line ", entry->line, ")"); @@ -1453,7 +1453,7 @@ dump_cache_entry (lf *file, dump_filter (file, "\n(original_fields ", entry->original_fields, ")= "); lf_printf (file, "\n(type \"%s\")", entry->type); lf_printf (file, "\n(expression \"%s\")", entry->expression); - lf_printf (file, "\n(next 0x%lx)", (long) entry->next); + lf_printf (file, "\n(next %p)", entry->next); } lf_printf (file, "%s", suffix); } @@ -1481,7 +1481,7 @@ dump_model_data (lf *file, const model_data *entry, const char *suffix) { - lf_printf (file, "%s(model_data *) 0x%lx", prefix, (long) entry); + lf_printf (file, "%s(model_data *) %p", prefix, entry); if (entry !=3D NULL) { lf_indent (file, +1); @@ -1489,7 +1489,7 @@ dump_model_data (lf *file, dump_filter (file, "\n(flags ", entry->flags, ")"); dump_table_entry (file, "\n(entry ", entry->entry, ")"); dump_table_entry (file, "\n(code ", entry->code, ")"); - lf_printf (file, "\n(next 0x%lx)", (long) entry->next); + lf_printf (file, "\n(next %p)", entry->next); lf_indent (file, -1); } lf_printf (file, "%s", prefix); @@ -1518,7 +1518,7 @@ dump_model_entry (lf *file, const model_entry *entry, const char *suffix) { - lf_printf (file, "%s(model_entry *) 0x%lx", prefix, (long) entry); + lf_printf (file, "%s(model_entry *) %p", prefix, entry); if (entry !=3D NULL) { lf_indent (file, +1); @@ -1527,7 +1527,7 @@ dump_model_entry (lf *file, lf_printf (file, "\n(name \"%s\")", entry->name); lf_printf (file, "\n(full_name \"%s\")", entry->full_name); lf_printf (file, "\n(unit_data \"%s\")", entry->unit_data); - lf_printf (file, "\n(next 0x%lx)", (long) entry->next); + lf_printf (file, "\n(next %p)", entry->next); lf_indent (file, -1); } lf_printf (file, "%s", prefix); @@ -1557,7 +1557,7 @@ dump_model_table (lf *file, const model_table *entry, const char *suffix) { - lf_printf (file, "%s(model_table *) 0x%lx", prefix, (long) entry); + lf_printf (file, "%s(model_table *) %p", prefix, entry); if (entry !=3D NULL) { lf_indent (file, +1); @@ -1603,7 +1603,7 @@ dump_insn_field (lf *file, const char *suffix) { char *sep =3D " "; - lf_printf (file, "%s(insn_field_entry *) 0x%lx", prefix, (long) field); + lf_printf (file, "%s(insn_field_entry *) %p", prefix, field); if (field !=3D NULL) { lf_indent (file, +1); @@ -1630,8 +1630,8 @@ dump_insn_field (lf *file, lf_printf (file, "%s(val \"%s\")", sep, field->val_string); break; } - lf_printf (file, "%s(next 0x%lx)", sep, (long) field->next); - lf_printf (file, "%s(prev 0x%lx)", sep, (long) field->prev); + lf_printf (file, "%s(next %p)", sep, field->next); + lf_printf (file, "%s(prev %p)", sep, field->prev); lf_indent (file, -1); } lf_printf (file, "%s", suffix); @@ -1643,24 +1643,24 @@ dump_insn_word_entry (lf *file, const insn_word_entry *word, const char *suffix) { - lf_printf (file, "%s(insn_word_entry *) 0x%lx", prefix, (long) word); + lf_printf (file, "%s(insn_word_entry *) %p", prefix, word); if (word !=3D NULL) { int i; insn_field_entry *field; lf_indent (file, +1); - lf_printf (file, "\n(first 0x%lx)", (long) word->first); - lf_printf (file, "\n(last 0x%lx)", (long) word->last); + lf_printf (file, "\n(first %p)", word->first); + lf_printf (file, "\n(last %p)", word->last); lf_printf (file, "\n(bit"); for (i =3D 0; i < options.insn_bit_size; i++) - lf_printf (file, "\n ((value %d) (mask %d) (field 0x%lx))", + lf_printf (file, "\n ((value %d) (mask %d) (field %p))", word->bit[i]->value, word->bit[i]->mask, - (long) word->bit[i]->field); + word->bit[i]->field); lf_printf (file, ")"); for (field =3D word->first; field !=3D NULL; field =3D field->next) dump_insn_field (file, "\n(", field, ")"); dump_filter (file, "\n(field_names ", word->field_names, ")"); - lf_printf (file, "\n(next 0x%lx)", (long) word->next); + lf_printf (file, "\n(next %p)", word->next); lf_indent (file, -1); } lf_printf (file, "%s", suffix); @@ -1687,7 +1687,7 @@ dump_insn_model_entry (lf *file, const insn_model_entry *model, const char *suffix) { - lf_printf (file, "%s(insn_model_entry *) 0x%lx", prefix, (long) model); + lf_printf (file, "%s(insn_model_entry *) %p", prefix, model); if (model !=3D NULL) { lf_indent (file, +1); @@ -1695,9 +1695,8 @@ dump_insn_model_entry (lf *file, dump_filter (file, "\n(names ", model->names, ")"); lf_printf (file, "\n(full_name \"%s\")", model->full_name); lf_printf (file, "\n(unit_data \"%s\")", model->unit_data); - lf_printf (file, "\n(insn (insn_entry *) 0x%lx)", (long) model->insn= ); - lf_printf (file, "\n(next (insn_model_entry *) 0x%lx)", - (long) model->next); + lf_printf (file, "\n(insn (insn_entry *) %p)", model->insn); + lf_printf (file, "\n(next (insn_model_entry *) %p)", model->next); lf_indent (file, -1); } lf_printf (file, "%s", suffix); @@ -1725,18 +1724,15 @@ dump_insn_mnemonic_entry (lf *file, const insn_mnemonic_entry *mnemonic, const char *suffix) { - lf_printf (file, "%s(insn_mnemonic_entry *) 0x%lx", prefix, - (long) mnemonic); + lf_printf (file, "%s(insn_mnemonic_entry *) %p", prefix, mnemonic); if (mnemonic !=3D NULL) { lf_indent (file, +1); dump_line_ref (file, "\n(line ", mnemonic->line, ")"); lf_printf (file, "\n(format \"%s\")", mnemonic->format); lf_printf (file, "\n(condition \"%s\")", mnemonic->condition); - lf_printf (file, "\n(insn (insn_entry *) 0x%lx)", - (long) mnemonic->insn); - lf_printf (file, "\n(next (insn_mnemonic_entry *) 0x%lx)", - (long) mnemonic->next); + lf_printf (file, "\n(insn (insn_entry *) %p)", mnemonic->insn); + lf_printf (file, "\n(next (insn_mnemonic_entry *) %p)", mnemonic->ne= xt); lf_indent (file, -1); } lf_printf (file, "%s", suffix); @@ -1763,7 +1759,7 @@ dump_insn_entry (lf *file, const insn_entry *entry, const char *suffix) { - lf_printf (file, "%s(insn_entry *) 0x%lx", prefix, (long) entry); + lf_printf (file, "%s(insn_entry *) %p", prefix, entry); if (entry !=3D NULL) { int i; @@ -1774,7 +1770,7 @@ dump_insn_entry (lf *file, dump_insn_word_entries (file, "\n(words ", entry->words, ")"); lf_printf (file, "\n(word"); for (i =3D 0; i < entry->nr_models; i++) - lf_printf (file, " 0x%lx", (long) entry->word[i]); + lf_printf (file, " %p", entry->word[i]); lf_printf (file, ")"); dump_filter (file, "\n(field_names ", entry->field_names, ")"); lf_printf (file, "\n(format_name \"%s\")", entry->format_name); @@ -1784,13 +1780,13 @@ dump_insn_entry (lf *file, dump_insn_model_entries (file, "\n(models ", entry->models, ")"); lf_printf (file, "\n(model"); for (i =3D 0; i < entry->nr_models; i++) - lf_printf (file, " 0x%lx", (long) entry->model[i]); + lf_printf (file, " %p", entry->model[i]); lf_printf (file, ")"); dump_filter (file, "\n(processors ", entry->processors, ")"); dump_insn_mnemonic_entries (file, "\n(mnemonics ", entry->mnemonics, ")"); dump_table_entry (file, "\n(code ", entry->code, ")"); - lf_printf (file, "\n(next 0x%lx)", (long) entry->next); + lf_printf (file, "\n(next %p)", entry->next); lf_indent (file, -1); } lf_printf (file, "%s", suffix); @@ -1820,7 +1816,7 @@ dump_insn_table (lf *file, const insn_table *isa, const char *suffix) { - lf_printf (file, "%s(insn_table *) 0x%lx", prefix, (long) isa); + lf_printf (file, "%s(insn_table *) %p", prefix, isa); if (isa !=3D NULL) { lf_indent (file, +1); diff --git a/sim/igen/table.c b/sim/igen/table.c index acf6e1cee9d..0bf1a308baf 100644 --- a/sim/igen/table.c +++ b/sim/igen/table.c @@ -536,7 +536,7 @@ dump_line_ref (lf *file, const line_ref *line, const char *suffix) { - lf_printf (file, "%s(line_ref*) 0x%lx", prefix, (long) line); + lf_printf (file, "%s(line_ref*) %p", prefix, line); if (line !=3D NULL) { lf_indent (file, +1); @@ -567,7 +567,7 @@ dump_table_entry (lf *file, const table_entry *entry, const char *suffix) { - lf_printf (file, "%s(table_entry*) 0x%lx", prefix, (long) entry); + lf_printf (file, "%s(table_entry*) %p", prefix, entry); if (entry !=3D NULL) { int field;