Skip to content

Commit

Permalink
chore(bpf): remove memset in _READ() macros
Browse files Browse the repository at this point in the history
The `bpf_probe_read_kernel` / `bpf_probe_read_user` perform memset
to zero in case they fail.  Avoid duplication and safe few insns.

Co-authored-by: Federico Di Pierro <[email protected]>
Signed-off-by: Hendrik Brueckner <[email protected]>
  • Loading branch information
2 people authored and poiana committed Feb 6, 2023
1 parent 88b93cc commit 7133250
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions driver/bpf/plumbing_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ or GPL2.txt for full copies of the license.
#include "builtins.h"

#define _READ(P) ({ typeof(P) _val; \
memset(&_val, 0, sizeof(_val)); \
bpf_probe_read_kernel(&_val, sizeof(_val), &P); \
_val; \
})
#define _READ_KERNEL(P) _READ(P)
#define _READ_USER(P) ({ typeof(P) _val; \
memset(&_val, 0, sizeof(_val)); \
bpf_probe_read_user(&_val, sizeof(_val), &P); \
_val; \
})
Expand Down

0 comments on commit 7133250

Please sign in to comment.