Vega-strike-engine-source: Bugs: Improperly initialized values

Created on 24 Nov 2020  路  3Comments  路  Source: vegastrike/Vega-Strike-Engine-Source

While reviewing https://github.com/vegastrike/Vega-Strike-Engine-Source/pull/345 I found several lines where a variable was not properly initialized. The basic pattern is:

type varName =
#ifdef SOME_DEFINED_VALUE
   type someOtherVar = theVarsValue;
   ...
#endif // SOME_DEFINED_VALUE

This is problematic from two perspectives as the variable (varName) is not actually initialized with its correct value in a verifiable manner:

  1. If SOME_DEFINED_VALUE is defined, then it would receive the value of someOtherVar converted to its type.
  2. If SOME_DEFINED_VALUE is not defined, then it'll either generate a compilation error and fail to compile (best case) or generate a warning/error and compile with a latent bug.

We should look at the git history of each file to try to determine if something was improperly removed in order to try to determine the correct values.

List of occurrences found in the PR:

  • [ ] g_game.sound_enabled = on engine/src/aldrv/al_init.cpp, line 162 (https://github.com/vegastrike/Vega-Strike-Engine-Source/pull/345#discussion_r528777404)
  • [ ] g_game.max_sound_sources = on engine/src/aldrv/al_init.cpp, line 176 (https://github.com/vegastrike/Vega-Strike-Engine-Source/pull/345#discussion_r529201188)
  • [ ] int used = on engine/src/audio/codecs/FFStream.cpp, line 278 (https://github.com/vegastrike/Vega-Strike-Engine-Source/pull/345#discussion_r529205347)

More occurrences:

  • [ ] WSK_BACKSPACE = on line 88 of engine/src/gldrv/winsys.h
  • [ ] WSK_DELETE = on line 94 of engine/src/gldrv/winsys.h
  • [ ] WSK_BACKSPACE = on line 215 of engine/src/gldrv/winsys.h
  • [ ] WSK_DELETE = on line 221 of engine/src/gldrv/winsys.h
bug

All 3 comments

These are probably causing some of the compile errors on Windows. (Since AL_whatever_it_is is undefined there for some reason.)

@stephengtuggy there's probably more, we just discovered these in the PR. We'll get there. Just will take some time and effort to find them all.

@BenjamenMeyer Yep. We might be able to run some sort of multi-line regex search to find the rest, I'm thinking. (I.e., search for an equals sign that has nothing but whitespace after it until the end of the line, then a #if at the beginning of the next line.)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BenjamenMeyer picture BenjamenMeyer  路  6Comments

stephengtuggy picture stephengtuggy  路  3Comments

LifWirser picture LifWirser  路  6Comments

nabaco picture nabaco  路  3Comments

royfalk picture royfalk  路  6Comments