[Mesa-dev] [PATCH] swr/rast: Fix GetEnv() returned value
Eric Engestrom
eric.engestrom at imgtec.com
Mon Sep 18 10:37:08 UTC 2017
On Monday, 2017-09-18 11:10:39 +0200, Laurent Carlier wrote:
> Return an empty string instead of a NULL pointer.
> Patch from Bernhard Rosenkraenzer.
I guess attributing the patch to him in git would be nice too:
From: Bernhard Rosenkraenzer <bero at lindev.ch>
>
> https://bugs.freedesktop.org/show_bug.cgi?id=101832
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101832
Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>
I could've sworn I had already seen this patch on the ML though?
> Fixes: a25093de718 ("swr/rast: Implement JIT shader caching to disk")
> ---
> src/gallium/drivers/swr/rasterizer/core/utils.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/swr/rasterizer/core/utils.h b/src/gallium/drivers/swr/rasterizer/core/utils.h
> index b096d2120c..3c849e82d3 100644
> --- a/src/gallium/drivers/swr/rasterizer/core/utils.h
> +++ b/src/gallium/drivers/swr/rasterizer/core/utils.h
> @@ -365,7 +365,8 @@ static INLINE std::string GetEnv(const std::string& variableName)
> output.resize(valueSize - 1); // valueSize includes null, output.resize() does not
> GetEnvironmentVariableA(variableName.c_str(), &output[0], valueSize);
> #else
> - output = getenv(variableName.c_str());
> + char *o = getenv(variableName.c_str());
> + output = o ? std::string(o) : std::string();
I think this can be simplified, but I'm not fussed about it:
output = o ? o : "";
`o` could have a better name too (eg. `env`), but again, I don't care
that much :P
> #endif
>
> return output;
> --
> 2.14.1
>
More information about the mesa-dev
mailing list