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

lib/gis: Refactor va_list usage in debug module #4702

Merged
merged 1 commit into from
Nov 29, 2024

Conversation

ymdatta
Copy link
Contributor

@ymdatta ymdatta commented Nov 14, 2024

lib/gis: Refactor va_list usage in debug module

va_list() macro initializes va_list structure before it's usage,
and each va_list() call has to be accompanied by corresponding
va_end() macro call on the same va_list structure.

By having these macros directly before and after the va_list
structure usage, reduces the number of places we need to keep
track of whether the va_list structure was properly inintialized
or closed.

This was found using cppcheck tool.

@github-actions github-actions bot added C Related code is in C libraries labels Nov 14, 2024
@metzm
Copy link
Contributor

metzm commented Nov 19, 2024

Start ap as late as possible and close it as early as possible ?

        va_start(ap, msg);
        vfprintf(fd, msg, ap);
        va_end(ap);

i.e. move va_start() and va_end() to be directly around vfprintf()

See also error.c

va_list() macro initializes va_list structure before it's usage,
and each va_list() call has to be accompanied by corresponding
va_end() macro call on the same va_list structure.

By having these macros directly before and after the va_list
structure usage, reduces the number of places we need to keep
track of whether the va_list structure was properly inintialized
or closed.

Signed-off-by: Mohan Yelugoti <[email protected]>
@ymdatta ymdatta changed the title lib/gis: Close va_list if erroring out early in debug module lib/gis: Refactor va_list usage in debug module Nov 27, 2024
@ymdatta
Copy link
Contributor Author

ymdatta commented Nov 27, 2024

@metzm : Thanks for the suggestion! I think that's a really clean and better way. Made the changes.

ymdatta added a commit to ymdatta/grass that referenced this pull request Nov 27, 2024
Documented each supression issue with comments to distinguish between
false positives and true positives awaiting resolution.

For the false positives supressions, appropriate information is
provided on why those were considered as false positive.

True positives will be removed from the suppression file once
their corresponding fixes(OSGeo#4702, OSGeo#4638, OSGeo#4500, OSGeo#4499) are merged.

Run:

`cppcheck --suppressions-list=.cppcheck-supressions <path>`

Signed-off-by: Mohan Yelugoti <[email protected]>
ymdatta added a commit to ymdatta/grass that referenced this pull request Nov 27, 2024
Documented each suppression issue with comments to distinguish between
false positives and true positives awaiting resolution.

For the false positives suppressions, appropriate information is
provided on why those were considered as false positive.

True positives will be removed from the suppression file once
their corresponding fixes(OSGeo#4702, OSGeo#4638, OSGeo#4500, OSGeo#4499) are merged.

Run:

`cppcheck --suppressions-list=.cppcheck-suppressions <path>`

Signed-off-by: Mohan Yelugoti <[email protected]>
@echoix echoix merged commit 0c3a9c7 into OSGeo:main Nov 29, 2024
26 of 28 checks passed
@github-actions github-actions bot added this to the 8.5.0 milestone Nov 29, 2024
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 libraries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants