Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve diagnostics for failed static_assert! #274

Closed
ojeda opened this issue May 17, 2021 · 1 comment
Closed

Improve diagnostics for failed static_assert! #274

ojeda opened this issue May 17, 2021 · 1 comment
Labels
• lib Related to the `rust/` library.

Comments

@ojeda
Copy link
Member

ojeda commented May 17, 2021

From #269 (comment):

One small nit though: when the static assertion fails, the build error is very cryptic. It's not immediately obvious what has happened.

const MY_ERRNO: u32 = 40000;
static_assert!((-(MY_ERRNO as i128)) fits in i16);
error: any use of this value will cause an error
   --> rust/kernel/static_assert.rs:129:23
    |
129 |         const _: () = [()][!($condition) as usize];
    |         --------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
    |                       |
    |                       index out of bounds: the length is 1 but the index is 1
    | 
   ::: rust/kernel/error.rs:113:1
    |
113 | static_assert!((-(MY_ERRNO as i128)) fits in i16);
    | -------------------------------------------------- in this macro invocation
    |
    = note: `#[deny(const_err)]` on by default
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
@alex
Copy link
Member

alex commented May 25, 2022

This should be done by #778

@alex alex closed this as completed May 25, 2022
ojeda pushed a commit that referenced this issue Jul 8, 2024
Add test coverage for reservations beyond the ring buffer size in order
to validate that bpf_ringbuf_reserve() rejects the request with NULL, all
other ring buffer tests keep passing as well:

  # ./vmtest.sh -- ./test_progs -t ringbuf
  [...]
  ./test_progs -t ringbuf
  [    1.165434] bpf_testmod: loading out-of-tree module taints kernel.
  [    1.165825] bpf_testmod: module verification failed: signature and/or required key missing - tainting kernel
  [    1.284001] tsc: Refined TSC clocksource calibration: 3407.982 MHz
  [    1.286871] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x311fc34e357, max_idle_ns: 440795379773 ns
  [    1.289555] clocksource: Switched to clocksource tsc
  #274/1   ringbuf/ringbuf:OK
  #274/2   ringbuf/ringbuf_n:OK
  #274/3   ringbuf/ringbuf_map_key:OK
  #274/4   ringbuf/ringbuf_write:OK
  #274     ringbuf:OK
  #275     ringbuf_multi:OK
  [...]

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
[ Test fixups for getting BPF CI back to work ]
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20240621140828.18238-2-daniel@iogearbox.net
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
• lib Related to the `rust/` library.
Development

No branches or pull requests

2 participants