From fa14c28cee14c5f1e3eba4b1d425f19791df0dce Mon Sep 17 00:00:00 2001 From: "ethan.du" Date: Thu, 16 Apr 2020 15:14:12 +0800 Subject: [PATCH] bugfix_get_int8 --- uiot/utils/json_token.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/uiot/utils/json_token.c b/uiot/utils/json_token.c index 9261e83..d2ffab4 100644 --- a/uiot/utils/json_token.c +++ b/uiot/utils/json_token.c @@ -146,15 +146,14 @@ int LITE_get_int16(int16_t *value, char *src) { */ int LITE_get_int8(int8_t *value, char *src) { int16_t temp = 0; - if(1 != sscanf(src, "%" SCNi16, temp)) + if(1 != sscanf(src, "%" SCNi16, &temp)) { return FAILURE_RET; } - value = (int8_t)temp; + *value = (int8_t)temp; return SUCCESS_RET; } - int LITE_get_uint32(uint32_t *value, char *src) { return (sscanf(src, "%" SCNu32, value) == 1) ? SUCCESS_RET : FAILURE_RET; } @@ -165,11 +164,11 @@ int LITE_get_uint16(uint16_t *value, char *src) { int LITE_get_uint8(uint8_t *value, char *src) { uint16_t temp = 0; - if(1 != sscanf(src, "%" SCNu16, temp)) + if(1 != sscanf(src, "%" SCNu16, &temp)) { return FAILURE_RET; } - value = (uint8_t)temp; + *value = (uint8_t)temp; return SUCCESS_RET; }