Re: [libnftnl PATCH 2/2] src: expr: log: Do not print unset values in xml.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 29 May 2014 13:26, Ana Rey <anarey@xxxxxxxxx> wrote:
> It changes the parse and the snprint functions to omit unset values.
>

Hi Ana,

I like your patches. A minor comment below.

> @@ -209,32 +209,25 @@ static int nft_rule_expr_log_xml_parse(struct nft_rule_expr *e,
>
>         prefix = nft_mxml_str_parse(tree, "prefix", MXML_DESCEND_FIRST,
>                                     NFT_XML_MAND, err);
> -       if (prefix == NULL)
> -               return -1;
> -
> -       log->prefix = strdup(prefix);
> -       e->flags |= (1 << NFT_EXPR_LOG_PREFIX);
> +       if (prefix != NULL) {
> +               log->prefix = strdup(prefix);
> +               e->flags |= (1 << NFT_EXPR_LOG_PREFIX);
> +       }
>

I guess it's time to switch here to nft_expr_attr_set_*() functions.
It was my fault to not use the shortcuts.
I think shortcuts are less error prone and save some lines of code.

Like the JSON parsing code:

if (prefix != NULL)
  nft_rule_expr_set_str(e, NFT_EXPR_LOG_PREFIX, prefix);

BTW, looking at how JSON does it [0], there the prefix element is
mandatory. I think we need to be consistent in both formats, so I
would recommend an additional patch to make prefix optional in the
JSON parser.

regards.

[0] http://git.netfilter.org/libnftnl/tree/src/expr/log.c#n171
-- 
Arturo Borrero González
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux