Skip to content

Commit

Permalink
Merge pull request #766 from Daft-Freak/mostly-pico-warnings
Browse files Browse the repository at this point in the history
Warning fixes (everywhere)
  • Loading branch information
Gadgetoid authored Aug 8, 2022
2 parents 4b3838e + 85275f4 commit 516dbbd
Show file tree
Hide file tree
Showing 44 changed files with 115 additions and 202 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
name: Linux
cache-key: linux
release-suffix: LIN64
cmake-args: '"-DCMAKE_CXX_CLANG_TIDY=clang-tidy;-header-filter=32blit;-checks=performance-*,portability-*,modernize-*,-modernize-use-trailing-return-type,-modernize-avoid-c-arrays,-modernize-use-nodiscard" -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache'
cmake-args: '"-DCMAKE_CXX_CLANG_TIDY=clang-tidy;-header-filter=(32blit|32blit-sdl)/;-checks=performance-*,portability-*,modernize-*,-modernize-use-trailing-return-type,-modernize-avoid-c-arrays,-modernize-use-nodiscard" -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache'
apt-packages: ccache clang-tidy libsdl2-dev libsdl2-image-dev libsdl2-net-dev python3-setuptools

- os: ubuntu-20.04
Expand Down
4 changes: 4 additions & 0 deletions 32blit-pico/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ target_compile_definitions(BlitHalPico INTERFACE
PICO_AUDIO_DMA_IRQ=1
)

target_compile_options(BlitHalPico INTERFACE
-Wno-ignored-qualifiers # pico-sdk generates a lot of these
)

if(${PICO_BOARD} STREQUAL "vgaboard")
message("Using VGA board...")
target_link_libraries(BlitHalPico INTERFACE pico_scanvideo_dpi pico_audio_i2s)
Expand Down
4 changes: 2 additions & 2 deletions 32blit-pico/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void init_audio() {
panic("PicoAudio: Unable to open audio device.\n");
}

bool ok = audio_i2s_connect(producer_pool);
[[maybe_unused]] bool ok = audio_i2s_connect(producer_pool);
assert(ok);
audio_i2s_set_enabled(true);
#endif
Expand All @@ -92,7 +92,7 @@ void init_audio() {
// PWM PIO program assumes 48MHz
pio_sm_set_clkdiv(pio1, 1, clock_get_hz(clk_sys) / 48000000.0f);

bool ok = audio_pwm_default_connect(producer_pool, false);
[[maybe_unused]] bool ok = audio_pwm_default_connect(producer_pool, false);
assert(ok);
audio_pwm_set_enabled(true);
gpio_set_drive_strength(PICO_AUDIO_PWM_MONO_PIN, GPIO_DRIVE_STRENGTH_4MA);
Expand Down
4 changes: 2 additions & 2 deletions 32blit-pico/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ DSTATUS disk_status(BYTE pdrv) {

DRESULT disk_read(BYTE pdrv, BYTE *buff, LBA_t sector, UINT count) {
static_assert(FF_MIN_SS == FF_MAX_SS);
return storage_read(sector, 0, buff, FF_MIN_SS * count) == FF_MIN_SS * count ? RES_OK : RES_ERROR;
return storage_read(sector, 0, buff, FF_MIN_SS * count) == int32_t(FF_MIN_SS * count) ? RES_OK : RES_ERROR;
}

DRESULT disk_write(BYTE pdrv, const BYTE *buff, LBA_t sector, UINT count) {
return storage_write(sector, 0, buff, FF_MIN_SS * count) == FF_MIN_SS * count ? RES_OK : RES_ERROR;
return storage_write(sector, 0, buff, FF_MIN_SS * count) == int32_t(FF_MIN_SS * count) ? RES_OK : RES_ERROR;
}

DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void* buff) {
Expand Down
16 changes: 8 additions & 8 deletions 32blit-pico/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ void update_input() {
using namespace blit;

#ifdef INPUT_GPIO
api.buttons = (get_button(ButtonIO::LEFT) ? Button::DPAD_LEFT : 0)
| (get_button(ButtonIO::RIGHT) ? Button::DPAD_RIGHT : 0)
| (get_button(ButtonIO::UP) ? Button::DPAD_UP : 0)
| (get_button(ButtonIO::DOWN) ? Button::DPAD_DOWN : 0)
| (get_button(ButtonIO::A) ? Button::A : 0)
| (get_button(ButtonIO::B) ? Button::B : 0)
| (get_button(ButtonIO::X) ? Button::X : 0)
| (get_button(ButtonIO::Y) ? Button::Y : 0);
api.buttons = (get_button(ButtonIO::LEFT) ? uint32_t(Button::DPAD_LEFT) : 0)
| (get_button(ButtonIO::RIGHT) ? uint32_t(Button::DPAD_RIGHT) : 0)
| (get_button(ButtonIO::UP) ? uint32_t(Button::DPAD_UP) : 0)
| (get_button(ButtonIO::DOWN) ? uint32_t(Button::DPAD_DOWN) : 0)
| (get_button(ButtonIO::A) ? uint32_t(Button::A) : 0)
| (get_button(ButtonIO::B) ? uint32_t(Button::B) : 0)
| (get_button(ButtonIO::X) ? uint32_t(Button::X) : 0)
| (get_button(ButtonIO::Y) ? uint32_t(Button::Y) : 0);
#endif
}
1 change: 0 additions & 1 deletion 32blit-pico/usb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t *
}

int32_t tud_msc_scsi_cb(uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, uint16_t bufsize) {
void const* response = NULL;
uint16_t resplen = 0;

switch (scsi_cmd[0]) {
Expand Down
3 changes: 2 additions & 1 deletion 32blit-sdl/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ void blit_send_message(const uint8_t *data, uint16_t length) {
const Uint32 System::timer_event = SDL_RegisterEvents(2);
const Uint32 System::loop_event = System::timer_event + 1;

#ifndef __EMSCRIPTEN__
// Thread bouncers
static int system_timer_thread(void *ptr) {
// Bounce back in to the class.
Expand All @@ -176,7 +177,7 @@ static int system_loop_thread(void *ptr) {
System *sys = (System *)ptr;
return sys->update_thread();
}

#endif

System::System() {
m_input = SDL_CreateMutex();
Expand Down
4 changes: 2 additions & 2 deletions 32blit-sdl/VideoCaptureFfmpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ static AVFrame *get_audio_frame(OutputStream *ost)
static int write_audio_frame(AVFormatContext *oc, OutputStream *ost)
{
AVCodecContext *c;
AVPacket pkt = { 0 }; // data and size must be 0;
AVPacket pkt = {}; // data and size must be 0;
AVFrame *frame;
int ret;
//int got_packet;
Expand Down Expand Up @@ -454,7 +454,7 @@ static int write_video_frame(AVFormatContext *oc, OutputStream *ost)
int ret;
AVCodecContext *c;
AVFrame *frame;
AVPacket pkt = { 0 };
AVPacket pkt = {};
c = ost->enc;
frame = get_video_frame(ost);
av_init_packet(&pkt);
Expand Down
2 changes: 2 additions & 0 deletions 32blit-stm32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ target_compile_definitions(BlitHalSTM32

target_compile_options(BlitHalSTM32 PUBLIC "$<$<CONFIG:RELEASE>:-Os>")
target_compile_options(BlitHalSTM32 PUBLIC "$<$<CONFIG:Debug>:-finline-functions-called-once>") # need at least some inlining, otherwise build is too big
target_compile_options(BlitHalSTM32 PRIVATE -Wno-missing-field-initializers)

set_target_properties(BlitHalSTM32 PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE)
set_target_properties(BlitHalSTM32 PROPERTIES POSITION_INDEPENDENT_CODE OFF)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ typedef enum
(__DMA_HANDLE__).Parent = (__HANDLE__); \
} while(0)

#define UNUSED(x) ((void)(__typeof__(x))(x)) // suppress "UNUSED" warnings
#define UNUSED(x) ((void)(x))

/** @brief Reset the Handle's State field.
* @param __HANDLE__: specifies the Peripheral Handle.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static const uint8_t LL_BDMA_CH_OFFSET_TAB[] =
/* Private constants ---------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/
#if !defined(UNUSED)
#define UNUSED(x) ((void)(__typeof__(x))(x)) // suppress "UNUSED" warnings
#define UNUSED(x) ((void)(x))
#endif

/* Exported types ------------------------------------------------------------*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ extern const uint8_t LL_RCC_PrescTable[16];
/* Private constants ---------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/
#if !defined(UNUSED)
#define UNUSED(x) ((void)(__typeof__(x))(x)) // suppress "UNUSED" warnings
#define UNUSED(x) ((void)(x))
#endif

/* 32 24 16 8 0
Expand Down
3 changes: 0 additions & 3 deletions 32blit-stm32/Inc/32blit.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#pragma once

#undef UNUSED
#define UNUSED(x) ((void)(__typeof__(x))(x)) // suppress "UNUSED" warnings

#include "32blit.hpp"
#include "persistence.h"
#include "executable.hpp"
Expand Down
22 changes: 11 additions & 11 deletions 32blit-stm32/Src/32blit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,17 +567,17 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
void blit_process_input() {
// Read buttons
blit::buttons =
(!HAL_GPIO_ReadPin(DPAD_UP_GPIO_Port, DPAD_UP_Pin) ? blit::DPAD_UP : 0) |
(!HAL_GPIO_ReadPin(DPAD_DOWN_GPIO_Port, DPAD_DOWN_Pin) ? blit::DPAD_DOWN : 0) |
(!HAL_GPIO_ReadPin(DPAD_LEFT_GPIO_Port, DPAD_LEFT_Pin) ? blit::DPAD_LEFT : 0) |
(!HAL_GPIO_ReadPin(DPAD_RIGHT_GPIO_Port, DPAD_RIGHT_Pin) ? blit::DPAD_RIGHT : 0) |
(!HAL_GPIO_ReadPin(BUTTON_A_GPIO_Port, BUTTON_A_Pin) ? blit::A : 0) |
(!HAL_GPIO_ReadPin(BUTTON_B_GPIO_Port, BUTTON_B_Pin) ? blit::B : 0) |
(!HAL_GPIO_ReadPin(BUTTON_X_GPIO_Port, BUTTON_X_Pin) ? blit::X : 0) |
(!HAL_GPIO_ReadPin(BUTTON_Y_GPIO_Port, BUTTON_Y_Pin) ? blit::Y : 0) |
(HAL_GPIO_ReadPin(BUTTON_HOME_GPIO_Port, BUTTON_HOME_Pin) ? blit::HOME : 0) | // INVERTED LOGIC!
(!HAL_GPIO_ReadPin(BUTTON_MENU_GPIO_Port, BUTTON_MENU_Pin) ? blit::MENU : 0) |
(!HAL_GPIO_ReadPin(JOYSTICK_BUTTON_GPIO_Port, JOYSTICK_BUTTON_Pin) ? blit::JOYSTICK : 0);
(!HAL_GPIO_ReadPin(DPAD_UP_GPIO_Port, DPAD_UP_Pin) ? uint32_t(DPAD_UP) : 0) |
(!HAL_GPIO_ReadPin(DPAD_DOWN_GPIO_Port, DPAD_DOWN_Pin) ? uint32_t(DPAD_DOWN) : 0) |
(!HAL_GPIO_ReadPin(DPAD_LEFT_GPIO_Port, DPAD_LEFT_Pin) ? uint32_t(DPAD_LEFT) : 0) |
(!HAL_GPIO_ReadPin(DPAD_RIGHT_GPIO_Port, DPAD_RIGHT_Pin) ? uint32_t(DPAD_RIGHT) : 0) |
(!HAL_GPIO_ReadPin(BUTTON_A_GPIO_Port, BUTTON_A_Pin) ? uint32_t(A) : 0) |
(!HAL_GPIO_ReadPin(BUTTON_B_GPIO_Port, BUTTON_B_Pin) ? uint32_t(B) : 0) |
(!HAL_GPIO_ReadPin(BUTTON_X_GPIO_Port, BUTTON_X_Pin) ? uint32_t(X) : 0) |
(!HAL_GPIO_ReadPin(BUTTON_Y_GPIO_Port, BUTTON_Y_Pin) ? uint32_t(Y) : 0) |
(HAL_GPIO_ReadPin(BUTTON_HOME_GPIO_Port, BUTTON_HOME_Pin) ? uint32_t(HOME) : 0) | // INVERTED LOGIC!
(!HAL_GPIO_ReadPin(BUTTON_MENU_GPIO_Port, BUTTON_MENU_Pin) ? uint32_t(MENU) : 0) |
(!HAL_GPIO_ReadPin(JOYSTICK_BUTTON_GPIO_Port, JOYSTICK_BUTTON_Pin) ? uint32_t(JOYSTICK) : 0);

if(blit::buttons.state)
power::update_active();
Expand Down
18 changes: 0 additions & 18 deletions 32blit-stm32/Src/fatfs_sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,24 +606,6 @@ DRESULT SD_disk_ioctl(BYTE drv, BYTE ctrl, void *buff)
case CTRL_SYNC:
if (SD_ReadyWait() == 0xFF) res = RES_OK;
break;
case MMC_GET_CSD:
/* SEND_CSD */
if (SD_SendCmd(CMD9, 0) == 0 && SD_RxDataBlock(ptr, 16)) res = RES_OK;
break;
case MMC_GET_CID:
/* SEND_CID */
if (SD_SendCmd(CMD10, 0) == 0 && SD_RxDataBlock(ptr, 16)) res = RES_OK;
break;
case MMC_GET_OCR:
/* READ_OCR */
if (SD_SendCmd(CMD58, 0) == 0)
{
for (n = 0; n < 4; n++)
{
*ptr++ = SPI_RxByte();
}
res = RES_OK;
}
default:
res = RES_PARERR;
}
Expand Down
5 changes: 5 additions & 0 deletions 32blit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ target_include_directories(BlitEngine
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
)

get_filename_component(3RD_PARTY_DIR ../3rd-party ABSOLUTE)
target_include_directories(BlitEngine
PRIVATE ${3RD_PARTY_DIR}
)

# version variables
string(TIMESTAMP BUILD_DATE "%Y-%m-%d" UTC)
if(DEFINED ENV{TRAVIS_TAG})
Expand Down
2 changes: 1 addition & 1 deletion 32blit/engine/menu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace blit {
Menu(std::string_view title, const Item *items = nullptr, int num_items = 0, const Font &font = minimal_font)
: title(title), items(items), num_items(num_items), display_rect(0, 0, 0, 0), font(font) {}

virtual ~Menu() {}
virtual ~Menu() = default;

//
// Render the menu to the screen
Expand Down
2 changes: 1 addition & 1 deletion 32blit/engine/profiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class ScopedProfilerProbe
class Profiler
{
public:
typedef std::vector<ProfilerProbe *> ProfilerProbes;
using ProfilerProbes = std::vector<ProfilerProbe *>;
enum DisplayMetric {dmMin, dmCur, dmAvg, dmMax};


Expand Down
2 changes: 1 addition & 1 deletion 32blit/engine/running_average.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ template<typename T>
class RunningAverage
{
public:
typedef std::vector<T> Data;
using Data = std::vector<T>;
RunningAverage(std::size_t uSize) : m_uSize(uSize), m_uIndex(0), m_average(0), m_bFull(false) {};

const T &operator[] (std::size_t i) const
Expand Down
4 changes: 1 addition & 3 deletions 32blit/types/mat3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ namespace blit {
v02 = 0.0f; v12 = 0.0f; v22 = 0.0f;
}

Mat3::Mat3(const Mat3 &m) = default;

Mat3 Mat3::identity() {
Mat3 m;
m.v00 = 1.0f; m.v11 = 1.0f; m.v22 = 1.0f;
Expand Down Expand Up @@ -66,4 +64,4 @@ namespace blit {
this->v22 = (m.v00 * m.v11 - m.v10 * m.v01) * invdet;
}

}
}
3 changes: 1 addition & 2 deletions 32blit/types/mat3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace blit {
float v02, v12, v22;

Mat3();
Mat3(const Mat3 &m);

inline Mat3& operator*= (const Mat3 &m) {
float r00 = this->v00 * m.v00 + this->v01 * m.v10 + this->v02 * m.v20;
Expand Down Expand Up @@ -38,4 +37,4 @@ namespace blit {

inline Mat3 operator* (Mat3 lhs, const Mat3 &m) { lhs *= m; return lhs; }

}
}
2 changes: 0 additions & 2 deletions 32blit/types/mat4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ namespace blit {
v03 = 0.0f; v13 = 0.0f; v23 = 0.0f; v33 = 0.0f;
}

Mat4::Mat4(const Mat4 &m) = default;

Mat4 Mat4::identity() {
Mat4 m;
m.v00 = 1.0f; m.v11 = 1.0f; m.v22 = 1.0f; m.v33 = 1.0f;
Expand Down
4 changes: 1 addition & 3 deletions 32blit/types/mat4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ namespace blit {
float v03, v13, v23, v33;

Mat4();
Mat4(const Mat4 &m);


inline Mat4& operator*= (const Mat4 &m) {
float r00 = this->v00 * m.v00 + this->v01 * m.v10 + this->v02 * m.v20 + this->v03 * m.v30;
Expand Down Expand Up @@ -48,4 +46,4 @@ namespace blit {
};

inline Mat4 operator* (Mat4 lhs, const Mat4 &m) { lhs *= m; return lhs; }
}
}
1 change: 0 additions & 1 deletion 32blit/types/point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace blit {
int32_t x = 0, y = 0;

Point() = default;
Point(const Point &p) = default;
constexpr Point(int32_t x, int32_t y) : x(x), y(y) {}
constexpr Point(Vec2 v) : x(int32_t(v.x)), y(int32_t(v.y)) {}

Expand Down
1 change: 0 additions & 1 deletion 32blit/types/vec2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace blit {
float x;
float y;

Vec2(const Vec2 &v) = default;
explicit constexpr Vec2(const float x = 0, const float y = 0) : x(x), y(y) {}

inline Vec2& operator-= (const Vec2 &a) { x -= a.x; y -= a.y; return *this; }
Expand Down
3 changes: 1 addition & 2 deletions 32blit/types/vec3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace blit {
float y;
float z;

Vec3(const Vec3 &v) = default;
constexpr Vec3(const float x = 0, const float y = 0, const float z = 0) : x(x), y(y), z(z) {}

inline Vec3& operator-= (const Vec3 &a) { x -= a.x; y -= a.y; z -= a.z; return *this; }
Expand Down Expand Up @@ -48,4 +47,4 @@ namespace blit {
void register_vec3lib(lua_State *L);
vec3 *push_vec3(lua_State* L, float x = 0, float y = 0, float z = 0);
vec3 *push_vec3(lua_State* L, const vec3 &v);*/
}
}
File renamed without changes.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ include(32blit-pico/sdk_import.cmake)

project(32blit)

if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -wd4244")
if(MSVC)
add_compile_options("/W4" "/wd4244" "/wd4324" "/wd4458" "/wd4100")
else()
add_compile_options("-Wall" "-Wextra" "-Wdouble-promotion" "-Wno-unused-parameter")
endif()

find_package (32BLIT CONFIG REQUIRED PATHS .)
Expand Down
13 changes: 0 additions & 13 deletions examples/fizzlefade/fizzlefade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@

using namespace blit;

const uint16_t screen_width = 160;
const uint16_t screen_height = 120;

/* define storage for the framebuffer, spritesheet, and mask */
//rgb __fb[screen_width * screen_height] __attribute__((section(".fb")));
// uint8_t __m[screen_width * screen_height] __attribute__((section(".m")));
// uint8_t __pb[screen_width * screen_height] __attribute__((section(".m")));

/* create surfaces */
//surface fb((uint8_t *)__fb, size(screen_width, screen_height), pixel_format::RGB);
// surface m((uint8_t *)__m, size(screen_width, screen_height), pixel_format::M);
// surface fbb((uint8_t *)__pb, size(screen_width, screen_height), pixel_format::P);

#define FADE_STEPS 3

Pen fade_to[FADE_STEPS]{
Expand Down
Loading

0 comments on commit 516dbbd

Please sign in to comment.