From 8a914f32e2dfaff7f23002502ba64a2abb2a4a50 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Tue, 28 May 2019 06:51:52 +0530 Subject: scsi: target/iscsi: fix possible condition with no effect (if == else) Fix the following warning reported by coccicheck: drivers/target/iscsi/iscsi_target_nego.c:175:6-8: WARNING: possible condition with no effect (if == else) Signed-off-by: Hariprasad Kelam Reviewed-by: David Disseldorp Signed-off-by: Martin K. Petersen --- drivers/target/iscsi/iscsi_target_nego.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'drivers/target') diff --git a/drivers/target/iscsi/iscsi_target_nego.c b/drivers/target/iscsi/iscsi_target_nego.c index 8a5e8d17a942..92ce2fd05fdd 100644 --- a/drivers/target/iscsi/iscsi_target_nego.c +++ b/drivers/target/iscsi/iscsi_target_nego.c @@ -160,22 +160,11 @@ static u32 iscsi_handle_authentication( if (strstr("None", authtype)) return 1; -#ifdef CANSRP - else if (strstr("SRP", authtype)) - return srp_main_loop(conn, auth, in_buf, out_buf, - &in_length, out_length); -#endif else if (strstr("CHAP", authtype)) return chap_main_loop(conn, auth, in_buf, out_buf, &in_length, out_length); - else if (strstr("SPKM1", authtype)) - return 2; - else if (strstr("SPKM2", authtype)) - return 2; - else if (strstr("KRB5", authtype)) - return 2; - else - return 2; + /* SRP, SPKM1, SPKM2 and KRB5 are unsupported */ + return 2; } static void iscsi_remove_failed_auth_entry(struct iscsi_conn *conn) -- cgit v1.2.3-59-g8ed1b From 22c2f35f49d474fa093b227253941980886d7b1b Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Sun, 16 Jun 2019 09:02:20 +0200 Subject: scsi: tcmu: Simplify tcmu_update_uio_info() Use 'kasprintf()' instead of: - snprintf(NULL, 0... - kmalloc(... - snprintf(... This is less verbose and saves 7 bytes (i.e. the space for '/(null)') if 'udev->dev_config' is NULL. Signed-off-by: Christophe JAILLET Acked-by: Mike Christie Signed-off-by: Martin K. Petersen --- drivers/target/target_core_user.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'drivers/target') diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index 40b29ca5a98d..9dbd0db64328 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -1836,20 +1836,18 @@ static int tcmu_update_uio_info(struct tcmu_dev *udev) { struct tcmu_hba *hba = udev->hba->hba_ptr; struct uio_info *info; - size_t size, used; char *str; info = &udev->uio_info; - size = snprintf(NULL, 0, "tcm-user/%u/%s/%s", hba->host_id, udev->name, - udev->dev_config); - size += 1; /* for \0 */ - str = kmalloc(size, GFP_KERNEL); - if (!str) - return -ENOMEM; - used = snprintf(str, size, "tcm-user/%u/%s", hba->host_id, udev->name); if (udev->dev_config[0]) - snprintf(str + used, size - used, "/%s", udev->dev_config); + str = kasprintf(GFP_KERNEL, "tcm-user/%u/%s/%s", hba->host_id, + udev->name, udev->dev_config); + else + str = kasprintf(GFP_KERNEL, "tcm-user/%u/%s", hba->host_id, + udev->name); + if (!str) + return -ENOMEM; /* If the old string exists, free it */ kfree(info->name); -- cgit v1.2.3-59-g8ed1b