Blob Blame History Raw
From 8438c244cc2066fbe9c598a6392e8935cf017d97 Mon Sep 17 00:00:00 2001
From: "Gao,Yan" <ygao@suse.com>
Date: Fri, 25 Jun 2021 15:02:14 +0200
Subject: [PATCH] Refactor: sbd-inquisitor: functionize striping leading spaces
 of an option value

---
 src/sbd-inquisitor.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/sbd-inquisitor.c b/src/sbd-inquisitor.c
index 4fec2fd..53ddfa3 100644
--- a/src/sbd-inquisitor.c
+++ b/src/sbd-inquisitor.c
@@ -40,9 +40,8 @@ bool sync_resource_startup = false;
 int parse_device_line(const char *line);
 
 static const char *
-get_env_option(const char *option)
+sanitize_option_value(const char *value)
 {
-	const char *value = getenv(option);
 	size_t max = 0;
 	size_t lpc = 0;
 
@@ -61,6 +60,14 @@ get_env_option(const char *option)
 	return (strlen(value + lpc) > 0 ? (value + lpc) : NULL);
 }
 
+static const char *
+get_env_option(const char *option)
+{
+	const char *value = getenv(option);
+
+	return sanitize_option_value(value);
+}
+
 static int
 recruit_servant(const char *devname, pid_t pid)
 {
-- 
1.8.3.1