From f01827a469fa34f0ffb65e2e1401c4e362b0c5f4 Mon Sep 17 00:00:00 2001 From: Tim Rowley Date: Tue, 19 Jul 2016 12:51:46 -0600 Subject: [PATCH] swr: [rasterizer core] allow hexadecimal for integer knobs Signed-off-by: Tim Rowley --- src/gallium/drivers/swr/rasterizer/core/knobs_init.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/swr/rasterizer/core/knobs_init.h b/src/gallium/drivers/swr/rasterizer/core/knobs_init.h index adf738c1bed..ba2df2292f0 100644 --- a/src/gallium/drivers/swr/rasterizer/core/knobs_init.h +++ b/src/gallium/drivers/swr/rasterizer/core/knobs_init.h @@ -38,7 +38,9 @@ template static inline void ConvertEnvToKnob(const char* pOverride, T& knobValue) { uint32_t value = 0; - if (sscanf(pOverride, "%u", &value)) + char* pStopped = nullptr; + value = strtoul(pOverride, &pStopped, 0); + if (pStopped != pOverride) { knobValue = static_cast(value); } @@ -64,10 +66,11 @@ static inline void ConvertEnvToKnob(const char* pOverride, bool& knobValue) // Try converting to a number and casting to bool uint32_t value = 0; - if (sscanf(pOverride, "%u", &value)) + char* pStopped = nullptr; + value = strtoul(pOverride, &pStopped, 0); + if (pStopped != pOverride) { knobValue = value != 0; - return; } } -- 2.30.2