From: Ian Jackson Date: Thu, 7 Jun 2012 18:14:28 +0000 (+0100) Subject: bool cache optional X-Git-Tag: debian/4.1.32~5 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=commitdiff_plain;h=f020ba4ed7c7219e8ac31fd83d32a9f16a34aad0;ds=sidebyside bool cache optional --- 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) {