[RFC PATCH 3/5] config API: add a config_origin_type_name() helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a config_origin_type_name() helper function. In a subsequent
commit we'll want to invoke this part of current_config_origin_type()
without requiring the global "current_config_kvi" or "cf" state.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
---
 config.c | 25 +++++++++++++++----------
 config.h |  6 ++++++
 2 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/config.c b/config.c
index a4105c456c3..a65e7bb36d3 100644
--- a/config.c
+++ b/config.c
@@ -3766,17 +3766,8 @@ int parse_config_key(const char *var,
 	return 0;
 }
 
-const char *current_config_origin_type(void)
+const char *config_origin_type_name(enum config_origin_type type)
 {
-	enum config_origin_type type;
-
-	if (current_config_kvi)
-		type = current_config_kvi->origin_type;
-	else if(cf)
-		type = cf->origin_type;
-	else
-		BUG("current_config_origin_type called outside config callback");
-
 	switch (type) {
 	case CONFIG_ORIGIN_BLOB:
 		return "blob";
@@ -3793,6 +3784,20 @@ const char *current_config_origin_type(void)
 	}
 }
 
+const char *current_config_origin_type(void)
+{
+	enum config_origin_type type;
+
+	if (current_config_kvi)
+		type = current_config_kvi->origin_type;
+	else if(cf)
+		type = cf->origin_type;
+	else
+		BUG("current_config_origin_type called outside config callback");
+
+	return config_origin_type_name(type);
+}
+
 const char *config_scope_name(enum config_scope scope)
 {
 	switch (scope) {
diff --git a/config.h b/config.h
index 571b92d674a..a9cb01e9405 100644
--- a/config.h
+++ b/config.h
@@ -117,6 +117,12 @@ struct key_value_info {
 	enum config_scope scope;
 };
 
+/**
+ * Given the "enum config_origin_type origin_type"
+ * (e.g. CONFIG_ORIGIN_BLOB) return a string (e.g. "blob").
+ */
+const char *config_origin_type_name(enum config_origin_type type);
+
 /**
  * A config callback function takes three parameters:
  *
-- 
2.40.0.rc1.1034.g5867a1b10c5




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux