Commit 8cda50fd authored by Wojciech Malikowski's avatar Wojciech Malikowski Committed by Jim Harris
Browse files

lib/ftl: Remove NULL pointer checks in external APIs

parent 7a4d6af1
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -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);

+1 −19
Original line number Diff line number Diff line
@@ -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;
	}
+0 −8
Original line number Diff line number Diff line
@@ -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;
	}