From f020ba4ed7c7219e8ac31fd83d32a9f16a34aad0 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 7 Jun 2012 19:14:28 +0100 Subject: [PATCH] bool cache optional --- cprogs/xacpi-simple.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cprogs/xacpi-simple.c b/cprogs/xacpi-simple.c index 73bea7f..eb761a2 100644 --- a/cprogs/xacpi-simple.c +++ b/cprogs/xacpi-simple.c @@ -531,9 +531,11 @@ static const char *getresource(const char *want) { } static int getresource_bool(const char *want, int def, int *cache) { - /* *cache should be initialised to -1 and will be set to !!value */ + /* *cache should be initialised to -1 and will be set to !!value + * alternatively cache==0 is allowed */ + + if (cache && *cache >= 0) return *cache; - if (*cache >= 0) return *cache; const char *str= getresource(want); int result = def; if (str && str[0]) { @@ -549,7 +551,9 @@ static int getresource_bool(const char *want, int def, int *cache) { } } } - return *cache= result; + + if (cache) *cache= result; + return result; } static void more_resources(const char *str, const char *why) { -- 2.30.2