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:
parent
b031f413b9
commit
dfc6f86567
@ -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[] = {
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user