From owner-svn-src-all@FreeBSD.ORG Wed Oct 29 09:36:04 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2E2E3D52; Wed, 29 Oct 2014 09:36:04 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 10E5CC3E; Wed, 29 Oct 2014 09:36:04 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9T9a3QZ028163; Wed, 29 Oct 2014 09:36:03 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9T9a39F028158; Wed, 29 Oct 2014 09:36:03 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201410290936.s9T9a39F028158@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Wed, 29 Oct 2014 09:36:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r273816 - head/usr.sbin/ctld X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Oct 2014 09:36:04 -0000 Author: trasz Date: Wed Oct 29 09:36:02 2014 New Revision: 273816 URL: https://svnweb.freebsd.org/changeset/base/273816 Log: Simplify code; no functional changes. MFC after: 1 month Sponsored by: The FreeBSD Foundation Modified: head/usr.sbin/ctld/ctld.c head/usr.sbin/ctld/ctld.h head/usr.sbin/ctld/parse.y Modified: head/usr.sbin/ctld/ctld.c ============================================================================== --- head/usr.sbin/ctld/ctld.c Wed Oct 29 09:32:36 2014 (r273815) +++ head/usr.sbin/ctld/ctld.c Wed Oct 29 09:36:02 2014 (r273816) @@ -522,25 +522,10 @@ auth_group_find(const struct conf *conf, return (NULL); } -static int -auth_group_set_type(struct auth_group *ag, int type) -{ - - if (ag->ag_type == AG_TYPE_UNKNOWN) { - ag->ag_type = type; - return (0); - } - - if (ag->ag_type == type) - return (0); - - return (1); -} - int -auth_group_set_type_str(struct auth_group *ag, const char *str) +auth_group_set_type(struct auth_group *ag, const char *str) { - int error, type; + int type; if (strcmp(str, "none") == 0) { type = AG_TYPE_NO_AUTHENTICATION; @@ -560,20 +545,22 @@ auth_group_set_type_str(struct auth_grou return (1); } - error = auth_group_set_type(ag, type); - if (error != 0) { - if (ag->ag_name != NULL) + if (ag->ag_type != AG_TYPE_UNKNOWN && ag->ag_type != type) { + if (ag->ag_name != NULL) { log_warnx("cannot set auth-type to \"%s\" for " "auth-group \"%s\"; already has a different " "type", str, ag->ag_name); - else + } else { log_warnx("cannot set auth-type to \"%s\" for target " "\"%s\"; already has a different type", str, ag->ag_target->t_name); + } return (1); } - return (error); + ag->ag_type = type; + + return (0); } static struct portal * @@ -979,25 +966,10 @@ isns_deregister(struct isns *isns) set_timeout(0, false); } -static int -portal_group_set_filter(struct portal_group *pg, int filter) -{ - - if (pg->pg_discovery_filter == PG_FILTER_UNKNOWN) { - pg->pg_discovery_filter = filter; - return (0); - } - - if (pg->pg_discovery_filter == filter) - return (0); - - return (1); -} - int -portal_group_set_filter_str(struct portal_group *pg, const char *str) +portal_group_set_filter(struct portal_group *pg, const char *str) { - int error, filter; + int filter; if (strcmp(str, "none") == 0) { filter = PG_FILTER_NONE; @@ -1015,15 +987,17 @@ portal_group_set_filter_str(struct porta return (1); } - error = portal_group_set_filter(pg, filter); - if (error != 0) { + if (pg->pg_discovery_filter != PG_FILTER_UNKNOWN && + pg->pg_discovery_filter != filter) { log_warnx("cannot set discovery-filter to \"%s\" for " "portal-group \"%s\"; already has a different " "value", str, pg->pg_name); return (1); } - return (error); + pg->pg_discovery_filter = filter; + + return (0); } static bool Modified: head/usr.sbin/ctld/ctld.h ============================================================================== --- head/usr.sbin/ctld/ctld.h Wed Oct 29 09:32:36 2014 (r273815) +++ head/usr.sbin/ctld/ctld.h Wed Oct 29 09:36:02 2014 (r273816) @@ -266,7 +266,7 @@ struct auth_group *auth_group_new(struct void auth_group_delete(struct auth_group *ag); struct auth_group *auth_group_find(const struct conf *conf, const char *name); -int auth_group_set_type_str(struct auth_group *ag, +int auth_group_set_type(struct auth_group *ag, const char *type); const struct auth *auth_new_chap(struct auth_group *ag, @@ -299,7 +299,7 @@ struct portal_group *portal_group_find(c const char *name); int portal_group_add_listen(struct portal_group *pg, const char *listen, bool iser); -int portal_group_set_filter_str(struct portal_group *pg, +int portal_group_set_filter(struct portal_group *pg, const char *filter); int isns_new(struct conf *conf, const char *addr); Modified: head/usr.sbin/ctld/parse.y ============================================================================== --- head/usr.sbin/ctld/parse.y Wed Oct 29 09:32:36 2014 (r273815) +++ head/usr.sbin/ctld/parse.y Wed Oct 29 09:36:02 2014 (r273816) @@ -238,7 +238,7 @@ auth_group_auth_type: AUTH_TYPE STR { int error; - error = auth_group_set_type_str(auth_group, $2); + error = auth_group_set_type(auth_group, $2); free($2); if (error != 0) return (1); @@ -358,7 +358,7 @@ portal_group_discovery_filter: DISCOVERY { int error; - error = portal_group_set_filter_str(portal_group, $2); + error = portal_group_set_filter(portal_group, $2); free($2); if (error != 0) return (1); @@ -480,7 +480,7 @@ target_auth_type: AUTH_TYPE STR } target->t_auth_group->ag_target = target; } - error = auth_group_set_type_str(target->t_auth_group, $2); + error = auth_group_set_type(target->t_auth_group, $2); free($2); if (error != 0) return (1);