On 08/23/2017 01:19 PM, Marc-André Lureau wrote:
> Instead of a preliminary check, add an assert to the function that has
> the pre-condition.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> contrib/vhost-user-scsi/vhost-user-scsi.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/contrib/vhost-user-scsi/vhost-user-scsi.c b/contrib/vhost-user-scsi/vhost-user-scsi.c
> index b40009e234..988417393f 100644
> --- a/contrib/vhost-user-scsi/vhost-user-scsi.c
> +++ b/contrib/vhost-user-scsi/vhost-user-scsi.c
> @@ -255,6 +255,7 @@ static int iscsi_add_lun(iscsi_lun_t *lun, char *iscsi_uri)
>
> assert(lun);
> assert(iscsi_uri);
> + assert(!lun->iscsi_ctx);
>
> iscsi_ctx = iscsi_create_context(VUS_ISCSI_INITIATOR);
> if (!iscsi_ctx) {
> @@ -664,11 +665,6 @@ static int vdev_scsi_add_iscsi_lun(vhost_scsi_dev_t *vdev_scsi,
> assert(iscsi_uri);
> assert(lun < VUS_MAX_LUNS);
>
> - if (vdev_scsi->luns[lun].iscsi_ctx) {
> - PERR("Lun %d already configured", lun);
> - return -1;
> - }
the error message is lost :/
anyway:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> -
> if (iscsi_add_lun(&vdev_scsi->luns[lun], iscsi_uri) != 0) {
> return -1;
> }
>