Skip to content

Comments

g.setproj: fix uninitialized variable issues in get_stp.c#3777

Merged
wenzeslaus merged 1 commit intoOSGeo:mainfrom
ShubhamDesai:fix-uninitialized-vars
Jun 6, 2024
Merged

g.setproj: fix uninitialized variable issues in get_stp.c#3777
wenzeslaus merged 1 commit intoOSGeo:mainfrom
ShubhamDesai:fix-uninitialized-vars

Conversation

@ShubhamDesai
Copy link
Contributor

This pull request fixes uninitialized variable issues in general/g.setproj/get_stp.c.

Changes Made

  1. Initialized reccnt:

    • Issue : The variable reccnt was used without being initialized.
    • Fix : Initialized reccnt to 0 at its declaration.
      int record, icode, reccnt = 0, special_case;
      
  2. Initialized STabbr_prev:

    • Issue : The variable STabbr_prev was used without being initialized.
    • Fix : Initialized STabbr_prev to an empty string at its declaration.
      char STabbr[50], STabbr_prev[50] = "", COname[50], answer[50], buff[256];
      

@github-actions github-actions bot added C Related code is in C module general labels Jun 6, 2024
Copy link
Member

@wenzeslaus wenzeslaus left a comment

Choose a reason for hiding this comment

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

This looks good. Congratulations on your first contribution to this repository!

@wenzeslaus wenzeslaus enabled auto-merge (squash) June 6, 2024 03:27
@wenzeslaus
Copy link
Member

The code is disabled, so the compilers don't see the issues (but cppcheck does), but we clearly have the code in the code base, so it's better when it is fixed. It might be a candidate for removal, though.

@wenzeslaus wenzeslaus merged commit 0f533c2 into OSGeo:main Jun 6, 2024
@neteler neteler added this to the 8.4.0 milestone Jun 6, 2024
@neteler neteler changed the title Fixed uninitialized variable issues in get_stp.c g.setproj: fix uninitialized variable issues in get_stp.c Jun 6, 2024
@echoix
Copy link
Member

echoix commented Jun 6, 2024

Cppcheck is quite fun for that, and it is also what can slow it down. It runs a pass on many combinations of conditional preprocessor defines in order to achieve highest code coverage. That same feature can also make it slower in some cases.

a0x8o pushed a commit to a0x8o/grass that referenced this pull request Jun 17, 2024
Fixes uninitialized variables reported by Cppcheck.
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 general module

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants