On 2018-11-23 07:27, Tobias Schramm wrote:
> Signed-off-by: Tobias Schramm <[email protected]>
> ---
>  blobmsg.c | 15 ++++++++++++---
>  blobmsg.h | 40 ++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 52 insertions(+), 3 deletions(-)
> 
> diff --git a/blobmsg.c b/blobmsg.c
> index dd4b506..97a9a0b 100644
> --- a/blobmsg.c
> +++ b/blobmsg.c
> @@ -81,10 +81,14 @@ bool blobmsg_check_attr_safe(const struct blob_attr 
> *attr, bool name, size_t len
>  }
>  
>  int blobmsg_check_array(const struct blob_attr *attr, int type)
> +{
> +     return blobmsg_check_array_safe(attr, type, blob_raw_len(attr));
> +}
Please make this an inline function as well.

> +int blobmsg_check_array_safe(const struct blob_attr *attr, int type, size_t 
> len)
>  {
>       struct blob_attr *cur;
>       bool name;
> -     int rem;
>       int size = 0;
>  
>       switch (blobmsg_type(attr)) {
> @@ -98,11 +102,11 @@ int blobmsg_check_array(const struct blob_attr *attr, 
> int type)
>               return -1;
>       }
>  
> -     blobmsg_for_each_attr(cur, attr, rem) {
> +     __blobmsg_for_each_attr(cur, attr, len) {
>               if (type != BLOBMSG_TYPE_UNSPEC && blobmsg_type(cur) != type)
>                       return -1;
>  
> -             if (!blobmsg_check_attr(cur, name))
> +             if (!blobmsg_check_attr_safe(cur, name, len))
>                       return -1;
>  
>               size++;
I would prefer leaving the blobmsg_for_each_attr block alone and only
adding a blobmsg_check_attr_safe call to the beginning of the function.
That way you can get rid of the custom iterator macro.

Thanks,

- Felix

_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to