X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=cprogs%2Fxacpi-simple.c;h=eb761a290635ca85ab8f80db11b6d26444c26dca;hb=f020ba4ed7c7219e8ac31fd83d32a9f16a34aad0;hp=73bea7f508973b40338751e7888ec435db4a095e;hpb=2c56327e902fac7d700897e5e8bcc7d6d5e78411;p=chiark-utils.git 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) {