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

Clippy ptrarg v3 #10339

Closed
wants to merge 3 commits into from
Closed

Conversation

catenacyber
Copy link
Contributor

Link to redmine ticket:
None

Describe changes:

  • fix clippy newest warnings
  • fix cocci FP

#10337 with cocci fix

error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
   --> src/dns/log.rs:371:29
    |
371 | pub fn dns_print_addr(addr: &Vec<u8>) -> std::string::String {
    |                             ^^^^^^^^ help: change this to: `&[u8]`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
@catenacyber catenacyber requested review from victorjulien, jasonish and a team as code owners February 8, 2024 19:22
The caller needs to check for NULL
as is done for HttpMultiBufHeaderThreadDataInit
@@ -58,6 +58,8 @@ FAIL_IF(x == NULL)
FAIL_IF(unlikely(x == NULL))
|
FAIL_IF_NULL(x)
|
return x;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cocci cannot however detect if the caller does indeed check that value, so this could miss some things?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyways, I think its this fix to cocci or make cocci happy with a superfluous return check which may trigger other linters: d3cc5d8

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should fix CI tooling because the code is good.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't tell if this is a fix, or just makes cocci more permissive.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't tell if this is a fix, or just makes cocci more permissive.

It is making it more permissive. Cocci, as far as I can tell does not have the ability to jump to callers of this function and validate the return check there. So wrappers like this need superfluous checks, or this more permissive Cocci check. At least in my observation so far.

Copy link

codecov bot commented Feb 8, 2024

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (80abc22) 82.32% compared to head (c6cc798) 82.32%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10339      +/-   ##
==========================================
- Coverage   82.32%   82.32%   -0.01%     
==========================================
  Files         978      978              
  Lines      272142   272143       +1     
==========================================
- Hits       224053   224050       -3     
- Misses      48089    48093       +4     
Flag Coverage Δ
fuzzcorpus 63.59% <66.66%> (+<0.01%) ⬆️
suricata-verify 61.47% <66.66%> (-0.02%) ⬇️
unittests 62.83% <11.11%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Copy link
Member

@jasonish jasonish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK on visual review. Cocci would fail on the realloc, so it makes sense that is part of the same PR.

@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline 18252

@suricata-qa
Copy link

Information:

field baseline test %
TREX_GENERIC_stats_chk
.capture.kernel_drops 0 320 0.00

Pipeline 18257

Copy link
Member

@victorjulien victorjulien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not willing to make cocci more relaxed for this edge case

@catenacyber
Copy link
Contributor Author

Replaced by #10345 a bit sad that we made dummy changes to the code instead of fixing the tool

@catenacyber catenacyber closed this Feb 9, 2024
@jasonish
Copy link
Member

jasonish commented Feb 9, 2024

Replaced by #10345 a bit sad that we made dummy changes to the code instead of fixing the tool

Are scan-build or some other clang based analysis up to the challenge of making sure allocations are checked before use? Essentially grepping for the usage pattern seems a little ancient :)

@victorjulien
Copy link
Member

Replaced by #10345 a bit sad that we made dummy changes to the code instead of fixing the tool

Are scan-build or some other clang based analysis up to the challenge of making sure allocations are checked before use? Essentially grepping for the usage pattern seems a little ancient :)

Easy to test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants