io_channel: add asserts in spdk_io_device_register
spdk_io_device_register() doesn't have a return value, but we can at least catch trivial mistakes like neglecting to pass a valid io_device or create/delete callback in debug builds. One invalid unit test case that passed NULL for all parameters is removed, since there's no way to make that work without adding a return value instead of asserts. Change-Id: I3dd4c850bdb14957d2dc03209ea9ea44bbe4e616 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-on: https://review.gerrithub.io/408117 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
0f99e7ab9e
commit
37039565d0
@ -303,6 +303,10 @@ spdk_io_device_register(void *io_device, spdk_io_channel_create_cb create_cb,
|
||||
{
|
||||
struct io_device *dev, *tmp;
|
||||
|
||||
assert(io_device != NULL);
|
||||
assert(create_cb != NULL);
|
||||
assert(destroy_cb != NULL);
|
||||
|
||||
dev = calloc(1, sizeof(struct io_device));
|
||||
if (dev == NULL) {
|
||||
SPDK_ERRLOG("could not allocate io_device\n");
|
||||
|
@ -353,12 +353,6 @@ destroy_cb_2(void *io_device, void *ctx_buf)
|
||||
g_destroy_cb_calls++;
|
||||
}
|
||||
|
||||
static int
|
||||
create_cb_null(void *io_device, void *ctx_buf)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
channel(void)
|
||||
{
|
||||
@ -368,7 +362,6 @@ channel(void)
|
||||
spdk_allocate_thread(_send_msg, NULL, NULL, NULL, "thread0");
|
||||
spdk_io_device_register(&device1, create_cb_1, destroy_cb_1, sizeof(ctx1));
|
||||
spdk_io_device_register(&device2, create_cb_2, destroy_cb_2, sizeof(ctx2));
|
||||
spdk_io_device_register(&device3, create_cb_null, NULL, 0);
|
||||
|
||||
g_create_cb_calls = 0;
|
||||
ch1 = spdk_get_io_channel(&device1);
|
||||
|
Loading…
Reference in New Issue
Block a user