Code refactoring in nft_rule_expr_byteorder_snprintf_* functions to get a nft_rule_expr type instead of nft_expr_byorder type. Signed-off-by: Ana Rey <anarey@xxxxxxxxx> --- src/expr/byteorder.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/expr/byteorder.c b/src/expr/byteorder.c index 4889e80..e42d7b6 100644 --- a/src/expr/byteorder.c +++ b/src/expr/byteorder.c @@ -296,10 +296,10 @@ nft_rule_expr_byteorder_xml_parse(struct nft_rule_expr *e, mxml_node_t *tree, #endif } -static int -nft_rule_expr_byteorder_snprintf_json(char *buf, size_t size, - struct nft_expr_byteorder *byteorder) +static int nft_rule_expr_byteorder_snprintf_json(char *buf, size_t size, + struct nft_rule_expr *e) { + struct nft_expr_byteorder *byteorder = nft_expr_data(e); int len = size, offset = 0, ret; ret = snprintf(buf, len, "\"sreg\":%u," @@ -315,10 +315,10 @@ nft_rule_expr_byteorder_snprintf_json(char *buf, size_t size, return offset; } -static int -nft_rule_expr_byteorder_snprintf_xml(char *buf, size_t size, - struct nft_expr_byteorder *byteorder) +static int nft_rule_expr_byteorder_snprintf_xml(char *buf, size_t size, + struct nft_rule_expr *e) { + struct nft_expr_byteorder *byteorder = nft_expr_data(e); int len = size, offset = 0, ret; ret = snprintf(buf, len, "<sreg>%u</sreg>" @@ -334,10 +334,10 @@ nft_rule_expr_byteorder_snprintf_xml(char *buf, size_t size, return offset; } -static int -nft_rule_expr_byteorder_snprintf_default(char *buf, size_t size, - struct nft_expr_byteorder *byteorder) +static int nft_rule_expr_byteorder_snprintf_default(char *buf, size_t size, + struct nft_rule_expr *e) { + struct nft_expr_byteorder *byteorder = nft_expr_data(e); int len = size, offset = 0, ret; ret = snprintf(buf, len, "reg %u = %s(reg %u, %u, %u) ", @@ -350,20 +350,15 @@ nft_rule_expr_byteorder_snprintf_default(char *buf, size_t size, static int nft_rule_expr_byteorder_snprintf(char *buf, size_t size, uint32_t type, - uint32_t flags, struct nft_rule_expr *e) + uint32_t flags, struct nft_rule_expr *e) { - struct nft_expr_byteorder *byteorder = nft_expr_data(e); - switch(type) { case NFT_OUTPUT_DEFAULT: - return nft_rule_expr_byteorder_snprintf_default(buf, size, - byteorder); + return nft_rule_expr_byteorder_snprintf_default(buf, size, e); case NFT_OUTPUT_XML: - return nft_rule_expr_byteorder_snprintf_xml(buf, size, - byteorder); + return nft_rule_expr_byteorder_snprintf_xml(buf, size, e); case NFT_OUTPUT_JSON: - return nft_rule_expr_byteorder_snprintf_json(buf, size, - byteorder); + return nft_rule_expr_byteorder_snprintf_json(buf, size, e); default: break; } -- 2.0.0 -- 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