Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Oct 2014 12:02:28 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r273543 - head/usr.sbin/ctld
Message-ID:  <201410231202.s9NC2SRB002287@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Thu Oct 23 12:02:27 2014
New Revision: 273543
URL: https://svnweb.freebsd.org/changeset/base/273543

Log:
  Clean up (refactor) discovery a little; no functional changes.
  
  MFC after:	1 month
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/usr.sbin/ctld/discovery.c

Modified: head/usr.sbin/ctld/discovery.c
==============================================================================
--- head/usr.sbin/ctld/discovery.c	Thu Oct 23 11:12:27 2014	(r273542)
+++ head/usr.sbin/ctld/discovery.c	Thu Oct 23 12:02:27 2014	(r273543)
@@ -160,7 +160,7 @@ logout_new_response(struct pdu *request)
 }
 
 static void
-discovery_add_target(struct keys *response_keys, struct target *targ)
+discovery_add_target(struct keys *response_keys, const struct target *targ)
 {
 	struct portal *portal;
 	char *buf;
@@ -206,9 +206,12 @@ discovery(struct connection *conn)
 {
 	struct pdu *request, *response;
 	struct keys *request_keys, *response_keys;
-	struct target *targ;
+	const struct portal_group *pg;
+	const struct target *targ;
 	const char *send_targets;
 
+	pg = conn->conn_portal->p_portal_group;
+
 	log_debugx("beginning discovery session; waiting for Text PDU");
 	request = text_receive(conn);
 	request_keys = keys_new();
@@ -222,11 +225,8 @@ discovery(struct connection *conn)
 	response_keys = keys_new();
 
 	if (strcmp(send_targets, "All") == 0) {
-		TAILQ_FOREACH(targ,
-		    &conn->conn_portal->p_portal_group->pg_conf->conf_targets,
-		    t_next) {
-			if (targ->t_portal_group !=
-			    conn->conn_portal->p_portal_group) {
+		TAILQ_FOREACH(targ, &pg->pg_conf->conf_targets, t_next) {
+			if (targ->t_portal_group != pg) {
 				log_debugx("not returning target \"%s\"; "
 				    "belongs to a different portal group",
 				    targ->t_name);
@@ -235,8 +235,7 @@ discovery(struct connection *conn)
 			discovery_add_target(response_keys, targ);
 		}
 	} else {
-		targ = target_find(conn->conn_portal->p_portal_group->pg_conf,
-		    send_targets);
+		targ = target_find(pg->pg_conf, send_targets);
 		if (targ == NULL) {
 			log_debugx("initiator requested information on unknown "
 			    "target \"%s\"; returning nothing", send_targets);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201410231202.s9NC2SRB002287>