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

Use #[expect(…)] instead of #[allow(…)], remove unnecessary allows #2784

Merged
merged 28 commits into from
Dec 20, 2024

Conversation

riesentoaster
Copy link
Contributor

#[expect(…)] returns a lint warning (configured to be an error) if the lint warning is not present without the attribute.

This also means I was able to remove a lot of allow statements.

I suggest in the future, expect is used wherever possible. The only exceptions I've stumbled across are when they are used in a macro and only appear for some macro calls (think trivial_numeric_casts of a u64 to a type passed to the struct, and it is called for u64 among others) and if the warning only appears in certain cfgs.

@domenukk
Copy link
Member

Feel free to fix this for all build targets - but it might be a world of pain :)

@riesentoaster
Copy link
Contributor Author

I did some more, but I'll leave the rest to someone else.

@riesentoaster
Copy link
Contributor Author

Also: I cannot guarantee that I haven't broken anything. I've manually checked as much as possible and the CI found stuff as well, but I may have still missed some cfg-dependent stuff (there's a lot in there lol). On the upside, I've only touched linting-related things. So if anyone's computer starts complaining, it's easy to just re-add the warning or change it back from an expect to an allow.

Comment on lines 114 to 117

# start manager in background, then start one client
timeout 32s ./${FUZZER_NAME} --cores 0 --input ./corpus 2>/dev/null &
timeout 31s ./${FUZZER_NAME} --cores 1 --input ./corpus | tee fuzz_stdout.log 2>/dev/null || true
Copy link
Contributor Author

@riesentoaster riesentoaster Dec 20, 2024

Choose a reason for hiding this comment

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

I added this, otherwise the test doesn't pass. Doesn't either on main btw.

And a few other very small tidbits here and there. Just tidying things with as little change to the logic as possible.

Copy link
Member

Choose a reason for hiding this comment

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

Weird, how was this not caught before?

Copy link
Member

Choose a reason for hiding this comment

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

Does it still not work now that you fixed the Opt parser btw?

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've reverted the change. Most likely something to do with the unwanted code changes. No idea what happened there lol.

@riesentoaster
Copy link
Contributor Author

Not quite sure why I did this. But it's done.

@@ -83,6 +83,7 @@ pub fn main() {
};

// Create an observation channel using the signals map
#[allow(static_mut_refs)] // only a problem in nightly
Copy link
Member

Choose a reason for hiding this comment

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

We should not use static mut refs here.
See this discussion as reference
#2770 (comment)

@domenukk
Copy link
Member

This is cool! I'm a bit afraid we'll run into a bunch of new errors on odd platforms though

@riesentoaster
Copy link
Contributor Author

  1. Dead code/unused functions: I have decided to not remove anything like that for now, this PR is large enough by itself. Separate PR?
  2. static_mut_refs: Same thing. Should be fairly easy to do, since you can basically grep for it. It may be worth unifying the pseudo-coverage across example fuzzers anyways. There is a variance in naming conventions, how the observers are built, etc. And that seems odd to me.
  3. Pedantic: I'll fix what breaks. If you want it in the repo: Should we not add this to the CI as well?

@domenukk
Copy link
Member

  • static_mut_refs: I don't think we should allow them, then we'll never fix them (and IIRC they will break in rust 2024)
  • Dead code/unused functions: same thing, we shound't allow those?

@domenukk
Copy link
Member

The pendantic comment you can ignore

@riesentoaster
Copy link
Contributor Author

Both are already in the repo. This makes them just a bit more visible.

I need to do something else at some point. Separate PR please?

@domenukk
Copy link
Member

Ah you already didn't :D
It's fine if we have a good amount of clippy lints

@domenukk
Copy link
Member

As in: the maximum amount of enabled lint possible at all times; without being ridicoulous

@@ -24,14 +24,15 @@ use libafl_bolts::{current_nanos, nonzero, rands::StdRand, tuples::tuple_list, A

/// Coverage map with explicit assignments due to the lack of instrumentation
static mut SIGNALS: [u8; 16] = [0; 16];
#[allow(static_mut_refs)] // only a problem in nightly
Copy link
Member

Choose a reason for hiding this comment

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

In any case these allows have to go

Copy link
Member

Choose a reason for hiding this comment

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

Or otherwise leave a biiiiiig TODO comment

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've created an issue (#2786) and added a comment to the code with a link to it.

@riesentoaster
Copy link
Contributor Author

Ah you already didn't :D

Who needs to graduate anyways…

@domenukk domenukk merged commit 25386bf into AFLplusplus:main Dec 20, 2024
103 checks passed
@domenukk
Copy link
Member

@devnexen if you ever find the time, it'd be interesting if this breaks something on obscure *Nixes

@riesentoaster riesentoaster deleted the expect-instead-of-allow branch December 20, 2024 16:37
@devnexen
Copy link
Contributor

Ok, will do !

@devnexen
Copy link
Contributor

devnexen commented Dec 20, 2024

  • Starting with solaris/illumos, nothing worrying but I get a bunch of (justified) warnings about the new trivial_numeric_cast lint when calling ioctl because the op argument is an int on these platforms.
  • All good with haiku.

@domenukk
Copy link
Member

Thank you @devnexen ! :)

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

Successfully merging this pull request may close these issues.

3 participants