Message ID | 20200815045027.919125-1-remi.nguyenvan+openwrt@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | options: fix parsing of boolean attributes | expand |
I see this is getting mixed with other patches, so to be clear this is a patch for firewall3 (see https://bugs.openwrt.org/index.php?do=details&task_id=3284). Let me know if there is a better place to post this. Le sam. 15 août 2020 à 13:50, <remi.nguyenvan@gmail.com> a écrit : > > From: Remi NGUYEN VAN <remi.nguyenvan+openwrt@gmail.com> > > Boolean attributes were parsed the same way as string attributes, > so a value of { "bool_attr": "true" } would be parsed correctly, but > { "bool_attr": true } (without quotes) was parsed as false. > > Fixes FS#3284 > > Signed-off-by: Remi NGUYEN VAN <remi.nguyenvan+openwrt@gmail.com> > --- > options.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/options.c b/options.c > index aed0cfb..6131786 100644 > --- a/options.c > +++ b/options.c > @@ -1170,6 +1170,9 @@ fw3_parse_blob_options(void *s, const struct fw3_option *opts, > if (blobmsg_type(e) == BLOBMSG_TYPE_INT32) { > snprintf(buf, sizeof(buf), "%d", blobmsg_get_u32(e)); > v = buf; > + } else if (blobmsg_type(o) == BLOBMSG_TYPE_BOOL) { > + snprintf(buf, sizeof(buf), "%d", blobmsg_get_bool(o)); > + v = buf; > } else { > v = blobmsg_get_string(e); > } > @@ -1189,6 +1192,9 @@ fw3_parse_blob_options(void *s, const struct fw3_option *opts, > if (blobmsg_type(o) == BLOBMSG_TYPE_INT32) { > snprintf(buf, sizeof(buf), "%d", blobmsg_get_u32(o)); > v = buf; > + } else if (blobmsg_type(o) == BLOBMSG_TYPE_BOOL) { > + snprintf(buf, sizeof(buf), "%d", blobmsg_get_bool(o)); > + v = buf; > } else { > v = blobmsg_get_string(o); > } > -- > 2.28.0.220.ged08abb693-goog >
On 19/08/2020 21:34, Rémi NGUYEN VAN wrote: > I see this is getting mixed with other patches, so to be clear this is > a patch for firewall3 (see > https://bugs.openwrt.org/index.php?do=details&task_id=3284). > Let me know if there is a better place to post this. Use "[PATCH] fw3: <rest of subject line>" (or "firewall3: ...") as the subject when sending the patch, and try to ensure the firewall3 maintainers, if any, are copied (email CC). You get that information from previous patches to firewall3 (look at the commit logs in git that touch the firewall3 directories) and from firewall3's OpenWrt Makefile. That enhances the selected visibility of the patch to the people who would act on it faster. It is also the best-practice on most of the FLOSS codebases that are complex enough to have several maintainers, subsystems, or components (examples are "git" itself, the Linux kernel, and OpenWrt :-) ). Also, since there is a bug report open about it, it is a good idea to attach the patch there. This helps ensure it won't be lost, although hopefully it will be acted upon soon enough. Please consider re-sending the patch with the subject line change I suggested (and the extra CCs to firewall3 maintainers) if nobody replies to you about it in the next two or three days.
Merged into project/firewall3.git, branch master at http://git.openwrt.org/?p=project/firewall3.git. Thank you!
diff --git a/options.c b/options.c index aed0cfb..6131786 100644 --- a/options.c +++ b/options.c @@ -1170,6 +1170,9 @@ fw3_parse_blob_options(void *s, const struct fw3_option *opts, if (blobmsg_type(e) == BLOBMSG_TYPE_INT32) { snprintf(buf, sizeof(buf), "%d", blobmsg_get_u32(e)); v = buf; + } else if (blobmsg_type(o) == BLOBMSG_TYPE_BOOL) { + snprintf(buf, sizeof(buf), "%d", blobmsg_get_bool(o)); + v = buf; } else { v = blobmsg_get_string(e); } @@ -1189,6 +1192,9 @@ fw3_parse_blob_options(void *s, const struct fw3_option *opts, if (blobmsg_type(o) == BLOBMSG_TYPE_INT32) { snprintf(buf, sizeof(buf), "%d", blobmsg_get_u32(o)); v = buf; + } else if (blobmsg_type(o) == BLOBMSG_TYPE_BOOL) { + snprintf(buf, sizeof(buf), "%d", blobmsg_get_bool(o)); + v = buf; } else { v = blobmsg_get_string(o); }