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

Check type cast results #381

Open
geyslan opened this issue Sep 28, 2023 · 0 comments
Open

Check type cast results #381

geyslan opened this issue Sep 28, 2023 · 0 comments
Labels
good first issue Good for newcomers

Comments

@geyslan
Copy link
Member

geyslan commented Sep 28, 2023

It's important to check type cast results to avoid panic.

Revive unchecked-type-assertion rule provided this output:

make lint-check
Linting golang code...
Error: rwArray_test.go:74:8: type cast result is unchecked in a.get(uint(i)).(*int) - type assertion will panic if not matched
Error: libbpfgo.go:1254:16: type cast result is unchecked in eventChannels.get(rb.slot).(chan []byte) - type assertion will panic if not matched
Error: helpers/kernel_symbols_test.go:65:11: type cast result is unchecked in syms.(*lazyKernelSymbols) - type assertion will panic if not matched
Error: helpers/kernel_config.go:359:14: type cast result is unchecked in k.configs[option].(KernelConfigOptionValue) - type assertion will panic if not matched
make: *** [Makefile:237: lint-check] Error 1

After solved, unchecked-type-assertion should be re-enabled:

https://github.com/roikol/libbpfgo/blob/2def7dd7296bf450e0cfd188863d303fcab7aab0/.revive.toml#L131-L132

Context: 2def7dd

@geyslan geyslan added the good first issue Good for newcomers label Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant