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

i.segment: Fix uninitialized struct member 'ngbr_rc.next' in mean_shift.c #3973

Merged
merged 1 commit into from
Jul 6, 2024

Conversation

ShubhamDesai
Copy link
Contributor

This pull request fixes an issue in mean_shift.c where the struct member ngbr_rc.next was used without being initialized. The change initializes ngbr_rc.next to NULL to ensure it is properly set before use.

Changes Made:

  • Initialize ngbr_rc.next to NULL

This fix resolves the cppcheck warning related to the uninitialized variable.

@github-actions github-actions bot added C Related code is in C module imagery labels Jul 2, 2024
@ShubhamDesai ShubhamDesai changed the title imagery: Fix uninitialized struct member 'ngbr_rc.next' in mean_shift.c Jul 2, 2024
@echoix echoix changed the title lib: Fix uninitialized struct member 'ngbr_rc.next' in mean_shift.c Jul 4, 2024
Copy link
Member

@echoix echoix left a comment

Choose a reason for hiding this comment

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

Seems fine to me, but I'm surprised that only one needs to be initialized. If I read correctly, there are 3 variables of type struct rc (one with *, so pointer?), and I would have expected the variable (struct of type rc) named next to need it too. C/C++ is very far for me, I'm letting someone else judge for this. I also changed the title so it won't fail the title check (for release notes categorization), so that PR would be ready to merge, once I get a confirmation that it is enough.

@nilason
Copy link
Contributor

nilason commented Jul 4, 2024

Seems fine to me, but I'm surprised that only one needs to be initialized. If I read correctly, there are 3 variables of type struct rc (one with *, so pointer?), and I would have expected the variable (struct of type rc) named next to need it too. C/C++ is very far for me, I'm letting someone else judge for this. I also changed the title so it won't fail the title check (for release notes categorization), so that PR would be ready to merge, once I get a confirmation that it is enough.

Member next of struct rs a pointer, which may need to be initialised with NULL.

@echoix echoix merged commit 559e088 into OSGeo:main Jul 6, 2024
27 of 28 checks passed
@neteler neteler added this to the 8.5.0 milestone Jul 8, 2024
a0x8o pushed a commit to a0x8o/grass that referenced this pull request Jul 23, 2024
…ft.c (OSGeo#3973)

imagery: Fix uninitialized struct member 'ngbr_rc.next' in mean_shift.c

Co-authored-by: Shubham Vasudeo Desai <sdesai8@vclvm178-253.vcl.ncsu.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C Related code is in C imagery module
4 participants