1 From 78d52a28c66ad0fd2af250038fdcf4239ad37bf2 Mon Sep 17 00:00:00 2001
2 From: Remi NGUYEN VAN <remi.nguyenvan+openwrt@gmail.com>
3 Date: Sat, 15 Aug 2020 13:50:27 +0900
4 Subject: [PATCH] options: fix parsing of boolean attributes
6 Boolean attributes were parsed the same way as string attributes,
7 so a value of { "bool_attr": "true" } would be parsed correctly, but
8 { "bool_attr": true } (without quotes) was parsed as false.
12 Signed-off-by: Remi NGUYEN VAN <remi.nguyenvan+openwrt@gmail.com>
15 1 file changed, 6 insertions(+)
19 @@ -1170,6 +1170,9 @@ fw3_parse_blob_options(void *s, const st
20 if (blobmsg_type(e) == BLOBMSG_TYPE_INT32) {
21 snprintf(buf, sizeof(buf), "%d", blobmsg_get_u32(e));
23 + } else if (blobmsg_type(o) == BLOBMSG_TYPE_BOOL) {
24 + snprintf(buf, sizeof(buf), "%d", blobmsg_get_bool(o));
27 v = blobmsg_get_string(e);
29 @@ -1189,6 +1192,9 @@ fw3_parse_blob_options(void *s, const st
30 if (blobmsg_type(o) == BLOBMSG_TYPE_INT32) {
31 snprintf(buf, sizeof(buf), "%d", blobmsg_get_u32(o));
33 + } else if (blobmsg_type(o) == BLOBMSG_TYPE_BOOL) {
34 + snprintf(buf, sizeof(buf), "%d", blobmsg_get_bool(o));
37 v = blobmsg_get_string(o);