No longer wrap assert()

assert is part of the C standard library and is available
on any platform we'd consider porting to. Don't put a
wrapper around it.

Change-Id: I0acfdd6a8a269d6c37df38fb7ddf4f1227630223
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Ben Walker 2016-08-08 13:55:27 -07:00
parent 888014289c
commit 0606eaad1a
10 changed files with 29 additions and 51 deletions

View File

@ -201,7 +201,7 @@ ioat_prep_copy(struct spdk_ioat_chan *ioat, uint64_t dst,
struct ioat_descriptor *desc;
union spdk_ioat_hw_desc *hw_desc;
ioat_assert(len <= ioat->max_xfer_size);
assert(len <= ioat->max_xfer_size);
if (ioat_get_ring_space(ioat) < 1) {
return NULL;
@ -232,7 +232,7 @@ ioat_prep_fill(struct spdk_ioat_chan *ioat, uint64_t dst,
struct ioat_descriptor *desc;
union spdk_ioat_hw_desc *hw_desc;
ioat_assert(len <= ioat->max_xfer_size);
assert(len <= ioat->max_xfer_size);
if (ioat_get_ring_space(ioat) < 1) {
return NULL;

View File

@ -1,7 +1,6 @@
#ifndef __IOAT_IMPL_H__
#define __IOAT_IMPL_H__
#include <assert.h>
#include <pthread.h>
#include <stdio.h>
#include <stdbool.h>
@ -11,6 +10,7 @@
#include <rte_atomic.h>
#include <rte_cycles.h>
#include "spdk/assert.h"
#include "spdk/pci.h"
#include "spdk/vtophys.h"
#include "spdk/pci.h"
@ -64,12 +64,6 @@ ioat_zmalloc(const char *tag, size_t size, unsigned align, uint64_t *phys_addr)
*/
#define ioat_delay_us(us) rte_delay_us(us)
/**
* Assert a condition and panic/abort as desired. Failures of these
* assertions indicate catastrophic failures within the driver.
*/
#define ioat_assert(check) assert(check)
/**
* Log or print a message from the driver.
*/

View File

@ -150,8 +150,8 @@ nvme_allocate_request_null(spdk_nvme_cmd_cb cb_fn, void *cb_arg)
void
nvme_free_request(struct nvme_request *req)
{
nvme_assert(req != NULL, ("nvme_free_request(NULL)\n"));
nvme_assert(req->num_children == 0, ("num_children != 0\n"));
assert(req != NULL);
assert(req->num_children == 0);
nvme_dealloc_request(req);
}

View File

@ -902,7 +902,7 @@ nvme_ctrlr_process_init(struct spdk_nvme_ctrlr *ctrlr)
break;
default:
nvme_assert(0, ("unhandled ctrlr state %d\n", ctrlr->state));
assert(0);
nvme_ctrlr_fail(ctrlr);
return -1;
}

View File

@ -104,12 +104,6 @@ nvme_malloc(const char *tag, size_t size, unsigned align, uint64_t *phys_addr)
*/
#define nvme_printf(ctrlr, fmt, args...) printf(fmt, ##args)
/**
* Assert a condition and panic/abort as desired. Failures of these
* assertions indicate catastrophic failures within the driver.
*/
#define nvme_assert(check, str) assert(check)
/**
* Return the physical address for the specified virtual address.
*/

View File

@ -176,7 +176,7 @@ int nvme_ns_construct(struct spdk_nvme_ns *ns, uint16_t id,
{
uint32_t pci_devid;
nvme_assert(id > 0, ("invalid namespace id %d", id));
assert(id > 0);
ns->ctrlr = ctrlr;
ns->id = id;

View File

@ -84,10 +84,10 @@ nvme_request_add_child(struct nvme_request *parent, struct nvme_request *child)
void
nvme_request_remove_child(struct nvme_request *parent, struct nvme_request *child)
{
nvme_assert(parent != NULL, ("parent == NULL\n"));
nvme_assert(child != NULL, ("child == NULL\n"));
nvme_assert(child->parent == parent, ("child->parent != parent\n"));
nvme_assert(parent->num_children != 0, ("num_children == 0\n"));
assert(parent != NULL);
assert(child != NULL);
assert(child->parent == parent);
assert(parent->num_children != 0);
parent->num_children--;
TAILQ_REMOVE(&parent->children, child, child_tailq);

View File

@ -115,8 +115,8 @@ static void
nvme_io_qpair_print_command(struct spdk_nvme_qpair *qpair,
struct spdk_nvme_cmd *cmd)
{
nvme_assert(qpair != NULL, ("print_command: qpair == NULL\n"));
nvme_assert(cmd != NULL, ("print_command: cmd == NULL\n"));
assert(qpair != NULL);
assert(cmd != NULL);
switch ((int)cmd->opc) {
case SPDK_NVME_OPC_WRITE:
case SPDK_NVME_OPC_READ:
@ -146,8 +146,8 @@ nvme_io_qpair_print_command(struct spdk_nvme_qpair *qpair,
static void
nvme_qpair_print_command(struct spdk_nvme_qpair *qpair, struct spdk_nvme_cmd *cmd)
{
nvme_assert(qpair != NULL, ("qpair can not be NULL"));
nvme_assert(cmd != NULL, ("cmd can not be NULL"));
assert(qpair != NULL);
assert(cmd != NULL);
if (nvme_qpair_is_admin_queue(qpair)) {
nvme_admin_qpair_print_command(qpair, cmd);
@ -369,7 +369,7 @@ nvme_qpair_complete_tracker(struct spdk_nvme_qpair *qpair, struct nvme_tracker *
req = tr->req;
nvme_assert(req != NULL, ("tr has NULL req\n"));
assert(req != NULL);
error = spdk_nvme_cpl_is_error(cpl);
retry = error && nvme_completion_is_retry(cpl) &&
@ -382,7 +382,7 @@ nvme_qpair_complete_tracker(struct spdk_nvme_qpair *qpair, struct nvme_tracker *
qpair->tr[cpl->cid].active = false;
nvme_assert(cpl->cid == req->cmd.cid, ("cpl cid does not match cmd cid\n"));
assert(cpl->cid == req->cmd.cid);
if (retry) {
req->retries++;
@ -506,7 +506,7 @@ spdk_nvme_qpair_process_completions(struct spdk_nvme_qpair *qpair, uint32_t max_
nvme_printf(qpair->ctrlr,
"cpl does not map to outstanding cmd\n");
nvme_qpair_print_completion(qpair, cpl);
nvme_assert(0, ("received completion for unknown cmd\n"));
assert(0);
}
if (++qpair->cq_head == qpair->num_entries) {
@ -537,8 +537,8 @@ nvme_qpair_construct(struct spdk_nvme_qpair *qpair, uint16_t id,
uint64_t phys_addr = 0;
uint64_t offset;
nvme_assert(num_entries != 0, ("invalid num_entries\n"));
nvme_assert(num_trackers != 0, ("invalid num_trackers\n"));
assert(num_entries != 0);
assert(num_trackers != 0);
qpair->id = id;
qpair->num_entries = num_entries;
@ -617,7 +617,7 @@ nvme_admin_qpair_abort_aers(struct spdk_nvme_qpair *qpair)
tr = LIST_FIRST(&qpair->outstanding_tr);
while (tr != NULL) {
nvme_assert(tr->req != NULL, ("tr->req == NULL in abort_aers\n"));
assert(tr->req != NULL);
if (tr->req->cmd.opc == SPDK_NVME_OPC_ASYNC_EVENT_REQUEST) {
nvme_qpair_manual_complete_tracker(qpair, tr,
SPDK_NVME_SCT_GENERIC, SPDK_NVME_SC_ABORTED_SQ_DELETION, 0,
@ -741,10 +741,10 @@ _nvme_qpair_build_hw_sgl_request(struct spdk_nvme_qpair *qpair, struct nvme_requ
/*
* Build scattered payloads.
*/
nvme_assert(req->payload_size != 0, ("cannot build SGL for zero-length transfer\n"));
nvme_assert(req->payload.type == NVME_PAYLOAD_TYPE_SGL, ("sgl payload type required\n"));
nvme_assert(req->payload.u.sgl.reset_sgl_fn != NULL, ("sgl reset callback required\n"));
nvme_assert(req->payload.u.sgl.next_sge_fn != NULL, ("sgl callback required\n"));
assert(req->payload_size != 0);
assert(req->payload.type == NVME_PAYLOAD_TYPE_SGL);
assert(req->payload.u.sgl.reset_sgl_fn != NULL);
assert(req->payload.u.sgl.next_sge_fn != NULL);
req->payload.u.sgl.reset_sgl_fn(req->payload.u.sgl.cb_arg, req->payload_offset);
sgl = tr->u.sgl;
@ -814,8 +814,8 @@ _nvme_qpair_build_prps_sgl_request(struct spdk_nvme_qpair *qpair, struct nvme_re
/*
* Build scattered payloads.
*/
nvme_assert(req->payload.type == NVME_PAYLOAD_TYPE_SGL, ("sgl payload type required\n"));
nvme_assert(req->payload.u.sgl.reset_sgl_fn != NULL, ("sgl reset callback required\n"));
assert(req->payload.type == NVME_PAYLOAD_TYPE_SGL);
assert(req->payload.u.sgl.reset_sgl_fn != NULL);
req->payload.u.sgl.reset_sgl_fn(req->payload.u.sgl.cb_arg, req->payload_offset);
remaining_transfer_len = req->payload_size;
@ -823,7 +823,7 @@ _nvme_qpair_build_prps_sgl_request(struct spdk_nvme_qpair *qpair, struct nvme_re
last_nseg = 0;
while (remaining_transfer_len > 0) {
nvme_assert(req->payload.u.sgl.next_sge_fn != NULL, ("sgl callback required\n"));
assert(req->payload.u.sgl.next_sge_fn != NULL);
rc = req->payload.u.sgl.next_sge_fn(req->payload.u.sgl.cb_arg, &phys_addr, &length);
if (rc) {
_nvme_fail_request_bad_vtophys(qpair, tr);
@ -958,7 +958,7 @@ nvme_qpair_submit_request(struct spdk_nvme_qpair *qpair, struct nvme_request *re
return rc;
}
} else {
nvme_assert(0, ("invalid NVMe payload type %d\n", req->payload.type));
assert(0);
_nvme_fail_request_bad_vtophys(qpair, tr);
return -EINVAL;
}

View File

@ -24,7 +24,6 @@ ioat_zmalloc(const char *tag, size_t size, unsigned align, uint64_t *phys_addr)
#define ioat_free(buf) free(buf)
#define ioat_vtophys(buf) (uint64_t)(buf)
#define ioat_delay_us(us) ioat_noop()
#define ioat_assert(check) assert(check)
#define ioat_printf(chan, fmt, args...) printf(fmt, ##args)
static inline int

View File

@ -61,15 +61,6 @@ extern char outbuf[OUTBUF_SIZE];
#define nvme_printf(ctrlr, fmt, args...) snprintf(outbuf, OUTBUF_SIZE, fmt, ##args)
#define nvme_get_num_ioq() 8
#define nvme_get_ioq_idx() 0
#define nvme_assert(check, str) \
do \
{ \
if (!(check)) { \
printf str; \
assert(check); \
} \
} \
while (0)
uint64_t nvme_vtophys(void *buf);
#define NVME_VTOPHYS_ERROR (0xFFFFFFFFFFFFFFFFULL)