From ee58be50845991361c2e0d0324cc8a2e6ec57049 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 22 Jan 2018 18:10:41 +0100 Subject: bpf: don't use builtin memset/memcpy in bpf_parse_rules bpf_parse_rules is not called in a fast path, so just use the plain memset/memcpy and let the compiler decide whether they should be replaced. Signed-off-by: Tobias Klauser --- bpf.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'bpf.c') diff --git a/bpf.c b/bpf.c index 66d1b6c..868742b 100644 --- a/bpf.c +++ b/bpf.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -710,13 +711,13 @@ void bpf_parse_rules(char *rulefile, struct sock_fprog *bpf, uint32_t link_type) struct sock_filter sf_single = { 0x06, 0, 0, 0xFFFFFFFF }; FILE *fp; - fmemset(bpf, 0, sizeof(*bpf)); + memset(bpf, 0, sizeof(*bpf)); if (rulefile == NULL) { bpf->len = 1; bpf->filter = xmalloc(sizeof(sf_single)); - fmemcpy(&bpf->filter[0], &sf_single, sizeof(sf_single)); + memcpy(&bpf->filter[0], &sf_single, sizeof(sf_single)); return; } @@ -730,16 +731,16 @@ void bpf_parse_rules(char *rulefile, struct sock_fprog *bpf, uint32_t link_type) return; } - fmemset(buff, 0, sizeof(buff)); + memset(buff, 0, sizeof(buff)); while (fgets(buff, sizeof(buff), fp) != NULL) { buff[sizeof(buff) - 1] = 0; if (buff[0] != '{') { - fmemset(buff, 0, sizeof(buff)); + memset(buff, 0, sizeof(buff)); continue; } - fmemset(&sf_single, 0, sizeof(sf_single)); + memset(&sf_single, 0, sizeof(sf_single)); ret = sscanf(buff, "{ 0x%x, %u, %u, 0x%08x },", (unsigned int *) &sf_single.code, (unsigned int *) &sf_single.jt, @@ -752,9 +753,9 @@ void bpf_parse_rules(char *rulefile, struct sock_fprog *bpf, uint32_t link_type) bpf->filter = xrealloc(bpf->filter, bpf->len * sizeof(sf_single)); - fmemcpy(&bpf->filter[bpf->len - 1], &sf_single, + memcpy(&bpf->filter[bpf->len - 1], &sf_single, sizeof(sf_single)); - fmemset(buff, 0, sizeof(buff)); + memset(buff, 0, sizeof(buff)); } if (fp != stdin) -- cgit v1.2.3-54-g00ecf