lib/ftl: Remove NULL pointer checks in external APIs

Change-Id: Ia2d89e7bf350544ced9a8ae40821634dedb3a741
Signed-off-by: Wojciech Malikowski <wojciech.malikowski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/443384
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Wojciech Malikowski 2019-02-05 06:37:26 -05:00 committed by Jim Harris
parent 7a4d6af182
commit 8cda50fd96
3 changed files with 5 additions and 33 deletions

View File

@ -206,10 +206,8 @@ void spdk_ftl_conf_init_defaults(struct spdk_ftl_conf *conf);
*
* \param dev device
* \param attr Attribute structure to fill
*
* \return 0 if successfully initialized, negated EINVAL otherwise.
*/
int spdk_ftl_dev_get_attrs(const struct spdk_ftl_dev *dev, struct spdk_ftl_attrs *attr);
void spdk_ftl_dev_get_attrs(const struct spdk_ftl_dev *dev, struct spdk_ftl_attrs *attr);
/**
* Submits a read to the specified device.
@ -223,7 +221,7 @@ int spdk_ftl_dev_get_attrs(const struct spdk_ftl_dev *dev, struct spdk_ftl_attrs
* \param cb_fn Callback function to invoke when the I/O is completed
* \param cb_arg Argument to pass to the callback function
*
* \return 0 if successfully submitted, negated EINVAL otherwise.
* \return 0 if successfully submitted, negative errno otherwise.
*/
int spdk_ftl_read(struct spdk_ftl_dev *dev, struct spdk_io_channel *ch, uint64_t lba,
size_t lba_cnt,
@ -241,7 +239,7 @@ int spdk_ftl_read(struct spdk_ftl_dev *dev, struct spdk_io_channel *ch, uint64_t
* \param cb_fn Callback function to invoke when the I/O is completed
* \param cb_arg Argument to pass to the callback function
*
* \return 0 if successfully submitted, negative values otherwise.
* \return 0 if successfully submitted, negative errno otherwise.
*/
int spdk_ftl_write(struct spdk_ftl_dev *dev, struct spdk_io_channel *ch, uint64_t lba,
size_t lba_cnt,
@ -254,7 +252,7 @@ int spdk_ftl_write(struct spdk_ftl_dev *dev, struct spdk_io_channel *ch, uint64_
* \param cb_fn Callback function to invoke when all prior IOs have been completed
* \param cb_arg Argument to pass to the callback function
*
* \return 0 if successfully submitted, negated EINVAL or ENOMEM otherwise.
* \return 0 if successfully submitted, negative errno otherwise.
*/
int spdk_ftl_flush(struct spdk_ftl_dev *dev, spdk_ftl_fn cb_fn, void *cb_arg);

View File

@ -1282,19 +1282,13 @@ ftl_current_limit(const struct spdk_ftl_dev *dev)
return dev->limit;
}
int
void
spdk_ftl_dev_get_attrs(const struct spdk_ftl_dev *dev, struct spdk_ftl_attrs *attrs)
{
if (!dev || !attrs) {
return -EINVAL;
}
attrs->uuid = dev->uuid;
attrs->lbk_cnt = dev->num_lbas;
attrs->lbk_size = FTL_BLOCK_SIZE;
attrs->range = dev->range;
return 0;
}
static void
@ -1357,10 +1351,6 @@ spdk_ftl_write(struct spdk_ftl_dev *dev, struct spdk_io_channel *ch, uint64_t lb
{
struct ftl_io *io;
if (!iov || !cb_fn || !dev) {
return -EINVAL;
}
if (iov_cnt == 0 || iov_cnt > FTL_MAX_IOV) {
return -EINVAL;
}
@ -1418,10 +1408,6 @@ spdk_ftl_read(struct spdk_ftl_dev *dev, struct spdk_io_channel *ch, uint64_t lba
{
struct ftl_io *io;
if (!iov || !cb_fn || !dev) {
return -EINVAL;
}
if (iov_cnt == 0 || iov_cnt > FTL_MAX_IOV) {
return -EINVAL;
}
@ -1502,10 +1488,6 @@ spdk_ftl_flush(struct spdk_ftl_dev *dev, spdk_ftl_fn cb_fn, void *cb_arg)
{
struct ftl_flush *flush;
if (!dev || !cb_fn) {
return -EINVAL;
}
if (!dev->initialized) {
return -EBUSY;
}

View File

@ -820,10 +820,6 @@ spdk_ftl_dev_init(const struct spdk_ftl_dev_init_opts *opts, spdk_ftl_init_fn cb
{
struct spdk_ftl_dev *dev;
if (!opts || !opts->ctrlr) {
return -EINVAL;
}
dev = calloc(1, sizeof(*dev));
if (!dev) {
return -ENOMEM;
@ -1016,10 +1012,6 @@ ftl_add_halt_poller(void *ctx)
int
spdk_ftl_dev_free(struct spdk_ftl_dev *dev, spdk_ftl_fn cb, void *cb_arg)
{
if (!dev || !cb) {
return -EINVAL;
}
if (dev->halt_cb) {
return -EBUSY;
}