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

Improves ignore messages in Router.cpp #4442

Conversation

charlieh0tel
Copy link
Contributor

  • Improves ignore messages in Router.cpp
  • Cleans up flow using standard "goto out" pattern to handle cleanup.

@CLAassistant
Copy link

CLAassistant commented Aug 11, 2024

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@thebentern
Copy link
Contributor

I'm a big fan of guard clauses, but less of a fan of goto statements. Perhaps we can take a similar approach in the if blocks but instead of the goto we can do early return ala:

packetPool.release(p);
return;

@charlieh0tel
Copy link
Contributor Author

The Linux kernel uses to goto pattern because it avoids copypasta, which has been demonstrated to cause bugs.

But I will change it to copypasta + nlx per your request.

@thebentern
Copy link
Contributor

copypasta, which has been demonstrated to cause bugs.

In my experience if copypasta is concern, it's typically a code-smell that extracting a method to encapsulate the duplicated behavior is called for. That could also be a QoL change as a part of this cleanup. FWIW, I understand gotos can be used effectively, but I've also seen them used to create some truly awful spaghetti code. We've gotten this far without using them, so I'd rather not open pandora's box. 😅

Signed-off-by: Christopher Hoover <ch@murgatroid.com>

.
@charlieh0tel charlieh0tel force-pushed the charlieh0tel/router-mo-betta-ignore-messages branch from d06f413 to 9efd493 Compare August 13, 2024 20:16
@charlieh0tel
Copy link
Contributor Author

I did it the copypasta + nlx way you requested. I think it is ready to merge. PTAL.

@charlieh0tel
Copy link
Contributor Author

charlieh0tel commented Aug 14, 2024

Caught up to head of master. Should be good to go. PTAL @thebentern

@thebentern thebentern merged commit 1813251 into meshtastic:master Aug 14, 2024
100 checks passed
@charlieh0tel charlieh0tel deleted the charlieh0tel/router-mo-betta-ignore-messages branch August 14, 2024 15:49
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