On Fri, Oct 21, 2022 at 11:29:32AM -0900, Philip Guenther wrote:
> On Fri, Oct 21, 2022 at 11:04 AM Klemens Nanni <[email protected]> wrote:
>
> > --- a/sys/arch/sparc64/sparc64/db_disasm.c
> > +++ b/sys/arch/sparc64/sparc64/db_disasm.c
> >
> ...
>
> > @@ -877,7 +877,7 @@ struct sparc_insn sparc_i[] = {
> > vaddr_t
> > db_disasm(vaddr_t loc, int altfmt)
> > {
> > - struct sparc_insn* i_ptr = (struct sparc_insn *)&sparc_i;
> > + const struct sparc_insn *i_ptr = (const struct sparc_insn
> > *)&sparc_i;
> >
>
> What's with that cast? Is it only there because sparc_i is an array and
> it's wrong to take its address when we just want a pointer to its first
> element? I mean, shouldn't that line just (with const) be:
> const struct sparc_insn *i_ptr = sparc_i; /* or &sparc_i[0] */
Sure, that also works.
diff --git a/sys/arch/sparc64/sparc64/db_disasm.c
b/sys/arch/sparc64/sparc64/db_disasm.c
index b697ad5e163..7f7056f6753 100644
--- a/sys/arch/sparc64/sparc64/db_disasm.c
+++ b/sys/arch/sparc64/sparc64/db_disasm.c
@@ -153,7 +153,7 @@ char *prefetch[] = {
/* The sparc instruction table has a format field which tells what
the operand structure for this instruction is. Here are the codes:
-Modifiers (nust be first):
+Modifiers (must be first):
a -- opcode has annul bit
p -- opcode has branch prediction bit
@@ -201,7 +201,7 @@ V8 only:
*/
-struct sparc_insn sparc_i[] = {
+const struct sparc_insn sparc_i[] = {
/*
* Format 1: Call
@@ -217,7 +217,7 @@ struct sparc_insn sparc_i[] = {
/* Note: if imm22 is zero then this is actually a "nop" grrr... */
{(FORMAT2(0, 0x4)), "sethi", "Cd"},
- /* Branch on Integer Co`ndition Codes "Bicc" */
+ /* Branch on Integer Condition Codes "Bicc" */
{(FORMAT2(0, 2) | COND(8)), "ba", "a,m"},
{(FORMAT2(0, 2) | COND(0)), "bn", "a,m"},
{(FORMAT2(0, 2) | COND(9)), "bne", "a,m"},
@@ -877,7 +877,7 @@ struct sparc_insn sparc_i[] = {
vaddr_t
db_disasm(vaddr_t loc, int altfmt)
{
- struct sparc_insn* i_ptr = (struct sparc_insn *)&sparc_i;
+ const struct sparc_insn *i_ptr = sparc_i;
unsigned int insn, you_lose, bitmask;
int matchp;