Skip to content

Commit

Permalink
butano: some clangd warnings fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
GValiente committed Oct 17, 2023
1 parent dd589de commit d98e0f9
Show file tree
Hide file tree
Showing 33 changed files with 60 additions and 77 deletions.
2 changes: 1 addition & 1 deletion butano/hw/include/bn_hw_audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ namespace bn::hw::audio

inline void set_sound_master_volume(int volume)
{
mmSetEffectsVolume(volume);
mmSetEffectsVolume(mm_word(volume));
}

[[nodiscard]] bool update_on_vblank();
Expand Down
6 changes: 3 additions & 3 deletions butano/hw/include/bn_hw_dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ inline void copy_half_words(const void* source, int half_words, void* destinatio
REG_DMA[3].cnt = 0;
REG_DMA[3].src = source;
REG_DMA[3].dst = destination;
REG_DMA[3].cnt = half_words | DMA_CPY16;
REG_DMA[3].cnt = unsigned(half_words) | DMA_CPY16;
}

inline void copy_words(const void* source, int words, void* destination)
{
REG_DMA[3].cnt = 0;
REG_DMA[3].src = source;
REG_DMA[3].dst = destination;
REG_DMA[3].cnt = words | DMA_CPY32;
REG_DMA[3].cnt = unsigned(words) | DMA_CPY32;
}

inline void start_hdma(int channel, const uint16_t* source, int half_words, uint16_t* destination)
{
REG_DMA[channel].cnt = 0;
REG_DMA[channel].src = source;
REG_DMA[channel].dst = destination;
REG_DMA[channel].cnt = half_words | DMA_HDMA;
REG_DMA[channel].cnt = unsigned(half_words) | DMA_HDMA;
}

inline void stop_hdma(int channel)
Expand Down
1 change: 0 additions & 1 deletion butano/hw/include/bn_hw_hblank_effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#ifndef BN_HW_HBLANK_EFFECTS_H
#define BN_HW_HBLANK_EFFECTS_H

#include "bn_algorithm.h"
#include "bn_config_hbes.h"
#include "bn_hw_irq.h"

Expand Down
4 changes: 2 additions & 2 deletions butano/hw/include/bn_hw_sram.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ namespace bn::hw::sram
{
auto source_ptr = reinterpret_cast<const uint8_t*>(source);
auto destination_ptr = reinterpret_cast<uint8_t*>(MEM_SRAM) + offset;
__agbabi_memcpy1(destination_ptr, source_ptr, size);
__agbabi_memcpy1(destination_ptr, source_ptr, unsigned(size));
}

inline void read(void* destination, int size, int offset)
{
auto source_ptr = reinterpret_cast<const uint8_t*>(MEM_SRAM) + offset;
auto destination_ptr = reinterpret_cast<uint8_t*>(destination);
__agbabi_memcpy1(destination_ptr, source_ptr, size);
__agbabi_memcpy1(destination_ptr, source_ptr, unsigned(size));
}

inline void set_bytes(uint8_t value, int size, int offset)
Expand Down
1 change: 0 additions & 1 deletion butano/hw/include/bn_hw_timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#define BN_HW_TIMER_H

#include "bn_hw_tonc.h"
#include "bn_hw_timer_constants.h"

namespace bn::hw::timer
{
Expand Down
5 changes: 2 additions & 3 deletions butano/hw/src/bn_hw_audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "bn_config_audio.h"
#include "../include/bn_hw_irq.h"
#include "../include/bn_hw_link.h"
#include "../include/bn_hw_tonc.h"
#include "../3rd_party/vgm-player/include/vgm.h"

extern "C"
Expand Down Expand Up @@ -313,9 +312,9 @@ void set_dmg_music_position(int pattern, int row)
}
else
{
BN_ASSERT(! row, "Invalid row: ", row);
BN_BASIC_ASSERT(! row, "Invalid row: ", row);

VgmSetOffsetPlay(pattern);
VgmSetOffsetPlay(unsigned(pattern));
}
}

Expand Down
4 changes: 2 additions & 2 deletions butano/hw/src/bn_hw_common.bn_noflto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ extern "C"

void __libc_init_array(void)
{
for(size_t index = 0, limit = __preinit_array_end - __preinit_array_start; index < limit; ++index)
for(int index = 0, limit = __preinit_array_end - __preinit_array_start; index < limit; ++index)
{
__preinit_array_start[index]();
}

for(size_t index = 0, limit = __init_array_end - __init_array_start; index < limit; ++index)
for(int index = 0, limit = __init_array_end - __init_array_start; index < limit; ++index)
{
__init_array_start[index]();
}
Expand Down
2 changes: 1 addition & 1 deletion butano/hw/src/bn_hw_link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void send(int data_to_send)
data.sendMessages.pop_front();
}

data.sendMessages.push_back(data_to_send);
data.sendMessages.push_back(uint16_t(data_to_send));

BN_BARRIER;
data.blockSendMessages = false;
Expand Down
5 changes: 4 additions & 1 deletion butano/hw/src/bn_hw_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@

#include "../include/bn_hw_memory.h"

#include "bn_random.h"
#include "bn_config_ewram.h"

#if BN_CFG_EWRAM_WAIT_STATE == BN_EWRAM_WAIT_STATE_1
#include "bn_random.h"
#endif

extern unsigned __iwram_start__;
extern unsigned __iwram_top;
extern unsigned __fini_array_end;
Expand Down
3 changes: 2 additions & 1 deletion butano/include/bn_assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@
[[noreturn]] void show(const char* condition, const char* file_name, const char* function, int line,
const bn::istring_base& message);

inline void show_args(const char* condition_msg, const char* file, const char* function, int line)
[[noreturn]] inline void show_args(
const char* condition_msg, const char* file, const char* function, int line)
{
_bn::assert::show(condition_msg, file, function, line);
}
Expand Down
2 changes: 1 addition & 1 deletion butano/include/bn_best_fit_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class best_fit_allocator

public:
item_type* previous = nullptr;
size_type size: 30 = 0;
size_type size: 31 = 0;
bool used: 1 = false;
free_items_pair free_items;

Expand Down
2 changes: 1 addition & 1 deletion butano/include/bn_bitset.h
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ class ibitset

[[nodiscard]] constexpr static element_t _bit(int index)
{
return element_t(1) << (index & (_bits_per_element - 1));
return element_t(1 << (index & (_bits_per_element - 1)));
}
};

Expand Down
3 changes: 2 additions & 1 deletion butano/include/bn_blending_fade_alpha.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class blending_fade_alpha
/**
* @brief Default equal operator.
*/
[[nodiscard]] constexpr friend bool operator==(const blending_fade_alpha& a, const blending_fade_alpha& b) = default;
[[nodiscard]] constexpr friend bool operator==(
const blending_fade_alpha& a, const blending_fade_alpha& b) = default;

private:
fixed _value;
Expand Down
8 changes: 4 additions & 4 deletions butano/include/bn_dmg_music_position.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class dmg_music_position
* @param row Row inside the pattern.
*/
constexpr dmg_music_position(int pattern, int row) :
_pattern(pattern),
_row(row)
_pattern(unsigned(pattern)),
_row(unsigned(row))
{
BN_ASSERT(pattern >= 0 && pattern < (1 << 26), "Invalid pattern: ", pattern);
BN_ASSERT(row >= 0 && row < 64, "Invalid row: ", row);
Expand All @@ -62,7 +62,7 @@ class dmg_music_position
{
BN_ASSERT(pattern >= 0 && pattern < (1 << 26), "Invalid pattern: ", pattern);

_pattern = pattern;
_pattern = unsigned(pattern);
}

/**
Expand All @@ -80,7 +80,7 @@ class dmg_music_position
{
BN_ASSERT(row >= 0 && row < 64, "Invalid row: ", row);

_row = row;
_row = unsigned(row);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion butano/include/bn_documentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -2159,7 +2159,7 @@
* @section changelog_15_9_0 15.9.0 (next release)
*
* * Same maps with different tiles or palettes supported.
* * Some Clang-Tidy warnings fixed.
* * Some clangd and Clang-Tidy warnings fixed.
*
*
* @section changelog_15_8_2 15.8.2
Expand Down
4 changes: 2 additions & 2 deletions butano/include/bn_regular_bg_map_cell_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class regular_bg_map_cell_info
{
BN_ASSERT(tile_index >= 0 && tile_index < 1024, "Invalid tile index: ", tile_index);

_fields.tile_index = tile_index;
_fields.tile_index = uint16_t(tile_index);
}

/**
Expand All @@ -90,7 +90,7 @@ class regular_bg_map_cell_info
{
BN_ASSERT(palette_id >= 0 && palette_id < 16, "Invalid palette id: ", palette_id);

_fields.palette_id = palette_id;
_fields.palette_id = uint8_t(palette_id);
}

/**
Expand Down
1 change: 0 additions & 1 deletion butano/include/bn_rumble.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

#include "bn_common.h"


/**
* @brief Rumble related functions.
*
Expand Down
1 change: 0 additions & 1 deletion butano/include/bn_sprite_affine_mat_actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* @ingroup action
*/

#include "bn_fixed.h"
#include "bn_sprite_affine_mat_ptr.h"
#include "bn_value_template_actions.h"

Expand Down
6 changes: 3 additions & 3 deletions butano/include/bn_sprite_tiles_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class sprite_tiles_item
constexpr sprite_tiles_item(const span<const tile>& tiles_ref, bpp_mode bpp, compression_type compression) :
_tiles_ref(tiles_ref),
_graphics_count(1),
_tiles_count_per_graphic(tiles_ref.size()),
_tiles_count_per_graphic(uint8_t(tiles_ref.size())),
_compression(uint8_t(compression)),
_bpp(uint8_t(bpp))
{
Expand Down Expand Up @@ -121,7 +121,7 @@ class sprite_tiles_item
constexpr sprite_tiles_item(const span<const tile>& tiles_ref, bpp_mode bpp, compression_type compression,
int graphics_count) :
_tiles_ref(tiles_ref),
_graphics_count(graphics_count),
_graphics_count(uint16_t(graphics_count)),
_tiles_count_per_graphic(0),
_compression(uint8_t(compression)),
_bpp(uint8_t(bpp))
Expand All @@ -135,7 +135,7 @@ class sprite_tiles_item
int tcpg = tiles_ref.size() / graphics_count;
BN_ASSERT(valid_tiles_count(tcpg, bpp), "Invalid tiles count per graphic: ", tcpg, " - ", int(bpp));

_tiles_count_per_graphic = tcpg;
_tiles_count_per_graphic = uint8_t(tcpg);
}

/**
Expand Down
1 change: 0 additions & 1 deletion butano/src/bn_audio_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include "bn_audio_manager.h"

#include "bn_math.h"
#include "bn_config_audio.h"
#include "bn_dmg_music_position.h"
#include "../hw/include/bn_hw_audio.h"
Expand Down
22 changes: 11 additions & 11 deletions butano/src/bn_bg_blocks_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ namespace
}

uint16_t offset = hw::bg_blocks::affine_map_cells_offset(tiles_offset);
_hw_commit_offset(source_data_ptr, half_words, offset, destination_vram_ptr);
_hw_commit_offset(source_data_ptr, unsigned(half_words), offset, destination_vram_ptr);
}
else
{
Expand Down Expand Up @@ -853,7 +853,7 @@ namespace
if(tiles_offset || palette_offset)
{
uint16_t offset = hw::bg_blocks::regular_map_cells_offset(tiles_offset, palette_offset);
_hw_commit_offset(source_data_ptr, half_words, offset, destination_vram_ptr);
_hw_commit_offset(source_data_ptr, unsigned(half_words), offset, destination_vram_ptr);
}
else
{
Expand Down Expand Up @@ -2593,10 +2593,10 @@ void update_regular_map_row(int id, int x, int y)
if(tiles_offset || palette_offset)
{
uint16_t offset = hw::bg_blocks::regular_map_cells_offset(tiles_offset, palette_offset);
_hw_commit_offset(source_data, elements, offset, dest_data);
_hw_commit_offset(source_data, unsigned(elements), offset, dest_data);
source_data += elements;
dest_data -= x_separator;
_hw_commit_offset(source_data, x_separator, offset, dest_data);
_hw_commit_offset(source_data, unsigned(x_separator), offset, dest_data);
}
else
{
Expand Down Expand Up @@ -2629,11 +2629,11 @@ void update_affine_map_row(int id, int x, int y)
if(auto tiles_offset = unsigned(item.affine_tiles_offset()))
{
uint16_t offset = hw::bg_blocks::affine_map_cells_offset(tiles_offset);
_hw_commit_offset(reinterpret_cast<const uint16_t*>(source_data), elements / 2, offset,
_hw_commit_offset(reinterpret_cast<const uint16_t*>(source_data), unsigned(elements) / 2, offset,
reinterpret_cast<uint16_t*>(dest_data));
source_data += elements;
dest_data -= x_separator;
_hw_commit_offset(reinterpret_cast<const uint16_t*>(source_data), x_separator / 2, offset,
_hw_commit_offset(reinterpret_cast<const uint16_t*>(source_data), unsigned(x_separator) / 2, offset,
reinterpret_cast<uint16_t*>(dest_data));
}
else
Expand Down Expand Up @@ -2670,10 +2670,10 @@ void set_regular_map_position(int id, int x, int y)
{
const uint16_t* source_data = item_data + ((row * map_width) + x);
uint16_t* dest_data = vram_data + (((row & 31) * 32) + x_separator);
_hw_commit_offset(source_data, elements, offset, dest_data);
_hw_commit_offset(source_data, unsigned(elements), offset, dest_data);
source_data += elements;
dest_data -= x_separator;
_hw_commit_offset(source_data, x_separator, offset, dest_data);
_hw_commit_offset(source_data, unsigned(x_separator), offset, dest_data);
}
}
else
Expand Down Expand Up @@ -2715,11 +2715,11 @@ void set_affine_map_position(int id, int x, int y)
{
const uint8_t* source_data = item_data + ((row * map_width) + x);
uint8_t* dest_data = vram_data + (((row & 31) * 32) + x_separator);
_hw_commit_offset(reinterpret_cast<const uint16_t*>(source_data), elements / 2, offset,
_hw_commit_offset(reinterpret_cast<const uint16_t*>(source_data), unsigned(elements) / 2, offset,
reinterpret_cast<uint16_t*>(dest_data));
source_data += elements;
dest_data -= x_separator;
_hw_commit_offset(reinterpret_cast<const uint16_t*>(source_data), x_separator / 2, offset,
_hw_commit_offset(reinterpret_cast<const uint16_t*>(source_data), unsigned(x_separator) / 2, offset,
reinterpret_cast<uint16_t*>(dest_data));
}
}
Expand Down Expand Up @@ -2794,7 +2794,7 @@ void update()
}
else if(item.commit)
{
data.to_commit_items_array[commit_items_count] = iterator.id();
data.to_commit_items_array[commit_items_count] = uint8_t(iterator.id());
++commit_items_count;
}

Expand Down
2 changes: 1 addition & 1 deletion butano/src/bn_cameras_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace
public:
item_type items[max_items];
alignas(int) uint8_t free_item_indexes_array[max_items];
int free_item_indexes_size = max_items;
uint16_t free_item_indexes_size = max_items;
bool update = false;
};

Expand Down
5 changes: 0 additions & 5 deletions butano/src/bn_hdma_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,6 @@ namespace
int8_t _current_state_index = 0;
bool _updated = false;

[[nodiscard]] const state& _current_state() const
{
return _states[_current_state_index];
}

[[nodiscard]] state& _current_state()
{
return _states[_current_state_index];
Expand Down
2 changes: 1 addition & 1 deletion butano/src/bn_keypad_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void update()
{
uint8_t low_part = data.commands[0] - '0';
uint8_t high_part = data.commands[1] - '0';
current_keys = (high_part << 5) + low_part;
current_keys = (unsigned(high_part) << 5) + low_part;
data.commands.remove_prefix(2);
}
}
Expand Down
2 changes: 1 addition & 1 deletion butano/src/bn_reciprocal_lut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace

for(int index = 1; index < reciprocal_16_lut_size; ++index)
{
result[index] = calculate_reciprocal_lut_value<16>(index).data();
result[index] = uint16_t(calculate_reciprocal_lut_value<16>(index).data());
}

return result;
Expand Down
1 change: 0 additions & 1 deletion butano/src/bn_regular_bg_horizontal_position_hbe_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#ifndef BN_REGULAR_BG_HORIZONTAL_POSITION_HBE_HANDLER_H
#define BN_REGULAR_BG_HORIZONTAL_POSITION_HBE_HANDLER_H

#include "bn_fixed_point.h"
#include "bn_bgs_manager.h"
#include "../hw/include/bn_hw_bgs.h"

Expand Down
Loading

0 comments on commit d98e0f9

Please sign in to comment.