Skip to content

Resolve warnings#6

Open
Quipyowert2 wants to merge 2 commits intomasterfrom
resolve-warnings
Open

Resolve warnings#6
Quipyowert2 wants to merge 2 commits intomasterfrom
resolve-warnings

Conversation

@Quipyowert2
Copy link
Owner

@Quipyowert2 Quipyowert2 commented Sep 15, 2023

Fixes a comparison between signed and unsigned and a incompatible pointer type warning. I originally solved the incompatible pointer type issue by using preprocessor macros, but int32_t is so much cleaner and concise.

comparison of integers of different signs: 'Sint32' (aka 'long') and 'unsigned long' [Semantic Issue] Clang (c-cpp-flylint) [Ln 148, Col 25]
incompatible pointer types passing 'Sint32[2]' (aka 'long[2]') to parameter of type 'int *' [Semantic Issue] Clang (c-cpp-flylint) [Ln 282, Col 12]

The first warning, at KXLsound.c:148, goes away after casting some unsigneds to signed when subtracting; the second, at KXLsound.c:282, is fixed by changing the Sint32 type to be int32_t which is always 32-bits, rather than long, which can either be the same size as int or larger, and is definitely not the same type. I also changed the type of Uint32 to uint32_t for consistency.

@Quipyowert2 Quipyowert2 marked this pull request as ready for review September 16, 2023 00:31
continue;
sample_ptr = KXL_SoundData.PlaySound[i].Pos+KXL_SoundData.PlaySound[i].Cnt;
sample_size = MIN(max_sample_size, KXL_SoundData.PlaySound[i].Length - KXL_SoundData.PlaySound[i].Cnt);
sample_size = MIN(max_sample_size, ((Sint32)KXL_SoundData.PlaySound[i].Length) - (Sint32)KXL_SoundData.PlaySound[i].Cnt);
Copy link
Owner Author

@Quipyowert2 Quipyowert2 Sep 30, 2023

Choose a reason for hiding this comment

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

Is it possible for the length to overflow if it is > ~2 GB?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant