misc: Use g_assert_not_reached for code which is expected to be unreachable

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>
This commit is contained in:
Stefan Weil 2013-07-25 18:21:28 +02:00 committed by Michael Tokarev
parent b031f413b9
commit dfc6f86567
10 changed files with 25 additions and 25 deletions

View file

@ -1029,7 +1029,7 @@ static void abort_prepare(BlkTransactionState *common, Error **errp)
static void abort_commit(BlkTransactionState *common) static void abort_commit(BlkTransactionState *common)
{ {
assert(false); /* this action never succeeds */ g_assert_not_reached(); /* this action never succeeds */
} }
static const BdrvActionOps actions[] = { static const BdrvActionOps actions[] = {

View file

@ -528,7 +528,7 @@ vmxnet3_setup_tx_offloads(VMXNET3State *s)
break; break;
default: default:
assert(false); g_assert_not_reached();
return false; return false;
} }
@ -575,7 +575,7 @@ vmxnet3_on_tx_done_update_stats(VMXNET3State *s, int qidx,
stats->ucastBytesTxOK += tot_len; stats->ucastBytesTxOK += tot_len;
break; break;
default: default:
assert(false); g_assert_not_reached();
} }
if (s->offload_mode == VMXNET3_OM_TSO) { if (s->offload_mode == VMXNET3_OM_TSO) {
@ -599,7 +599,7 @@ vmxnet3_on_tx_done_update_stats(VMXNET3State *s, int qidx,
break; break;
default: default:
assert(false); g_assert_not_reached();
} }
} }
@ -634,7 +634,7 @@ vmxnet3_on_rx_done_update_stats(VMXNET3State *s,
stats->ucastBytesRxOK += tot_len; stats->ucastBytesRxOK += tot_len;
break; break;
default: default:
assert(false); g_assert_not_reached();
} }
if (tot_len > s->mtu) { if (tot_len > s->mtu) {
@ -643,7 +643,7 @@ vmxnet3_on_rx_done_update_stats(VMXNET3State *s,
} }
break; break;
default: 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, if (VMW_IS_MULTIREG_ADDR(addr, VMXNET3_REG_IMR,
VMXNET3_MAX_INTRS, VMXNET3_REG_ALIGN)) { VMXNET3_MAX_INTRS, VMXNET3_REG_ALIGN)) {
assert(false); g_assert_not_reached();
} }
VMW_CBPRN("BAR0 unknown read [%" PRIx64 "], size %d", addr, size); VMW_CBPRN("BAR0 unknown read [%" PRIx64 "], size %d", addr, size);
@ -1651,7 +1651,7 @@ vmxnet3_io_bar1_write(void *opaque,
case VMXNET3_REG_ICR: case VMXNET3_REG_ICR:
VMW_CBPRN("Write BAR1 [VMXNET3_REG_ICR] = %" PRIx64 ", size %d", VMW_CBPRN("Write BAR1 [VMXNET3_REG_ICR] = %" PRIx64 ", size %d",
val, size); val, size);
assert(false); g_assert_not_reached();
break; break;
/* Event Cause Register */ /* Event Cause Register */
@ -1801,7 +1801,7 @@ vmxnet3_rx_filter_may_indicate(VMXNET3State *s, const void *data,
break; break;
default: default:
assert(false); g_assert_not_reached();
} }
return true; return true;

View file

@ -287,7 +287,7 @@ void vmxnet_tx_pkt_build_vheader(struct VmxnetTxPkt *pkt, bool tso_enable,
break; break;
default: default:
assert(false); g_assert_not_reached();
} }
if (csum_enable) { if (csum_enable) {

View file

@ -1357,7 +1357,7 @@ static void ehci_execute_complete(EHCIQueue *q)
default: default:
/* should not be triggerable */ /* should not be triggerable */
fprintf(stderr, "USB invalid response %d\n", p->packet.status); fprintf(stderr, "USB invalid response %d\n", p->packet.status);
assert(0); g_assert_not_reached();
break; break;
} }
@ -2142,7 +2142,7 @@ static void ehci_advance_state(EHCIState *ehci, int async)
default: default:
fprintf(stderr, "Bad state!\n"); fprintf(stderr, "Bad state!\n");
again = -1; again = -1;
assert(0); g_assert_not_reached();
break; break;
} }
@ -2206,7 +2206,7 @@ static void ehci_advance_async_state(EHCIState *ehci)
/* this should only be due to a developer mistake */ /* this should only be due to a developer mistake */
fprintf(stderr, "ehci: Bad asynchronous state %d. " fprintf(stderr, "ehci: Bad asynchronous state %d. "
"Resetting to active\n", ehci->astate); "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 */ /* this should only be due to a developer mistake */
fprintf(stderr, "ehci: Bad periodic state %d. " fprintf(stderr, "ehci: Bad periodic state %d. "
"Resetting to active\n", ehci->pstate); "Resetting to active\n", ehci->pstate);
assert(0); g_assert_not_reached();
} }
} }

View file

@ -73,7 +73,7 @@ eth_get_gso_type(uint16_t l3_proto, uint8_t *l3_hdr, uint8_t l4proto)
} }
/* Unsupported offload */ /* Unsupported offload */
assert(false); g_assert_not_reached();
return VIRTIO_NET_HDR_GSO_NONE | ecn_state; return VIRTIO_NET_HDR_GSO_NONE | ecn_state;
} }

View file

@ -360,7 +360,7 @@ static BusState *qbus_find(const char *path)
/* find device */ /* find device */
if (sscanf(path+pos, "%127[^/]%n", elem, &len) != 1) { if (sscanf(path+pos, "%127[^/]%n", elem, &len) != 1) {
assert(0); g_assert_not_reached();
elem[0] = len = 0; elem[0] = len = 0;
} }
pos += len; pos += len;
@ -397,7 +397,7 @@ static BusState *qbus_find(const char *path)
/* find bus */ /* find bus */
if (sscanf(path+pos, "%127[^/]%n", elem, &len) != 1) { if (sscanf(path+pos, "%127[^/]%n", elem, &len) != 1) {
assert(0); g_assert_not_reached();
elem[0] = len = 0; elem[0] = len = 0;
} }
pos += len; pos += len;

View 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, "was %s, now %s\n", r2->cp, 32 + 32 * is64,
r2->crn, r2->crm, r2->opc1, r2->opc2, r2->crn, r2->crm, r2->opc1, r2->opc2,
oldreg->name, r2->name); oldreg->name, r2->name);
assert(0); g_assert_not_reached();
} }
} }
g_hash_table_insert(cpu->cp_regs, key, r2); g_hash_table_insert(cpu->cp_regs, key, r2);

View file

@ -394,7 +394,7 @@ static void test_native_list_integer_helper(TestInputVisitorData *data,
break; break;
} }
default: default:
g_assert(false); g_assert_not_reached();
} }
g_string_free(gstr_union, true); g_string_free(gstr_union, true);

View file

@ -559,7 +559,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue)
break; break;
} }
default: default:
g_assert(false); g_assert_not_reached();
} }
} }
@ -645,7 +645,7 @@ static void check_native_list(QObject *qobj,
} }
break; break;
default: default:
g_assert(false); g_assert_not_reached();
} }
QDECREF(qlist); QDECREF(qlist);
} }

View 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); visit_type_int64(v, &pt->value.s64, NULL, errp);
break; break;
case PTYPE_EOL: 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); visit_type_uint64List(v, &pl->value.u64_integers, NULL, errp);
break; break;
default: default:
g_assert(false); g_assert_not_reached();
} }
} }
@ -500,7 +500,7 @@ static void test_primitive_lists(gconstpointer opaque)
break; break;
} }
default: default:
g_assert(0); g_assert_not_reached();
} }
} }
@ -656,7 +656,7 @@ static void test_primitive_lists(gconstpointer opaque)
break; break;
} }
default: default:
g_assert(0); g_assert_not_reached();
} }
i++; i++;
} while (cur_head); } while (cur_head);