Improvement: avoid segfault when passing a nullptr to t8_forest_element_face_neighbor#2214
Improvement: avoid segfault when passing a nullptr to t8_forest_element_face_neighbor#2214dutkalex wants to merge 5 commits intoDLR-AMR:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2214 +/- ##
==========================================
- Coverage 82.59% 82.59% -0.01%
==========================================
Files 115 115
Lines 18545 18548 +3
==========================================
+ Hits 15318 15320 +2
- Misses 3227 3228 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thank you for this addition! |
| t8_forest_element_face_neighbor (t8_forest_t forest, t8_locidx_t ltreeid, const t8_element_t *elem, t8_element_t *neigh, | ||
| const t8_eclass_t neigh_eclass, int face, int *neigh_face) | ||
| { | ||
| int dummy = 0; |
There was a problem hiding this comment.
I was first uncertain about this dummy. After looking through the code it is clear the variable is required locally. It is still an output, and if a user does not actually need it, it seems ok to just discard it.
There was a problem hiding this comment.
This is the simplest and least intrusive change to allow for nullptr to be passed to this function. Conceptually, it boils down to moving inside of the function the call site boilerplate that callers are doing right now if they don't care about neigh_face. Reading your comment it is not 100% clear to me if you agree with this implementation or if you want me to change something however.
| } | ||
|
|
||
| // TODO: Function declaration return statement does not match the implementation. | ||
| // Check this. |
There was a problem hiding this comment.
Checked this. I think the TODO can be removed.
There was a problem hiding this comment.
I don't quite understand what this TODO comment is referring to. Is it related to the change implemented in this PR?
Co-authored-by: Benedict <135045760+benegee@users.noreply.github.com>
Describe your changes here:
The last argument of
t8_forest_element_face_neighboris an output parameter which gets filled with the dual face index. In some situations, this additional output is not desired and one would like to passnullptr(as is often done in other t8code APIs) to signal this. Currently, this results in a hard crash. This PR enables this use case.All these boxes must be checked by the AUTHOR before requesting review:
Documentation:,Bugfix:,Feature:,Improvement:orOther:.All these boxes must be checked by the REVIEWERS before merging the pull request:
As a reviewer please read through all the code lines and make sure that the code is fully understood, bug free, well-documented and well-structured.
General
Tests
If the Pull request introduces code that is not covered by the github action (for example coupling with a new library):
Scripts and Wiki
scripts/internal/find_all_source_files.shto check the indentation of these files.License
doc/(or already has one).