]> git.proxmox.com Git - mirror_qemu.git/commitdiff
misc: Use g_assert_not_reached for code which is expected to be unreachable
authorStefan Weil <sw@weilnetz.de>
Thu, 25 Jul 2013 16:21:28 +0000 (18:21 +0200)
committerMichael Tokarev <mjt@tls.msk.ru>
Sat, 27 Jul 2013 07:22:54 +0000 (11:22 +0400)
The macro g_assert_not_reached is a better self documenting replacement
for assert(0) or assert(false).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
blockdev.c
hw/net/vmxnet3.c
hw/net/vmxnet_tx_pkt.c
hw/usb/hcd-ehci.c
net/eth.c
qdev-monitor.c
target-arm/helper.c
tests/test-qmp-input-visitor.c
tests/test-qmp-output-visitor.c
tests/test-visitor-serialization.c

index 453486480237b24e221374ac0367f86518ec70dd..7879e8593d783591b1ae062572373758195fe8f3 100644 (file)
@@ -1029,7 +1029,7 @@ static void abort_prepare(BlkTransactionState *common, Error **errp)
 
 static void abort_commit(BlkTransactionState *common)
 {
-    assert(false); /* this action never succeeds */
+    g_assert_not_reached(); /* this action never succeeds */
 }
 
 static const BdrvActionOps actions[] = {
index b39ff08f28c47aa67be321932f8a430665edf29a..0f3c58c8e40e406090dcf1c420bd3e6a7d489c6e 100644 (file)
@@ -528,7 +528,7 @@ vmxnet3_setup_tx_offloads(VMXNET3State *s)
         break;
 
     default:
-        assert(false);
+        g_assert_not_reached();
         return false;
     }
 
@@ -575,7 +575,7 @@ vmxnet3_on_tx_done_update_stats(VMXNET3State *s, int qidx,
             stats->ucastBytesTxOK += tot_len;
             break;
         default:
-            assert(false);
+            g_assert_not_reached();
         }
 
         if (s->offload_mode == VMXNET3_OM_TSO) {
@@ -599,7 +599,7 @@ vmxnet3_on_tx_done_update_stats(VMXNET3State *s, int qidx,
         break;
 
     default:
-        assert(false);
+        g_assert_not_reached();
     }
 }
 
@@ -634,7 +634,7 @@ vmxnet3_on_rx_done_update_stats(VMXNET3State *s,
             stats->ucastBytesRxOK += tot_len;
             break;
         default:
-            assert(false);
+            g_assert_not_reached();
         }
 
         if (tot_len > s->mtu) {
@@ -643,7 +643,7 @@ vmxnet3_on_rx_done_update_stats(VMXNET3State *s,
         }
         break;
     default:
-        assert(false);
+        g_assert_not_reached();
     }
 }
 
@@ -1106,7 +1106,7 @@ vmxnet3_io_bar0_read(void *opaque, hwaddr addr, unsigned size)
 {
     if (VMW_IS_MULTIREG_ADDR(addr, VMXNET3_REG_IMR,
                         VMXNET3_MAX_INTRS, VMXNET3_REG_ALIGN)) {
-        assert(false);
+        g_assert_not_reached();
     }
 
     VMW_CBPRN("BAR0 unknown read [%" PRIx64 "], size %d", addr, size);
@@ -1651,7 +1651,7 @@ vmxnet3_io_bar1_write(void *opaque,
     case VMXNET3_REG_ICR:
         VMW_CBPRN("Write BAR1 [VMXNET3_REG_ICR] = %" PRIx64 ", size %d",
                   val, size);
-        assert(false);
+        g_assert_not_reached();
         break;
 
     /* Event Cause Register */
@@ -1801,7 +1801,7 @@ vmxnet3_rx_filter_may_indicate(VMXNET3State *s, const void *data,
         break;
 
     default:
-        assert(false);
+        g_assert_not_reached();
     }
 
     return true;
index fc01e4da3ce8d4643dfe48a80c65d5ce59cb54c3..f7344c4cb30253bd3ea6890559ba3b66f10a591f 100644 (file)
@@ -287,7 +287,7 @@ void vmxnet_tx_pkt_build_vheader(struct VmxnetTxPkt *pkt, bool tso_enable,
         break;
 
     default:
-        assert(false);
+        g_assert_not_reached();
     }
 
     if (csum_enable) {
index 67e4b24273ea234d3fc2392e26d4347f65030cb8..010a0d0d321c05c8a127ad9a602b05950102179a 100644 (file)
@@ -1357,7 +1357,7 @@ static void ehci_execute_complete(EHCIQueue *q)
     default:
         /* should not be triggerable */
         fprintf(stderr, "USB invalid response %d\n", p->packet.status);
-        assert(0);
+        g_assert_not_reached();
         break;
     }
 
@@ -2142,7 +2142,7 @@ static void ehci_advance_state(EHCIState *ehci, int async)
         default:
             fprintf(stderr, "Bad state!\n");
             again = -1;
-            assert(0);
+            g_assert_not_reached();
             break;
         }
 
@@ -2206,7 +2206,7 @@ static void ehci_advance_async_state(EHCIState *ehci)
         /* this should only be due to a developer mistake */
         fprintf(stderr, "ehci: Bad asynchronous state %d. "
                 "Resetting to active\n", ehci->astate);
-        assert(0);
+        g_assert_not_reached();
     }
 }
 
@@ -2256,7 +2256,7 @@ static void ehci_advance_periodic_state(EHCIState *ehci)
         /* this should only be due to a developer mistake */
         fprintf(stderr, "ehci: Bad periodic state %d. "
                 "Resetting to active\n", ehci->pstate);
-        assert(0);
+        g_assert_not_reached();
     }
 }
 
index 1d7494d5e52c902732e62fef764ab1224dce4b3c..7c61132cbb1555638b523bc3b34178a78031fa15 100644 (file)
--- a/net/eth.c
+++ b/net/eth.c
@@ -73,7 +73,7 @@ eth_get_gso_type(uint16_t l3_proto, uint8_t *l3_hdr, uint8_t l4proto)
     }
 
     /* Unsupported offload */
-    assert(false);
+    g_assert_not_reached();
 
     return VIRTIO_NET_HDR_GSO_NONE | ecn_state;
 }
index e54dbc2c5d6bddba7f25828e97f7706ade158363..e5adf6c9d0fa3b19c12f46782fd0585fd7d69b57 100644 (file)
@@ -360,7 +360,7 @@ static BusState *qbus_find(const char *path)
 
         /* find device */
         if (sscanf(path+pos, "%127[^/]%n", elem, &len) != 1) {
-            assert(0);
+            g_assert_not_reached();
             elem[0] = len = 0;
         }
         pos += len;
@@ -397,7 +397,7 @@ static BusState *qbus_find(const char *path)
 
         /* find bus */
         if (sscanf(path+pos, "%127[^/]%n", elem, &len) != 1) {
-            assert(0);
+            g_assert_not_reached();
             elem[0] = len = 0;
         }
         pos += len;
index b0c3ca1fbe35418381e495f94a559de9cf5bfdf5..4968391b830a637aef24d722e12aaea2c0c3f177 100644 (file)
@@ -1653,7 +1653,7 @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
                                 "was %s, now %s\n", r2->cp, 32 + 32 * is64,
                                 r2->crn, r2->crm, r2->opc1, r2->opc2,
                                 oldreg->name, r2->name);
-                        assert(0);
+                        g_assert_not_reached();
                     }
                 }
                 g_hash_table_insert(cpu->cp_regs, key, r2);
index 2741eef3fa3792aaa1f495e310642898750eb7ab..0beb8fbfd2d91b95b45eeec31de05d3a6a86ae6e 100644 (file)
@@ -394,7 +394,7 @@ static void test_native_list_integer_helper(TestInputVisitorData *data,
         break;
     }
     default:
-        g_assert(false);
+        g_assert_not_reached();
     }
 
     g_string_free(gstr_union, true);
index b2fa9a74f67ea368234fbc660ba26c4b060d2080..e073d833bf6291361db3bc0d9549166ef6e50f6c 100644 (file)
@@ -559,7 +559,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue)
         break;
     }
     default:
-        g_assert(false);
+        g_assert_not_reached();
     }
 }
 
@@ -645,7 +645,7 @@ static void check_native_list(QObject *qobj,
         }
         break;
     default:
-        g_assert(false);
+        g_assert_not_reached();
     }
     QDECREF(qlist);
 }
index ee7916b80695c67f481693f1994480918ef105bb..9aaa5872e5b8eca88470c1c8ea0252278e20beed 100644 (file)
@@ -136,7 +136,7 @@ static void visit_primitive_type(Visitor *v, void **native, Error **errp)
         visit_type_int64(v, &pt->value.s64, NULL, errp);
         break;
     case PTYPE_EOL:
-        g_assert(false);
+        g_assert_not_reached();
     }
 }
 
@@ -181,7 +181,7 @@ static void visit_primitive_list(Visitor *v, void **native, Error **errp)
         visit_type_uint64List(v, &pl->value.u64_integers, NULL, errp);
         break;
     default:
-        g_assert(false);
+        g_assert_not_reached();
     }
 }
 
@@ -500,7 +500,7 @@ static void test_primitive_lists(gconstpointer opaque)
             break;
         }
         default:
-            g_assert(0);
+            g_assert_not_reached();
         }
     }
 
@@ -656,7 +656,7 @@ static void test_primitive_lists(gconstpointer opaque)
             break;
         }
         default:
-            g_assert(0);
+            g_assert_not_reached();
         }
         i++;
     } while (cur_head);