mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-11 03:31:36 +00:00
CLEANUP: sample: Use explicit return for successful json_query
s
Move the `return 1` into each of the cases, instead of relying on the single `return 1` at the bottom of the function.
This commit is contained in:
parent
8f3bc8ffca
commit
3b9cdf1cb7
37
src/sample.c
37
src/sample.c
@ -3739,26 +3739,30 @@ static int sample_conv_json_query(const struct arg *args, struct sample *smp, vo
|
||||
return 0;
|
||||
|
||||
smp->data.type = SMP_T_SINT;
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
double double_val;
|
||||
|
||||
if (mjson_get_number(smp->data.u.str.area, smp->data.u.str.data, args[0].data.str.area, &double_val) == 0) {
|
||||
if (mjson_get_number(smp->data.u.str.area, smp->data.u.str.data, args[0].data.str.area, &double_val) == 0)
|
||||
return 0;
|
||||
} else {
|
||||
trash->data = snprintf(trash->area,trash->size,"%g",double_val);
|
||||
smp->data.u.str = *trash;
|
||||
smp->data.type = SMP_T_STR;
|
||||
}
|
||||
|
||||
trash->data = snprintf(trash->area,trash->size,"%g",double_val);
|
||||
smp->data.u.str = *trash;
|
||||
smp->data.type = SMP_T_STR;
|
||||
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case MJSON_TOK_TRUE:
|
||||
smp->data.type = SMP_T_BOOL;
|
||||
smp->data.u.sint = 1;
|
||||
break;
|
||||
|
||||
return 1;
|
||||
case MJSON_TOK_FALSE:
|
||||
smp->data.type = SMP_T_BOOL;
|
||||
smp->data.u.sint = 0;
|
||||
break;
|
||||
|
||||
return 1;
|
||||
case MJSON_TOK_STRING: {
|
||||
int len;
|
||||
|
||||
@ -3767,12 +3771,13 @@ static int sample_conv_json_query(const struct arg *args, struct sample *smp, vo
|
||||
if (len == -1) {
|
||||
/* invalid string */
|
||||
return 0;
|
||||
} else {
|
||||
trash->data = len;
|
||||
smp->data.u.str = *trash;
|
||||
smp->data.type = SMP_T_STR;
|
||||
}
|
||||
break;
|
||||
|
||||
trash->data = len;
|
||||
smp->data.u.str = *trash;
|
||||
smp->data.type = SMP_T_STR;
|
||||
|
||||
return 1;
|
||||
}
|
||||
case MJSON_TOK_NULL:
|
||||
case MJSON_TOK_ARRAY:
|
||||
@ -3789,7 +3794,9 @@ static int sample_conv_json_query(const struct arg *args, struct sample *smp, vo
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
||||
my_unreachable();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user