<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body style='font-size: 12pt; font-family: Verdana,Geneva,sans-serif'>
<div class="pre" style="margin: 0; padding: 0; font-family: monospace">Fix the following coccicheck warning:<br /><br />arch/powerpc/xmon/spu-dis.c:51:34-35: WARNING comparing pointer to 0<br /><br />Signed-off-by: Yonggang Wu <wuyonggang001@208suo.com><br />---<br /> arch/powerpc/xmon/spu-dis.c | 384 ++++++++++++++++++------------------<br /> 1 file changed, 193 insertions(+), 191 deletions(-)<br /><br />diff --git a/arch/powerpc/xmon/spu-dis.c b/arch/powerpc/xmon/spu-dis.c<br />index 4b0a4e640f08..f48a2ddd7440 100644<br />--- a/arch/powerpc/xmon/spu-dis.c<br />+++ b/arch/powerpc/xmon/spu-dis.c<br />@@ -22,216 +22,218 @@ extern const int spu_num_opcodes;<br /> #define SPU_DISASM_TBL_SIZE (1 << 11)<br /> static const struct spu_opcode *spu_disassemble_table[SPU_DISASM_TBL_SIZE];<br /> <br />-static void<br />-init_spu_disassemble (void)<br />+static void init_spu_disassemble(void)<br /> {<br />-  int i;<br />-<br />-  /* If two instructions have the same opcode then we prefer the first<br />-   * one.  In most cases it is just an alternate mnemonic. */<br />-  for (i = 0; i < spu_num_opcodes; i++)<br />-    {<br />-      int o = spu_opcodes[i].opcode;<br />-      if (o >= SPU_DISASM_TBL_SIZE)<br />-    continue; /* abort (); */<br />-      if (spu_disassemble_table[o] == 0)<br />-    spu_disassemble_table[o] = &spu_opcodes[i];<br />-    }<br />+    int i;<br />+<br />+    /*<br />+     * If two instructions have the same opcode then we prefer the first<br />+     * one.  In most cases it is just an alternate mnemonic.<br />+     */<br />+    for (i = 0; i < spu_num_opcodes; i++) {<br />+        int o = spu_opcodes[i].opcode;<br />+<br />+        if (o >= SPU_DISASM_TBL_SIZE)<br />+            continue; /* abort(); */<br />+        if (spu_disassemble_table[o] == NULL)<br />+            spu_disassemble_table[o] = &spu_opcodes[i];<br />+    }<br /> }<br /> <br /> /* Determine the instruction from the 10 least significant bits. */<br />-static const struct spu_opcode *<br />-get_index_for_opcode (unsigned int insn)<br />+static const struct spu_opcode *get_index_for_opcode(unsigned int insn)<br /> {<br />-  const struct spu_opcode *index;<br />-  unsigned int opcode = insn >> (32-11);<br />-<br />-  /* Init the table.  This assumes that element 0/opcode 0 (currently<br />-   * NOP) is always used */<br />-  if (spu_disassemble_table[0] == 0)<br />-    init_spu_disassemble ();<br />-<br />-  if ((index = spu_disassemble_table[opcode & 0x780]) != 0<br />-      && index->insn_type == RRR)<br />-    return index;<br />-<br />-  if ((index = spu_disassemble_table[opcode & 0x7f0]) != 0<br />-      && (index->insn_type == RI18 || index->insn_type == LBT))<br />-    return index;<br />-<br />-  if ((index = spu_disassemble_table[opcode & 0x7f8]) != 0<br />-      && index->insn_type == RI10)<br />-    return index;<br />-<br />-  if ((index = spu_disassemble_table[opcode & 0x7fc]) != 0<br />-      && (index->insn_type == RI16))<br />-    return index;<br />-<br />-  if ((index = spu_disassemble_table[opcode & 0x7fe]) != 0<br />-      && (index->insn_type == RI8))<br />-    return index;<br />-<br />-  if ((index = spu_disassemble_table[opcode & 0x7ff]) != 0)<br />-    return index;<br />-<br />-  return NULL;<br />+    const struct spu_opcode *index;<br />+    unsigned int opcode = insn >> (32-11);<br />+<br />+    /*<br />+     * Init the table.  This assumes that element 0/opcode 0 (currently<br />+     * NOP) is always used<br />+     */<br />+    if (spu_disassemble_table[0] == NULL)<br />+        init_spu_disassemble();<br />+<br />+    index = spu_disassemble_table[opcode & 0x780];<br />+    if (index != NULL && index->insn_type == RRR)<br />+        return index;<br />+<br />+    index = spu_disassemble_table[opcode & 0x7f0];<br />+    if (index != NULL<br />+      && (index->insn_type == RI18 || index->insn_type == LBT))<br />+        return index;<br />+<br />+    index = spu_disassemble_table[opcode & 0x7f8];<br />+    if (index != NULL<br />+      && index->insn_type == RI10)<br />+        return index;<br />+<br />+    index = spu_disassemble_table[opcode & 0x7fc]<br />+    if (index != NULL && (index->insn_type == RI16))<br />+        return index;<br />+<br />+    index = spu_disassemble_table[opcode & 0x7fe];<br />+    if (index != NULL && (index->insn_type == RI8))<br />+        return index;<br />+<br />+    index = spu_disassemble_table[opcode & 0x7ff];<br />+    if (index != NULL)<br />+        return index;<br />+<br />+    return NULL;<br /> }<br /> <br /> /* Print a Spu instruction.  */<br /> <br />-int<br />-print_insn_spu (unsigned long insn, unsigned long memaddr)<br />+int print_insn_spu(unsigned long insn, unsigned long memaddr)<br /> {<br />-  int value;<br />-  int hex_value;<br />-  const struct spu_opcode *index;<br />-  enum spu_insns tag;<br />+    int value;<br />+    int hex_value;<br />+    const struct spu_opcode *index;<br />+    enum spu_insns tag;<br /> <br />-  index = get_index_for_opcode (insn);<br />+    index = get_index_for_opcode(insn);<br /> <br />-  if (index == 0)<br />-    {<br />-      printf(".long 0x%lx", insn);<br />-    }<br />-  else<br />-    {<br />-      int i;<br />-      int paren = 0;<br />-      tag = (enum spu_insns)(index - spu_opcodes);<br />-      printf("%s", index->mnemonic);<br />-      if (tag == M_BI || tag == M_BISL || tag == M_IRET || tag == M_BISLED<br />-      || tag == M_BIHNZ || tag == M_BIHZ || tag == M_BINZ || tag == M_BIZ<br />-          || tag == M_SYNC || tag == M_HBR)<br />+    if (index == NULL)<br />     {<br />-      int fb = (insn >> (32-18)) & 0x7f;<br />-      if (fb & 0x40)<br />-        printf(tag == M_SYNC ? "c" : "p");<br />-      if (fb & 0x20)<br />-        printf("d");<br />-      if (fb & 0x10)<br />-        printf("e");<br />-    }<br />-      if (index->arg[0] != 0)<br />-    printf("\t");<br />-      hex_value = 0;<br />-      for (i = 1;  i <= index->arg[0]; i++)<br />+        printf(".long 0x%lx", insn);<br />+    } else<br />     {<br />-      int arg = index->arg[i];<br />-      if (arg != A_P && !paren && i > 1)<br />-        printf(",");<br />-<br />-      switch (arg)<br />-        {<br />-        case A_T:<br />-          printf("$%lu",<br />-                     DECODE_INSN_RT (insn));<br />-          break;<br />-        case A_A:<br />-          printf("$%lu",<br />-                     DECODE_INSN_RA (insn));<br />-          break;<br />-        case A_B:<br />-          printf("$%lu",<br />-                     DECODE_INSN_RB (insn));<br />-          break;<br />-        case A_C:<br />-          printf("$%lu",<br />-                     DECODE_INSN_RC (insn));<br />-          break;<br />-        case A_S:<br />-          printf("$sp%lu",<br />-                     DECODE_INSN_RA (insn));<br />-          break;<br />-        case A_H:<br />-          printf("$ch%lu",<br />-                     DECODE_INSN_RA (insn));<br />-          break;<br />-        case A_P:<br />-          paren++;<br />-          printf("(");<br />-          break;<br />-        case A_U7A:<br />-          printf("%lu",<br />-                     173 - DECODE_INSN_U8 (insn));<br />-          break;<br />-        case A_U7B:<br />-          printf("%lu",<br />-                     155 - DECODE_INSN_U8 (insn));<br />-          break;<br />-        case A_S3:<br />-        case A_S6:<br />-        case A_S7:<br />-        case A_S7N:<br />-        case A_U3:<br />-        case A_U5:<br />-        case A_U6:<br />-        case A_U7:<br />-          hex_value = DECODE_INSN_I7 (insn);<br />-          printf("%d", hex_value);<br />-          break;<br />-        case A_S11:<br />-          print_address(memaddr + DECODE_INSN_I9a (insn) * 4);<br />-          break;<br />-        case A_S11I:<br />-          print_address(memaddr + DECODE_INSN_I9b (insn) * 4);<br />-          break;<br />-        case A_S10:<br />-        case A_S10B:<br />-          hex_value = DECODE_INSN_I10 (insn);<br />-          printf("%d", hex_value);<br />-          break;<br />-        case A_S14:<br />-          hex_value = DECODE_INSN_I10 (insn) * 16;<br />-          printf("%d", hex_value);<br />-          break;<br />-        case A_S16:<br />-          hex_value = DECODE_INSN_I16 (insn);<br />-          printf("%d", hex_value);<br />-          break;<br />-        case A_X16:<br />-          hex_value = DECODE_INSN_U16 (insn);<br />-          printf("%u", hex_value);<br />-          break;<br />-        case A_R18:<br />-          value = DECODE_INSN_I16 (insn) * 4;<br />-          if (value == 0)<br />-        printf("%d", value);<br />-          else<br />+        int i;<br />+        int paren = 0;<br />+<br />+        tag = (enum spu_insns)(index - spu_opcodes);<br />+<br />+        printf("%s", index->mnemonic);<br />+        if (tag == M_BI || tag == M_BISL || tag == M_IRET || tag == M_BISLED<br />+        || tag == M_BIHNZ || tag == M_BIHZ || tag == M_BINZ || tag == M_BIZ<br />+          || tag == M_SYNC || tag == M_HBR)<br />         {<br />-          hex_value = memaddr + value;<br />-          print_address(hex_value & 0x3ffff);<br />+            int fb = (insn >> (32-18)) & 0x7f;<br />+<br />+            if (fb & 0x40)<br />+                printf(tag == M_SYNC ? "c" : "p");<br />+            if (fb & 0x20)<br />+                printf("d");<br />+            if (fb & 0x10)<br />+                printf("e");<br />         }<br />-          break;<br />-        case A_S18:<br />-          value = DECODE_INSN_U16 (insn) * 4;<br />-          if (value == 0)<br />-        printf("%d", value);<br />-          else<br />-        print_address(value);<br />-          break;<br />-        case A_U18:<br />-          value = DECODE_INSN_U18 (insn);<br />-          if (value == 0 || 1)<br />+        if (index->arg[0] != 0)<br />+            printf("\t");<br />+        hex_value = 0;<br />+        for (i = 1;  i <= index->arg[0]; i++) {<br />+            int arg = index->arg[i];<br />+<br />+            if (arg != A_P && !paren && i > 1)<br />+                printf(",");<br />+<br />+            switch (arg) {<br />+            case A_T:<br />+                printf("$%lu",<br />+                        DECODE_INSN_RT(insn));<br />+                break;<br />+            case A_A:<br />+                printf("$%lu",<br />+                        DECODE_INSN_RA(insn));<br />+                break;<br />+            case A_B:<br />+                printf("$%lu",<br />+                        DECODE_INSN_RB(insn));<br />+                break;<br />+            case A_C:<br />+                printf("$%lu",<br />+                        DECODE_INSN_RC(insn));<br />+                break;<br />+            case A_S:<br />+                printf("$sp%lu",<br />+                        DECODE_INSN_RA(insn));<br />+                break;<br />+            case A_H:<br />+                printf("$ch%lu",<br />+                        DECODE_INSN_RA(insn));<br />+                break;<br />+            case A_P:<br />+                paren++;<br />+                printf("(");<br />+                break;<br />+            case A_U7A:<br />+                printf("%lu",<br />+                        173 - DECODE_INSN_U8(insn));<br />+                break;<br />+            case A_U7B:<br />+                printf("%lu",<br />+                        155 - DECODE_INSN_U8(insn));<br />+                break;<br />+            case A_S3:<br />+            case A_S6:<br />+            case A_S7:<br />+            case A_S7N:<br />+            case A_U3:<br />+            case A_U5:<br />+            case A_U6:<br />+            case A_U7:<br />+                hex_value = DECODE_INSN_I7(insn);<br />+                printf("%d", hex_value);<br />+                break;<br />+            case A_S11:<br />+                print_address(memaddr + DECODE_INSN_I9a(insn) * 4);<br />+                break;<br />+            case A_S11I:<br />+                print_address(memaddr + DECODE_INSN_I9b(insn) * 4);<br />+                break;<br />+            case A_S10:<br />+            case A_S10B:<br />+                hex_value = DECODE_INSN_I10(insn);<br />+                printf("%d", hex_value);<br />+                break;<br />+            case A_S14:<br />+                hex_value = DECODE_INSN_I10(insn) * 16;<br />+                printf("%d", hex_value);<br />+                break;<br />+            case A_S16:<br />+                hex_value = DECODE_INSN_I16(insn);<br />+                printf("%d", hex_value);<br />+                break;<br />+            case A_X16:<br />+                hex_value = DECODE_INSN_U16(insn);<br />+                printf("%u", hex_value);<br />+                break;<br />+            case A_R18:<br />+                value = DECODE_INSN_I16(insn) * 4;<br />+                if (value == 0)<br />+                    printf("%d", value);<br />+                else {<br />+                    hex_value = memaddr + value;<br />+                    print_address(hex_value & 0x3ffff);<br />+                }<br />+                break;<br />+            case A_S18:<br />+                value = DECODE_INSN_U16(insn) * 4;<br />+                if (value == 0)<br />+                    printf("%d", value);<br />+                else<br />+                    print_address(value);<br />+                break;<br />+            case A_U18:<br />+                value = DECODE_INSN_U18(insn);<br />+                if (value == 0 || 1) {<br />+                    hex_value = value;<br />+                    printf("%u", value);<br />+                } else<br />+                    print_address(value);<br />+                break;<br />+            case A_U14:<br />+                hex_value = DECODE_INSN_U14(insn);<br />+                printf("%u", hex_value);<br />+                break;<br />+            }<br />+        if (arg != A_P && paren)<br />         {<br />-          hex_value = value;<br />-          printf("%u", value);<br />+            printf(")");<br />+            paren--;<br />         }<br />-          else<br />-        print_address(value);<br />-          break;<br />-        case A_U14:<br />-          hex_value = DECODE_INSN_U14 (insn);<br />-          printf("%u", hex_value);<br />-          break;<br />-        }<br />-      if (arg != A_P && paren)<br />-        {<br />-          printf(")");<br />-          paren--;<br />-        }<br />     }<br />-      if (hex_value > 16)<br />-    printf("\t# %x", hex_value);<br />+        if (hex_value > 16)<br />+            printf("\t# %x", hex_value);<br />     }<br />   return 4;<br /> }</div>

</body></html>