examples: Replace use of deprecated symbols
Phil Sutter
reviewerPATCH 1/1 examples: Replace use of deprecated symbols
Do not use unqualified setters to avoid the warnings. Pass a (false) zero length value to nftnl_flowtable_set_data() when assigning to NFTNL_FLOWTABLE_DEVICES as the length value is unused and not even usable. Maybe one should introduce a dedicated nftnl_flowtable_set_devices() at a later point.
--- examples/nft-chain-add.c | 4 ++-- examples/nft-chain-del.c | 4 ++-- examples/nft-chain-get.c | 4 ++-- examples/nft-ct-helper-get.c | 6 +++--- examples/nft-ct-timeout-add.c | 3 ++- examples/nft-ct-timeout-get.c | 6 +++--- examples/nft-flowtable-add.c | 6 +++--- examples/nft-flowtable-del.c | 4 ++-- examples/nft-flowtable-get.c | 4 ++-- examples/nft-obj-get.c | 6 +++--- examples/nft-rule-add.c | 4 ++-- examples/nft-rule-ct-expectation-add.c | 4 ++-- examples/nft-rule-ct-helper-add.c | 4 ++-- examples/nft-rule-ct-timeout-add.c | 4 ++-- examples/nft-rule-del.c | 4 ++-- examples/nft-set-del.c | 4 ++-- examples/nft-set-elem-add.c | 4 ++-- examples/nft-set-elem-del.c | 4 ++-- examples/nft-set-elem-get.c | 4 ++-- examples/nft-table-get.c | 2 +- examples/nft-table-upd.c | 2 +- 21 files changed, 44 insertions(+), 43 deletions(-)
examples/nft-chain-add.c +2 -2
@@ -48,8 +48,8 @@ static struct nftnl_chain *chain_add_parse(int argc, char *argv[])perror ("OOM" );return NULL ; } -nftnl_chain_set (t,NFTNL_CHAIN_TABLE , argv[2 ]); -nftnl_chain_set (t,NFTNL_CHAIN_NAME , argv[3 ]); +nftnl_chain_set_str (t,NFTNL_CHAIN_TABLE , argv[2 ]); +nftnl_chain_set_str (t,NFTNL_CHAIN_NAME , argv[3 ]);if (argc ==6 ) {nftnl_chain_set_u32 (t,NFTNL_CHAIN_HOOKNUM , hooknum);nftnl_chain_set_u32 (t,NFTNL_CHAIN_PRIO ,atoi (argv[5 ]));
examples/nft-chain-del.c +2 -2
@@ -30,8 +30,8 @@ static struct nftnl_chain *chain_del_parse(int argc, char *argv[])return NULL ; } -nftnl_chain_set (t,NFTNL_CHAIN_TABLE , argv[2 ]); -nftnl_chain_set (t,NFTNL_CHAIN_NAME , argv[3 ]); +nftnl_chain_set_str (t,NFTNL_CHAIN_TABLE , argv[2 ]); +nftnl_chain_set_str (t,NFTNL_CHAIN_NAME , argv[3 ]);return t; }
examples/nft-chain-get.c +2 -2
@@ -86,8 +86,8 @@ int main(int argc, char *argv[]) } nlh =nftnl_chain_nlmsg_build_hdr (buf,NFT_MSG_GETCHAIN , family,NLM_F_ACK , seq); -nftnl_chain_set (t,NFTNL_CHAIN_TABLE , argv[2 ]); -nftnl_chain_set (t,NFTNL_CHAIN_NAME , argv[3 ]); +nftnl_chain_set_str (t,NFTNL_CHAIN_TABLE , argv[2 ]); +nftnl_chain_set_str (t,NFTNL_CHAIN_NAME , argv[3 ]);nftnl_chain_nlmsg_build_payload (nlh, t);nftnl_chain_free (t); }else if (argc >=2 ) {
examples/nft-ct-helper-get.c +3 -3
@@ -90,13 +90,13 @@ int main(int argc, char *argv[]) nlh =nftnl_nlmsg_build_hdr (buf,NFT_MSG_GETOBJ , family,NLM_F_DUMP , seq);if (argc ==3 ) { -nftnl_obj_set (t,NFTNL_OBJ_TABLE , argv[2 ]); +nftnl_obj_set_str (t,NFTNL_OBJ_TABLE , argv[2 ]);nftnl_obj_nlmsg_build_payload (nlh, t);nftnl_obj_free (t); } }else { -nftnl_obj_set (t,NFTNL_OBJ_TABLE , argv[2 ]); -nftnl_obj_set (t,NFTNL_OBJ_NAME , argv[3 ]); +nftnl_obj_set_str (t,NFTNL_OBJ_TABLE , argv[2 ]); +nftnl_obj_set_str (t,NFTNL_OBJ_NAME , argv[3 ]); nlh =nftnl_nlmsg_build_hdr (buf,NFT_MSG_GETOBJ , family,NLM_F_ACK , seq);
examples/nft-ct-timeout-add.c +2 -1
@@ -71,7 +71,8 @@ static struct nftnl_obj *obj_add_parse(int argc, char *argv[])nftnl_obj_set_str (t,NFTNL_OBJ_NAME , argv[3 ]);nftnl_obj_set_u8 (t,NFTNL_OBJ_CT_TIMEOUT_L4PROTO , l4proto);nftnl_obj_set_u16 (t,NFTNL_OBJ_CT_TIMEOUT_L3PROTO ,NFPROTO_IPV4 ); -nftnl_obj_set (t,NFTNL_OBJ_CT_TIMEOUT_ARRAY , timeout); +nftnl_obj_set_data (t,NFTNL_OBJ_CT_TIMEOUT_ARRAY , + timeout, timeout_array_size);return t; }
examples/nft-ct-timeout-get.c +3 -3
@@ -89,13 +89,13 @@ int main(int argc, char *argv[]) nlh =nftnl_nlmsg_build_hdr (buf,NFT_MSG_GETOBJ , family,NLM_F_DUMP , seq);if (argc ==3 ) { -nftnl_obj_set (t,NFTNL_OBJ_TABLE , argv[2 ]); +nftnl_obj_set_str (t,NFTNL_OBJ_TABLE , argv[2 ]);nftnl_obj_nlmsg_build_payload (nlh, t);nftnl_obj_free (t); } }else { -nftnl_obj_set (t,NFTNL_OBJ_TABLE , argv[2 ]); -nftnl_obj_set (t,NFTNL_OBJ_NAME , argv[3 ]); +nftnl_obj_set_str (t,NFTNL_OBJ_TABLE , argv[2 ]); +nftnl_obj_set_str (t,NFTNL_OBJ_NAME , argv[3 ]); nlh =nftnl_nlmsg_build_hdr (buf,NFT_MSG_GETOBJ , family,NLM_F_ACK , seq);
examples/nft-flowtable-add.c +3 -3
@@ -27,13 +27,13 @@ static struct nftnl_flowtable *flowtable_add_parse(int argc, char *argv[])perror ("OOM" );return NULL ; } -nftnl_flowtable_set (t,NFTNL_FLOWTABLE_TABLE , argv[2 ]); -nftnl_flowtable_set (t,NFTNL_FLOWTABLE_NAME , argv[3 ]); +nftnl_flowtable_set_str (t,NFTNL_FLOWTABLE_TABLE , argv[2 ]); +nftnl_flowtable_set_str (t,NFTNL_FLOWTABLE_NAME , argv[3 ]);if (argc ==6 ) {nftnl_flowtable_set_u32 (t,NFTNL_FLOWTABLE_HOOKNUM , hooknum);nftnl_flowtable_set_u32 (t,NFTNL_FLOWTABLE_PRIO ,atoi (argv[5 ])); } -nftnl_flowtable_set (t,NFTNL_FLOWTABLE_DEVICES , dev_array); +nftnl_flowtable_set_data (t,NFTNL_FLOWTABLE_DEVICES , dev_array,0 );return t; }
examples/nft-flowtable-del.c +2 -2
@@ -19,8 +19,8 @@ static struct nftnl_flowtable *flowtable_del_parse(int argc, char *argv[])return NULL ; } -nftnl_flowtable_set (t,NFTNL_FLOWTABLE_TABLE , argv[2 ]); -nftnl_flowtable_set (t,NFTNL_FLOWTABLE_NAME , argv[3 ]); +nftnl_flowtable_set_str (t,NFTNL_FLOWTABLE_TABLE , argv[2 ]); +nftnl_flowtable_set_str (t,NFTNL_FLOWTABLE_NAME , argv[3 ]);return t; }
examples/nft-flowtable-get.c +2 -2
@@ -75,8 +75,8 @@ int main(int argc, char *argv[]) } nlh =nftnl_flowtable_nlmsg_build_hdr (buf,NFT_MSG_GETFLOWTABLE , family,NLM_F_ACK , seq); -nftnl_flowtable_set (t,NFTNL_FLOWTABLE_TABLE , argv[2 ]); -nftnl_flowtable_set (t,NFTNL_FLOWTABLE_NAME , argv[3 ]); +nftnl_flowtable_set_str (t,NFTNL_FLOWTABLE_TABLE , argv[2 ]); +nftnl_flowtable_set_str (t,NFTNL_FLOWTABLE_NAME , argv[3 ]);nftnl_flowtable_nlmsg_build_payload (nlh, t);nftnl_flowtable_free (t); }else if (argc >=2 ) {
examples/nft-obj-get.c +3 -3
@@ -89,13 +89,13 @@ int main(int argc, char *argv[]) nlh =nftnl_nlmsg_build_hdr (buf,NFT_MSG_GETOBJ , family,NLM_F_DUMP , seq);if (argc ==3 ) { -nftnl_obj_set (t,NFTNL_OBJ_TABLE , argv[2 ]); +nftnl_obj_set_str (t,NFTNL_OBJ_TABLE , argv[2 ]);nftnl_obj_nlmsg_build_payload (nlh, t);nftnl_obj_free (t); } }else { -nftnl_obj_set (t,NFTNL_OBJ_TABLE , argv[2 ]); -nftnl_obj_set (t,NFTNL_OBJ_NAME , argv[3 ]); +nftnl_obj_set_str (t,NFTNL_OBJ_TABLE , argv[2 ]); +nftnl_obj_set_str (t,NFTNL_OBJ_NAME , argv[3 ]);nftnl_obj_set_u32 (t,NFTNL_OBJ_TYPE ,NFT_OBJECT_COUNTER ); nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_GETOBJ, family,
examples/nft-rule-add.c +2 -2
@@ -93,8 +93,8 @@ static struct nftnl_rule *setup_rule(uint8_t family, const char *table,exit (EXIT_FAILURE ); } -nftnl_rule_set (r,NFTNL_RULE_TABLE , table); -nftnl_rule_set (r,NFTNL_RULE_CHAIN , chain); +nftnl_rule_set_str (r,NFTNL_RULE_TABLE , table); +nftnl_rule_set_str (r,NFTNL_RULE_CHAIN , chain);nftnl_rule_set_u32 (r,NFTNL_RULE_FAMILY , family);if (handle !=NULL ) {
examples/nft-rule-ct-expectation-add.c +2 -2
@@ -69,8 +69,8 @@ static struct nftnl_rule *setup_rule(uint8_t family, const char *table,exit (EXIT_FAILURE ); } -nftnl_rule_set (r,NFTNL_RULE_TABLE , table); -nftnl_rule_set (r,NFTNL_RULE_CHAIN , chain); +nftnl_rule_set_str (r,NFTNL_RULE_TABLE , table); +nftnl_rule_set_str (r,NFTNL_RULE_CHAIN , chain);nftnl_rule_set_u32 (r,NFTNL_RULE_FAMILY , family);if (handle !=NULL ) {
examples/nft-rule-ct-helper-add.c +2 -2
@@ -56,8 +56,8 @@ static struct nftnl_rule *setup_rule(uint8_t family, const char *table,exit (EXIT_FAILURE ); } -nftnl_rule_set (r,NFTNL_RULE_TABLE , table); -nftnl_rule_set (r,NFTNL_RULE_CHAIN , chain); +nftnl_rule_set_str (r,NFTNL_RULE_TABLE , table); +nftnl_rule_set_str (r,NFTNL_RULE_CHAIN , chain);nftnl_rule_set_u32 (r,NFTNL_RULE_FAMILY , family);if (handle !=NULL ) {
examples/nft-rule-ct-timeout-add.c +2 -2
@@ -56,8 +56,8 @@ static struct nftnl_rule *setup_rule(uint8_t family, const char *table,exit (EXIT_FAILURE ); } -nftnl_rule_set (r,NFTNL_RULE_TABLE , table); -nftnl_rule_set (r,NFTNL_RULE_CHAIN , chain); +nftnl_rule_set_str (r,NFTNL_RULE_TABLE , table); +nftnl_rule_set_str (r,NFTNL_RULE_CHAIN , chain);nftnl_rule_set_u32 (r,NFTNL_RULE_FAMILY , family);if (handle !=NULL ) {
examples/nft-rule-del.c +2 -2
@@ -58,8 +58,8 @@ int main(int argc, char *argv[]) } seq =time (NULL ); -nftnl_rule_set (r,NFTNL_RULE_TABLE , argv[2 ]); -nftnl_rule_set (r,NFTNL_RULE_CHAIN , argv[3 ]); +nftnl_rule_set_str (r,NFTNL_RULE_TABLE , argv[2 ]); +nftnl_rule_set_str (r,NFTNL_RULE_CHAIN , argv[3 ]);/* If no handle is specified, delete all rules in the chain */ if (argc ==5 )
examples/nft-set-del.c +2 -2
@@ -63,8 +63,8 @@ int main(int argc, char *argv[]) nlh =nftnl_set_nlmsg_build_hdr (mnl_nlmsg_batch_current (batch),NFT_MSG_DELSET , family,NLM_F_ACK , seq); -nftnl_set_set (t,NFTNL_SET_TABLE , argv[2 ]); -nftnl_set_set (t,NFTNL_SET_NAME , argv[3 ]); +nftnl_set_set_str (t,NFTNL_SET_TABLE , argv[2 ]); +nftnl_set_set_str (t,NFTNL_SET_NAME , argv[3 ]);nftnl_set_nlmsg_build_payload (nlh, t);nftnl_set_free (t);
examples/nft-set-elem-add.c +2 -2
@@ -57,8 +57,8 @@ int main(int argc, char *argv[])exit (EXIT_FAILURE ); } -nftnl_set_set (s,NFTNL_SET_TABLE , argv[2 ]); -nftnl_set_set (s,NFTNL_SET_NAME , argv[3 ]); +nftnl_set_set_str (s,NFTNL_SET_TABLE , argv[2 ]); +nftnl_set_set_str (s,NFTNL_SET_NAME , argv[3 ]);/* Add to dummy elements to set */ e =nftnl_set_elem_alloc ();
examples/nft-set-elem-del.c +2 -2
@@ -55,8 +55,8 @@ int main(int argc, char *argv[])exit (EXIT_FAILURE ); } -nftnl_set_set (s,NFTNL_SET_TABLE , argv[2 ]); -nftnl_set_set (s,NFTNL_SET_NAME , argv[3 ]); +nftnl_set_set_str (s,NFTNL_SET_TABLE , argv[2 ]); +nftnl_set_set_str (s,NFTNL_SET_NAME , argv[3 ]);/* Add to dummy elements to set */ e =nftnl_set_elem_alloc ();
examples/nft-set-elem-get.c +2 -2
@@ -81,8 +81,8 @@ int main(int argc, char *argv[]) nlh =nftnl_set_nlmsg_build_hdr (buf,NFT_MSG_GETSETELEM , family,NLM_F_DUMP |NLM_F_ACK , seq); -nftnl_set_set (t,NFTNL_SET_NAME , argv[3 ]); -nftnl_set_set (t,NFTNL_SET_TABLE , argv[2 ]); +nftnl_set_set_str (t,NFTNL_SET_NAME , argv[3 ]); +nftnl_set_set_str (t,NFTNL_SET_TABLE , argv[2 ]);nftnl_set_elems_nlmsg_build_payload (nlh, t);nftnl_set_free (t);
examples/nft-table-get.c +1 -1
@@ -91,7 +91,7 @@ int main(int argc, char *argv[]) }else { nlh =nftnl_table_nlmsg_build_hdr (buf,NFT_MSG_GETTABLE , family,NLM_F_ACK , seq); -nftnl_table_set (t,NFTNL_TABLE_NAME , argv[2 ]); +nftnl_table_set_str (t,NFTNL_TABLE_NAME , argv[2 ]);nftnl_table_nlmsg_build_payload (nlh, t);nftnl_table_free (t); }
examples/nft-table-upd.c +1 -1
@@ -72,7 +72,7 @@ int main(int argc, char *argv[])exit (EXIT_FAILURE ); } -nftnl_table_set (t,NFTNL_TABLE_NAME , argv[2 ]); +nftnl_table_set_str (t,NFTNL_TABLE_NAME , argv[2 ]);nftnl_table_set_u32 (t,NFTNL_TABLE_FLAGS , flags); table_seq = seq;
Signature · 1 line
2.24.0
Quoted 8 lines · Phil Sutter
Do not use unqualified setters to avoid the warnings. Pass a (false) zero length value to
nftnl_flowtable_set_data()when assigning toNFTNL_FLOWTABLE_DEVICESas the length value is unused and not even usable. Maybe one should introduce a dedicatednftnl_flowtable_set_devices()at a later point.Fixes 7349a70634fa0 ("Deprecate untyped data setters")Signed-off-by Phil Sutter <[email protected]>
Quoted 9 lines · Phil Sutter
Do not use unqualified setters to avoid the warnings. Pass a (false) zero length value to
nftnl_flowtable_set_data()when assigning toNFTNL_FLOWTABLE_DEVICESas the length value is unused and not even usable. Maybe one should introduce a dedicatednftnl_flowtable_set_devices()at a later point.Fixes 7349a70634fa0 ("Deprecate untyped data setters")Signed-off-by Phil Sutter <[email protected]>---
Thanks, I saw them too.