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

Fix some issues found by static analysis #4213

Merged
merged 8 commits into from
Nov 6, 2023
Merged

Conversation

vlstill
Copy link
Contributor

@vlstill vlstill commented Oct 30, 2023

No description provided.

fruffy
fruffy previously approved these changes Oct 30, 2023
Copy link
Collaborator

@fruffy fruffy left a comment

Choose a reason for hiding this comment

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

Which linter is this? Publicly available?

@vlstill vlstill requested a review from fruffy October 30, 2023 18:14
@vlstill
Copy link
Contributor Author

vlstill commented Oct 30, 2023

Which linter is this? Publicly available?

Coverity, so no. My feeling is a lot of this could actually be found by clang-tidy too though, but I had not checked that yet.

@vlstill vlstill changed the title Fix some issues found by linting Fix some issues found by static analysis Oct 31, 2023
@vlstill vlstill dismissed fruffy’s stale review October 31, 2023 06:51

new changes since

@@ -66,12 +66,14 @@ TestBackEnd::TestInfo EBPFTestBackend::produceTestInfo(
IR::getConstant(IR::getBitType(outPktSize), EBPFTestBackend::ZERO_PKT_VAL);
testInfo.packetTaintMask =
IR::getConstant(IR::getBitType(outPktSize), EBPFTestBackend::ZERO_PKT_MAX);
} else {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fruffy I'm not really sure about this change. The original code seems suspicious, since the outputPacket set in the "short" path was always rewritten. But I don't know if it is correct now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems good. I am not even sure whether the condition can ever be true. The eBPF back end can not reduce packet size.

@@ -66,12 +66,14 @@ TestBackEnd::TestInfo EBPFTestBackend::produceTestInfo(
IR::getConstant(IR::getBitType(outPktSize), EBPFTestBackend::ZERO_PKT_VAL);
testInfo.packetTaintMask =
IR::getConstant(IR::getBitType(outPktSize), EBPFTestBackend::ZERO_PKT_MAX);
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems good. I am not even sure whether the condition can ever be true. The eBPF back end can not reduce packet size.

ir/v1.def Outdated
@@ -230,7 +230,7 @@ class CalculatedField : IAnnotated {
bool update;
ID name;
Expression cond;
update_or_verify() {} // FIXME -- needed by umpack_json(safe_vector) -- should not be
update_or_verify() { update = false; } // FIXME -- needed by umpack_json(safe_vector) -- should not be
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be in the function call or in the initializer of update?

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 would like to put it into the initializer, but for some reason that breaks the generated code -- the parametric constructor has just 3 arguments. I don't know why that is, it seems quite weird to me. Therefore I've added it to the constructor. I'm quite surprised nested classes can be generated by IRGen.

Copy link
Collaborator

Choose a reason for hiding this comment

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

optional bool update = false;
maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That worked, thanks.

@vlstill
Copy link
Contributor Author

vlstill commented Oct 31, 2023

@fruffy is this test working normally?
image
I've seen in failed also in

@fruffy
Copy link
Collaborator

fruffy commented Oct 31, 2023

@fruffy is this test working normally? image I've seen in failed also in

It is failing about 30% of the time. We are unsure what causes this failure but are trying to fix it. It might be caused by a particular Github runner being chosen.

@vlstill vlstill requested a review from fruffy November 3, 2023 12:14
@vlstill vlstill marked this pull request as ready for review November 3, 2023 12:15
@vlstill vlstill merged commit 646615f into p4lang:main Nov 6, 2023
14 checks passed
@vlstill vlstill deleted the lint-0 branch November 6, 2023 14:14
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.

2 participants