fix: resta tidy (60 troballes — empty-catch, widening, branch-clone, etc.)
This commit is contained in:
@@ -57,12 +57,14 @@ namespace Ja {
|
||||
std::unique_ptr<Uint8[], SdlFreeDeleter> buffer;
|
||||
};
|
||||
|
||||
// L'ordre (punters primer, ints després, enum de 8 bits al final) minimitza
|
||||
// el padding a 64-bit (evita avisos de clang-analyzer-optin.performance.Padding).
|
||||
struct Channel {
|
||||
Sound* sound{nullptr};
|
||||
SDL_AudioStream* stream{nullptr};
|
||||
int pos{0};
|
||||
int times{0};
|
||||
int group{0};
|
||||
SDL_AudioStream* stream{nullptr};
|
||||
ChannelState state{ChannelState::FREE};
|
||||
};
|
||||
|
||||
@@ -314,7 +316,11 @@ namespace Ja {
|
||||
std::fseek(f, 0, SEEK_END);
|
||||
const long FSIZE = std::ftell(f);
|
||||
std::fseek(f, 0, SEEK_SET);
|
||||
auto* buffer = static_cast<Uint8*>(std::malloc(FSIZE + 1));
|
||||
if (FSIZE <= 0) {
|
||||
std::fclose(f);
|
||||
return nullptr;
|
||||
}
|
||||
auto* buffer = static_cast<Uint8*>(std::malloc(static_cast<size_t>(FSIZE) + 1));
|
||||
if (buffer == nullptr) {
|
||||
std::fclose(f);
|
||||
return nullptr;
|
||||
@@ -520,7 +526,7 @@ namespace Ja {
|
||||
inline auto loadSound(std::uint8_t* buffer, std::uint32_t size) -> Sound* {
|
||||
auto sound = std::make_unique<Sound>();
|
||||
Uint8* raw = nullptr;
|
||||
if (!SDL_LoadWAV_IO(SDL_IOFromMem(buffer, size), 1, &sound->spec, &raw, &sound->length)) {
|
||||
if (!SDL_LoadWAV_IO(SDL_IOFromMem(buffer, size), true, &sound->spec, &raw, &sound->length)) {
|
||||
std::cout << "Failed to load WAV from memory: " << SDL_GetError() << '\n';
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user