diff mbox

[2/4] nvram: add nvram_query_eq()

Message ID 1475038592-24094-2-git-send-email-oohall@gmail.com
State Accepted
Headers show

Commit Message

Oliver O'Halloran Sept. 28, 2016, 4:56 a.m. UTC
Adds a helper that looks for the given NVRAM config string and checks
that associated value is equal to the supplied value.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 core/nvram-format.c | 11 +++++++++++
 include/nvram.h     |  1 +
 2 files changed, 12 insertions(+)

Comments

Stewart Smith Oct. 16, 2016, 11:37 p.m. UTC | #1
Oliver O'Halloran <oohall@gmail.com> writes:
> Adds a helper that looks for the given NVRAM config string and checks
> that associated value is equal to the supplied value.
>
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>

Merged to master as of bdd34cca13be8ac075657b3981f6db91f7dab0ae
diff mbox

Patch

diff --git a/core/nvram-format.c b/core/nvram-format.c
index b98aee1430ff..b110d804ffb7 100644
--- a/core/nvram-format.c
+++ b/core/nvram-format.c
@@ -262,3 +262,14 @@  const char *nvram_query(const char *key)
 
 	return NULL;
 }
+
+
+bool nvram_query_eq(const char *key, const char *value)
+{
+	const char *s = nvram_query(key);
+
+	if (!s)
+		return false;
+
+	return !strcmp(s, value);
+}
diff --git a/include/nvram.h b/include/nvram.h
index d87561d79397..288b536827b5 100644
--- a/include/nvram.h
+++ b/include/nvram.h
@@ -23,5 +23,6 @@  void nvram_reinit(void);
 bool nvram_validate(void);
 
 const char *nvram_query(const char *name);
+bool nvram_query_eq(const char *key, const char *value);
 
 #endif /* __NVRAM_H */