All of lore.kernel.org
 help / color / mirror / Atom feed
From: Justin Mitchell <jumitche@redhat.com>
To: Steve Dickson <steved@redhat.com>
Cc: linux-nfs <linux-nfs@vger.kernel.org>, Bruce Fields <bfields@redhat.com>
Subject: [PATCH 2/7] nfs-utils: Merge conf_get_str and conf_get_section
Date: Wed, 13 Sep 2017 15:01:46 +0100	[thread overview]
Message-ID: <1505311306.15819.23.camel@redhat.com> (raw)
In-Reply-To: <1505311126.15819.20.camel@redhat.com>

conf_get_section() started as conf_get_str() with one extra search
parameter, subsequent patches have not maintained feature parity,
combine the code to make a single more generic function and just call
that differently where required.

Signed-off-by: Justin Mitchell <jumitche@redhat.com>
---
 support/nfs/conffile.c | 36 ++++++++++++++----------------------
 1 file changed, 14 insertions(+), 22 deletions(-)

diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
index 4323fbb..8239d66 100644
--- a/support/nfs/conffile.c
+++ b/support/nfs/conffile.c
@@ -636,28 +636,9 @@ conf_match_num(const char *section, const char *tag, int x)
 char *
 conf_get_str(const char *section, const char *tag)
 {
-	struct conf_binding *cb;
-retry:
-	cb = LIST_FIRST (&conf_bindings[conf_hash (section)]);
-	for (; cb; cb = LIST_NEXT (cb, link)) {
-		if (strcasecmp (section, cb->section) == 0
-		    && strcasecmp (tag, cb->tag) == 0) {
-			if (cb->value[0] == '$') {
-				/* expand $name from [environment] section,
-				 * or from environment
-				 */
-				char *env = getenv(cb->value+1);
-				if (env && *env)
-					return env;
-				section = "environment";
-				tag = cb->value + 1;
-				goto retry;
-			}
-			return cb->value;
-		}
-	}
-	return 0;
+	return conf_get_section(section, NULL, tag);
 }
+
 /*
  * Find a section that may or may not have an argument
  */
@@ -665,7 +646,7 @@ char *
 conf_get_section(const char *section, const char *arg, const char *tag)
 {
 	struct conf_binding *cb;
-
+retry:
 	cb = LIST_FIRST (&conf_bindings[conf_hash (section)]);
 	for (; cb; cb = LIST_NEXT (cb, link)) {
 		if (strcasecmp(section, cb->section) != 0)
@@ -674,6 +655,17 @@ conf_get_section(const char *section, const char *arg, const char *tag)
 			continue;
 		if (strcasecmp(tag, cb->tag) != 0)
 			continue;
+		if (cb->value[0] == '$') {
+			/* expand $name from [environment] section,
+			 * or from environment
+			 */
+			char *env = getenv(cb->value+1);
+			if (env && *env)
+				return env;
+			section = "environment";
+			tag = cb->value + 1;
+			goto retry;
+		}
 		return cb->value;
 	}
 	return 0;
-- 
1.8.3.1




  parent reply	other threads:[~2017-09-13 14:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-13 13:58 [PATCH 0/7] nfs-utils: Merge libnfsidmap tree with nfs-utils Justin Mitchell
2017-09-13 14:00 ` [PATCH 1/7] nfs-utils: const-ify the config handling functions Justin Mitchell
2017-09-13 14:01 ` Justin Mitchell [this message]
2017-09-13 14:02 ` [PATCH 3/7] nfs-utils: Add get_str with default value Justin Mitchell
2017-09-13 14:03 ` [PATCH 4/7] nfs-utils: split conffile to a separate convenience lib Justin Mitchell
2017-09-13 14:06 ` [PATCH 6/7] nfs-utils: integrate libnfsidmap code with rest of nfs-utils Justin Mitchell
2017-09-13 14:06 ` [PATCH 7/7] nfs-utils: cleanup warnings from merged libnfsidmap code Justin Mitchell
2017-09-13 15:29 ` [PATCH 0/7] nfs-utils: Merge libnfsidmap tree with nfs-utils J. Bruce Fields
     [not found] ` <1505311491.15819.27.camel@redhat.com>
     [not found]   ` <0c78c3e5-0ec8-1dcf-e608-77693596097d@RedHat.com>
2017-09-13 15:58     ` [PATCH 5/7] nfs-utils: Import libnfsidmap codebase Justin Mitchell
  -- strict thread matches above, loose matches on Subject: below --
2017-09-14 14:02 [PATCH 0/7] nfs-utils: Merge libnfsidmap tree with nfs-utils UPDATED Justin Mitchell
2017-09-14 14:03 ` [PATCH 2/7] nfs-utils: Merge conf_get_str and conf_get_section Justin Mitchell
2017-08-30 11:51 [PATCH 0/7] Move nfs.conf to a shared library Justin Mitchell
2017-08-30 11:54 ` [PATCH 2/7] nfs-utils: Merge conf_get_str and conf_get_section Justin Mitchell

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=1505311306.15819.23.camel@redhat.com \
    --to=jumitche@redhat.com \
    --cc=bfields@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=steved@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.