Skip to content

Commit

Permalink
cocci: extend WRITE_ONCE detection for const script
Browse files Browse the repository at this point in the history
It was suggesting that ctx should be marked const:

  static __always_inline __maybe_unused void
  bpf_clear_meta(struct __sk_buff *ctx)
  {
        __u32 zero = 0;

        WRITE_ONCE(ctx->cb[0], zero);
        WRITE_ONCE(ctx->cb[1], zero);
        WRITE_ONCE(ctx->cb[2], zero);
        WRITE_ONCE(ctx->cb[3], zero);
        WRITE_ONCE(ctx->cb[4], zero);
  }

Extend to cover x->z[...].

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
  • Loading branch information
borkmann committed Aug 25, 2020
1 parent 7fcd46c commit 9af24ee
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions contrib/coccinelle/const.cocci
Expand Up @@ -43,6 +43,7 @@ position p;
when != &x->z
when != e = x
when != WRITE_ONCE(x->z, ...)
when != WRITE_ONCE(x->z[...], ...)
when != f(..., x, ...)
// Special case for the addr field since it's an array in several
// structures.
Expand Down

0 comments on commit 9af24ee

Please sign in to comment.