The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Roland Dreier <rdreier@cisco.com>
To: linux-kernel@vger.kernel.org,
	"Nicholas A. Bellinger" <nab@linux-iscsi.org>
Subject: [PATCH] [SCSI] target: Remove unneeded test of se_cmd
Date: Sat, 15 Jan 2011 21:46:31 -0800	[thread overview]
Message-ID: <adazkr1z9hk.fsf@cisco.com> (raw)

se_cmd is dereferenced unconditionally in many other parts of
transport_get_lun_for_cmd() so remove the last test whether se_cmd is NULL.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
---
I'm not 100% sure of this patch (perhaps se_cmd can be NULL here and the
whole rest of the function needs to be fixed instead), but this seems
like the more sensible thing.

 drivers/target/target_core_device.c |   22 +++++++++-------------
 1 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index 317ce58..d94933d 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -69,21 +69,17 @@ int transport_get_lun_for_cmd(
 	deve = se_cmd->se_deve =
 			&SE_NODE_ACL(se_sess)->device_list[unpacked_lun];
 	if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) {
-		if (se_cmd) {
-			deve->total_cmds++;
-			deve->total_bytes += se_cmd->data_length;
-
-			if (se_cmd->data_direction == DMA_TO_DEVICE) {
-				if (deve->lun_flags &
-						TRANSPORT_LUNFLAGS_READ_ONLY) {
-					read_only = 1;
-					goto out;
-				}
-				deve->write_bytes += se_cmd->data_length;
-			} else if (se_cmd->data_direction ==
-				   DMA_FROM_DEVICE) {
-				deve->read_bytes += se_cmd->data_length;
+		deve->total_cmds++;
+		deve->total_bytes += se_cmd->data_length;
+
+		if (se_cmd->data_direction == DMA_TO_DEVICE) {
+			if (deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY) {
+				read_only = 1;
+				goto out;
 			}
+			deve->write_bytes += se_cmd->data_length;
+		} else if (se_cmd->data_direction == DMA_FROM_DEVICE) {
+			deve->read_bytes += se_cmd->data_length;
 		}
 		deve->deve_cmds++;
 

             reply	other threads:[~2011-01-16  5:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-16  5:46 Roland Dreier [this message]
2011-01-16  7:12 ` [PATCH] [SCSI] target: Remove unneeded test of se_cmd Nicholas A. Bellinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=adazkr1z9hk.fsf@cisco.com \
    --to=rdreier@cisco.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nab@linux-iscsi.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox