include: include <string.h> in <nft.h>
PATCH 1/1 include: include <string.h> in <nft.h>
<string.h> provides strcmp(), as such it's very basic and used everywhere.
Include it via <nft.h>.
The benefit of this will be to add a static-inline function nft_strcmp0() to <nft.h>, which calls strcmp() but handles that strings might be NULL. Such a basic utility will be useful, and <nft.h> is the right place. So we will need <string.h> there. Regardless of that, not including the same header basically everywhere, is already a benefit.
--- include/cache.h | 2 -- include/nft.h | 1 + include/rule.h | 1 - src/cli.c | 1 - src/cmd.c | 1 - src/ct.c | 1 - src/datatype.c | 1 - src/erec.c | 1 - src/evaluate.c | 1 - src/expression.c | 1 - src/exthdr.c | 1 - src/fib.c | 1 - src/gmputil.c | 1 - src/iface.c | 1 - src/json.c | 1 - src/libnftables.c | 1 - src/main.c | 1 - src/meta.c | 1 - src/mini-gmp.c | 1 - src/misspell.c | 1 - src/mnl.c | 1 - src/monitor.c | 1 - src/netlink.c | 1 - src/netlink_delinearize.c | 1 - src/netlink_linearize.c | 1 - src/nfnl_osf.c | 1 - src/nftutils.c | 1 - src/optimize.c | 1 - src/osf.c | 1 - src/parser_json.c | 1 - src/payload.c | 1 - src/proto.c | 1 - src/rt.c | 1 - src/rule.c | 1 - src/sctp_chunk.c | 1 - src/segtree.c | 1 - src/statement.c | 1 - src/tcpopt.c | 1 - src/utils.c | 1 - src/xfrm.c | 1 - src/xt.c | 1 - 41 files changed, 1 insertion(+), 41 deletions(-)
include/cache.h +0 -2
@@ -1,8 +1,6 @@#ifndef _NFT_CACHE_H_#define _NFT_CACHE_H_ -#include <string.h> -#include <list.h> struct handle ;
include/nft.h +1 -0
@@ -7,5 +7,6 @@#include <stdbool.h> #include <stdint.h> #include <stdlib.h> +#include <string.h> #endif /* NFTABLES_NFT_H */
include/rule.h +0 -1
@@ -6,7 +6,6 @@#include <netinet/in.h> #include <libnftnl/object.h> /* For NFTNL_CTTIMEOUT_ARRAY_MAX. */ #include <linux/netfilter/nf_tables.h> -#include <string.h> #include <cache.h> /**
src/cli.c +0 -1
@@ -18,7 +18,6 @@#include <stdarg.h> #include <unistd.h> #include <errno.h> -#include <string.h> #include <ctype.h> #include <limits.h> #ifdef HAVE_LIBREADLINE
src/cmd.c +0 -1
@@ -16,7 +16,6 @@#include <iface.h> #include <errno.h> #include <cache.h> -#include <string.h> void cmd_add_loc (struct cmd *cmd,uint16_t offset,const struct location *loc) {
src/ct.c +0 -1
@@ -15,7 +15,6 @@#include <stddef.h> #include <stdio.h> #include <inttypes.h> -#include <string.h> #include <netinet/ip.h> #include <linux/netfilter.h>
src/datatype.c +0 -1
@@ -10,7 +10,6 @@#include <nft.h> -#include <string.h> #include <inttypes.h> #include <ctype.h> /* isdigit */ #include <errno.h>
src/erec.c +0 -1
@@ -11,7 +11,6 @@#include <nft.h> #include <stdio.h> -#include <string.h> #include <stdarg.h> #include <netlink.h>
src/evaluate.c +0 -1
@@ -12,7 +12,6 @@#include <stddef.h> #include <stdio.h> -#include <string.h> #include <arpa/inet.h> #include <linux/netfilter.h> #include <linux/netfilter_arp.h>
src/expression.c +0 -1
@@ -12,7 +12,6 @@#include <stddef.h> #include <stdio.h> -#include <string.h> #include <limits.h> #include <expression.h>
src/exthdr.c +0 -1
@@ -14,7 +14,6 @@#include <stddef.h> #include <stdio.h> -#include <string.h> #include <netinet/in.h> #include <netinet/ip6.h>
src/fib.c +0 -1
@@ -16,7 +16,6 @@#include <datatype.h> #include <gmputil.h> #include <utils.h> -#include <string.h> #include <fib.h> #include <linux/rtnetlink.h>
src/gmputil.c +0 -1
@@ -14,7 +14,6 @@#include <stdarg.h> #include <stdio.h> #include <unistd.h> -#include <string.h> #include <nftables.h> #include <datatype.h>
src/iface.c +0 -1
@@ -11,7 +11,6 @@#include <stdio.h> #include <net/if.h> #include <time.h> -#include <string.h> #include <errno.h> #include <libmnl/libmnl.h>
src/json.c +0 -1
@@ -9,7 +9,6 @@#include <nft.h> #include <stdio.h> -#include <string.h> #include <expression.h> #include <list.h>
src/libnftables.c +0 -1
@@ -16,7 +16,6 @@#include <iface.h> #include <cmd.h> #include <errno.h> -#include <string.h> static int nft_netlink (struct nft_ctx *nft,struct list_head *cmds,struct list_head *msgs)
src/main.c +0 -1
@@ -14,7 +14,6 @@#include <unistd.h> #include <stdio.h> #include <errno.h> -#include <string.h> #include <getopt.h> #include <fcntl.h> #include <sys/types.h>
src/meta.c +0 -1
@@ -16,7 +16,6 @@#include <limits.h> #include <stddef.h> #include <stdio.h> -#include <string.h> #include <net/if.h> #include <net/if_arp.h> #include <pwd.h>
src/mini-gmp.c +0 -1
@@ -47,7 +47,6 @@ see https://www.gnu.org/licenses/. */#include <ctype.h> #include <limits.h> #include <stdio.h> -#include <string.h> #include "mini-gmp.h"
src/misspell.c +0 -1
@@ -8,7 +8,6 @@#include <nft.h> -#include <string.h> #include <limits.h> #include <utils.h> #include <misspell.h>
src/mnl.c +0 -1
@@ -29,7 +29,6 @@#include <mnl.h> #include <cmd.h> -#include <string.h> #include <net/if.h> #include <sys/socket.h> #include <arpa/inet.h>
src/monitor.c +0 -1
@@ -8,7 +8,6 @@#include <nft.h> -#include <string.h> #include <fcntl.h> #include <errno.h> #include <libmnl/libmnl.h>
src/netlink.c +0 -1
@@ -11,7 +11,6 @@#include <nft.h> -#include <string.h> #include <errno.h> #include <libmnl/libmnl.h> #include <netinet/in.h>
src/netlink_delinearize.c +0 -1
@@ -11,7 +11,6 @@#include <nft.h> -#include <string.h> #include <limits.h> #include <linux/netfilter/nf_tables.h> #include <arpa/inet.h>
src/netlink_linearize.c +0 -1
@@ -14,7 +14,6 @@#include <linux/netfilter/nf_tables.h> #include <linux/netfilter/nf_log.h> -#include <string.h> #include <rule.h> #include <statement.h> #include <expression.h>
src/nfnl_osf.c +0 -1
@@ -25,7 +25,6 @@#include <ctype.h> #include <errno.h> -#include <string.h> #include <time.h> #include <netinet/ip.h>
src/nftutils.c +0 -1
@@ -5,7 +5,6 @@#include "nftutils.h" #include <netdb.h> -#include <string.h> /* Buffer size used for getprotobynumber_r() and similar. The manual comments * that a buffer of 1024 should be sufficient "for most applications"(??), so
src/optimize.c +0 -1
@@ -13,7 +13,6 @@#include <nft.h> -#include <string.h> #include <errno.h> #include <inttypes.h> #include <nftables.h>
src/osf.c +0 -1
@@ -11,7 +11,6 @@#include <nftables.h> #include <expression.h> #include <utils.h> -#include <string.h> #include <osf.h> #include <json.h>
src/parser_json.c +0 -1
@@ -9,7 +9,6 @@#include <nft.h> #include <errno.h> -#include <string.h> #include <syslog.h> #include <erec.h>
src/payload.c +0 -1
@@ -14,7 +14,6 @@#include <stddef.h> #include <stdio.h> -#include <string.h> #include <net/if_arp.h> #include <arpa/inet.h> #include <linux/netfilter.h>
src/proto.c +0 -1
@@ -12,7 +12,6 @@#include <nft.h> #include <stddef.h> -#include <string.h> #include <net/if_arp.h> #include <arpa/inet.h> #include <linux/netfilter.h>
src/rt.c +0 -1
@@ -13,7 +13,6 @@#include <errno.h> #include <stddef.h> #include <stdio.h> -#include <string.h> #include <arpa/inet.h> #include <linux/netfilter.h>
src/rule.c +0 -1
@@ -12,7 +12,6 @@#include <stddef.h> #include <stdio.h> -#include <string.h> #include <inttypes.h> #include <errno.h>
src/sctp_chunk.c +0 -1
@@ -11,7 +11,6 @@#include <exthdr.h> #include <sctp_chunk.h> -#include <string.h> #define PHT (__token, __offset, __len) \ PROTO_HDR_TEMPLATE(__token, &integer_type, BYTEORDER_BIG_ENDIAN, \
src/segtree.c +0 -1
@@ -10,7 +10,6 @@#include <nft.h> -#include <string.h> #include <inttypes.h> #include <arpa/inet.h>
src/statement.c +0 -1
@@ -13,7 +13,6 @@#include <stddef.h> #include <stdio.h> #include <inttypes.h> -#include <string.h> #include <syslog.h> #include <rule.h>
src/tcpopt.c +0 -1
@@ -2,7 +2,6 @@#include <stddef.h> #include <stdio.h> -#include <string.h> #include <netinet/in.h> #include <netinet/ip6.h> #include <netinet/tcp.h>
src/utils.c +0 -1
@@ -14,7 +14,6 @@#include <stdarg.h> #include <stdio.h> #include <unistd.h> -#include <string.h> #include <nftables.h> #include <utils.h>
src/xfrm.c +0 -1
@@ -17,7 +17,6 @@#include <datatype.h> #include <gmputil.h> #include <utils.h> -#include <string.h> #include <netinet/ip.h> #include <linux/netfilter.h>
src/xt.c +0 -1
@@ -10,7 +10,6 @@#include <nft.h> #include <time.h> -#include <string.h> #include <net/if.h> #include <getopt.h> #include <ctype.h> /* for isspace */
Signature · 1 line
2.41.0
Quoted 10 lines · Thomas Haller
<
string.h> providesstrcmp(), as such it's very basic and used everywhere.Include it via <
nft.h>.The benefit of this will be to add a static-inline function
nft_strcmp0()to <nft.h>, which callsstrcmp()but handles that strings might be NULL. Such a basic utility will be useful, and <nft.h> is the right place. So we will need <string.h> there. Regardless of that, not including the same header basically everywhere, is already a benefit.
Applied, thanks