Stricter warnings

This commit is contained in:
Michael Theall 2023-07-13 12:52:28 -05:00
parent 55ea4f6201
commit 5c2af6fd29
12 changed files with 59 additions and 13 deletions

2
.gitignore vendored
View File

@ -12,6 +12,7 @@
*.nso *.nso
*.pfs0 *.pfs0
*.smdh *.smdh
*~
.gdb_history .gdb_history
3ds/build 3ds/build
3ds-classic/build 3ds-classic/build
@ -23,3 +24,4 @@ switch/build
switch-classic/build switch-classic/build
switch/romfs/*.zst switch/romfs/*.zst
switch/romfs/shaders/*.dksh switch/romfs/shaders/*.dksh
build*/

View File

@ -15,14 +15,17 @@ target_compile_features(${FTPD_TARGET} PRIVATE cxx_std_20)
target_include_directories(${FTPD_TARGET} PRIVATE include) target_include_directories(${FTPD_TARGET} PRIVATE include)
target_compile_definitions(${FTPD_TARGET} PRIVATE target_compile_definitions(${FTPD_TARGET} PRIVATE
STATUS_STRING="${PROJECT_NAME} v${PROJECT_VERSION}" STATUS_STRING="${PROJECT_NAME} v${PROJECT_VERSION}"
IMGUI_DISABLE_OBSOLETE_FUNCTIONS=1
) )
target_compile_options(${FTPD_TARGET} PRIVATE -Wall -Wextra -Werror)
include(CheckIPOSupported) include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORTED) check_ipo_supported(RESULT IPO_SUPPORTED)
if(IPO_SUPPORTED) if(IPO_SUPPORTED)
set_target_properties(${FTPD_TARGET} PROPERTIES set_target_properties(${FTPD_TARGET} PROPERTIES
INTERPROCEDURAL_OPTIMIZATION FALSE INTERPROCEDURAL_OPTIMIZATION TRUE
INTERPROCEDURAL_OPTIMIZATION_DEBUG FALSE INTERPROCEDURAL_OPTIMIZATION_DEBUG FALSE
INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE
INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO TRUE INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO TRUE

View File

@ -144,6 +144,8 @@ void enableBacklight (bool const enable_)
/// \param param_ User param /// \param param_ User param
void handleAPTHook (APT_HookType const type_, void *const param_) void handleAPTHook (APT_HookType const type_, void *const param_)
{ {
(void)param_;
switch (type_) switch (type_)
{ {
case APTHOOK_ONSUSPEND: case APTHOOK_ONSUSPEND:

View File

@ -99,6 +99,7 @@ int curlDebug (CURL *const handle_,
std::size_t const size_, std::size_t const size_,
void *const user_) void *const user_)
{ {
(void)handle_;
(void)user_; (void)user_;
auto const text = printable (data_, size_); auto const text = printable (data_, size_);

View File

@ -1723,7 +1723,6 @@ bool FtpSession::listTransfer ()
if (::lstat (fullPath.c_str (), &st) != 0) if (::lstat (fullPath.c_str (), &st) != 0)
{ {
error ("Skipping %s: %s\n", fullPath.c_str (), std::strerror (errno)); error ("Skipping %s: %s\n", fullPath.c_str (), std::strerror (errno));
std::fprintf (stderr, "Skipping %s: %s\n", fullPath.c_str (), std::strerror (errno));
continue; // just skip it continue; // just skip it
} }
#ifdef __3DS__ #ifdef __3DS__
@ -1867,6 +1866,8 @@ bool FtpSession::storeTransfer ()
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
void FtpSession::ABOR (char const *args_) void FtpSession::ABOR (char const *args_)
{ {
(void)args_;
if (m_state == State::COMMAND) if (m_state == State::COMMAND)
{ {
sendResponse ("225 No transfer to abort\r\n"); sendResponse ("225 No transfer to abort\r\n");
@ -1881,6 +1882,8 @@ void FtpSession::ABOR (char const *args_)
void FtpSession::ALLO (char const *args_) void FtpSession::ALLO (char const *args_)
{ {
(void)args_;
sendResponse ("202 Superfluous command\r\n"); sendResponse ("202 Superfluous command\r\n");
setState (State::COMMAND, false, false); setState (State::COMMAND, false, false);
} }
@ -1900,6 +1903,8 @@ void FtpSession::APPE (char const *args_)
void FtpSession::CDUP (char const *args_) void FtpSession::CDUP (char const *args_)
{ {
(void)args_;
setState (State::COMMAND, false, false); setState (State::COMMAND, false, false);
if (!authorized ()) if (!authorized ())
@ -1966,6 +1971,8 @@ void FtpSession::DELE (char const *args_)
} }
void FtpSession::FEAT (char const *args_) void FtpSession::FEAT (char const *args_)
{ {
(void)args_;
setState (State::COMMAND, false, false); setState (State::COMMAND, false, false);
sendResponse ("211-\r\n" sendResponse ("211-\r\n"
" MDTM\r\n" " MDTM\r\n"
@ -1985,6 +1992,8 @@ void FtpSession::FEAT (char const *args_)
void FtpSession::HELP (char const *args_) void FtpSession::HELP (char const *args_)
{ {
(void)args_;
setState (State::COMMAND, false, false); setState (State::COMMAND, false, false);
sendResponse ("214-\r\n" sendResponse ("214-\r\n"
"The following commands are recognized\r\n" "The following commands are recognized\r\n"
@ -2009,6 +2018,8 @@ void FtpSession::LIST (char const *args_)
void FtpSession::MDTM (char const *args_) void FtpSession::MDTM (char const *args_)
{ {
(void)args_;
setState (State::COMMAND, false, false); setState (State::COMMAND, false, false);
if (!authorized ()) if (!authorized ())
@ -2104,6 +2115,8 @@ void FtpSession::NLST (char const *args_)
void FtpSession::NOOP (char const *args_) void FtpSession::NOOP (char const *args_)
{ {
(void)args_;
sendResponse ("200 OK\r\n"); sendResponse ("200 OK\r\n");
} }
@ -2201,6 +2214,8 @@ void FtpSession::PASS (char const *args_)
void FtpSession::PASV (char const *args_) void FtpSession::PASV (char const *args_)
{ {
(void)args_;
if (!authorized ()) if (!authorized ())
{ {
setState (State::COMMAND, false, false); setState (State::COMMAND, false, false);
@ -2364,6 +2379,8 @@ void FtpSession::PORT (char const *args_)
void FtpSession::PWD (char const *args_) void FtpSession::PWD (char const *args_)
{ {
(void)args_;
if (!authorized ()) if (!authorized ())
{ {
sendResponse ("530 Not logged in\r\n"); sendResponse ("530 Not logged in\r\n");
@ -2381,6 +2398,8 @@ void FtpSession::PWD (char const *args_)
void FtpSession::QUIT (char const *args_) void FtpSession::QUIT (char const *args_)
{ {
(void)args_;
sendResponse ("221 Disconnecting\r\n"); sendResponse ("221 Disconnecting\r\n");
closeCommand (); closeCommand ();
} }
@ -2756,6 +2775,8 @@ void FtpSession::STOR (char const *args_)
void FtpSession::STOU (char const *args_) void FtpSession::STOU (char const *args_)
{ {
(void)args_;
setState (State::COMMAND, false, false); setState (State::COMMAND, false, false);
sendResponse ("502 Command not implemented\r\n"); sendResponse ("502 Command not implemented\r\n");
} }
@ -2776,12 +2797,16 @@ void FtpSession::STRU (char const *args_)
void FtpSession::SYST (char const *args_) void FtpSession::SYST (char const *args_)
{ {
(void)args_;
setState (State::COMMAND, false, false); setState (State::COMMAND, false, false);
sendResponse ("215 UNIX Type: L8\r\n"); sendResponse ("215 UNIX Type: L8\r\n");
} }
void FtpSession::TYPE (char const *args_) void FtpSession::TYPE (char const *args_)
{ {
(void)args_;
setState (State::COMMAND, false, false); setState (State::COMMAND, false, false);
// we always transfer in binary mode // we always transfer in binary mode

View File

@ -191,6 +191,8 @@ void debug (char const *const fmt_, ...)
va_start (ap, fmt_); va_start (ap, fmt_);
addLog (DEBUG, fmt_, ap); addLog (DEBUG, fmt_, ap);
va_end (ap); va_end (ap);
#else
(void)fmt_;
#endif #endif
} }

View File

@ -3,7 +3,7 @@
// - RFC 3659 (https://tools.ietf.org/html/rfc3659) // - RFC 3659 (https://tools.ietf.org/html/rfc3659)
// - suggested implementation details from https://cr.yp.to/ftp/filesystem.html // - suggested implementation details from https://cr.yp.to/ftp/filesystem.html
// //
// Copyright (C) 2022 Michael Theall // Copyright (C) 2023 Michael Theall
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
@ -31,7 +31,7 @@
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
int main (int argc_, char *argv_[]) int main ()
{ {
#ifndef CLASSIC #ifndef CLASSIC
curl_global_init (CURL_GLOBAL_ALL); curl_global_init (CURL_GLOBAL_ALL);

View File

@ -151,6 +151,8 @@ char const *SockAddr::name (char *buffer_, std::size_t size_) const
{ {
case AF_INET: case AF_INET:
#ifdef __NDS__ #ifdef __NDS__
(void)buffer_;
(void)size_;
return inet_ntoa (reinterpret_cast<struct sockaddr_in const *> (&m_addr)->sin_addr); return inet_ntoa (reinterpret_cast<struct sockaddr_in const *> (&m_addr)->sin_addr);
#else #else
return inet_ntop (AF_INET, return inet_ntop (AF_INET,

View File

@ -181,6 +181,8 @@ bool Socket::shutdown (int const how_)
bool Socket::setLinger (bool const enable_, std::chrono::seconds const time_) bool Socket::setLinger (bool const enable_, std::chrono::seconds const time_)
{ {
#ifdef __NDS__ #ifdef __NDS__
(void)enable_;
(void)time_;
errno = ENOSYS; errno = ENOSYS;
return -1; return -1;
#else #else

View File

@ -5,7 +5,7 @@
// //
// The MIT License (MIT) // The MIT License (MIT)
// //
// Copyright (C) 2020 Michael Theall // Copyright (C) 2023 Michael Theall
// //
// Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal // of this software and associated documentation files (the "Software"), to deal
@ -210,7 +210,7 @@ DkCmdList setupRenderState (dk::UniqueCmdBuf &cmdBuf_,
vertUBO.projMtx = glm::orthoRH_ZO (L, R, B, T, -1.0f, 1.0f); vertUBO.projMtx = glm::orthoRH_ZO (L, R, B, T, -1.0f, 1.0f);
// create command buffer to initialize/reset render state // create command buffer to initialize/reset render state
cmdBuf_.setViewports (0, DkViewport{0.0f, 0.0f, width_, height_}); cmdBuf_.setViewports (0, DkViewport{0.0f, 0.0f, (float)width_, (float)height_, 0.0f, 0.0f});
cmdBuf_.bindShaders (DkStageFlag_GraphicsMask, {&s_shaders[0], &s_shaders[1]}); cmdBuf_.bindShaders (DkStageFlag_GraphicsMask, {&s_shaders[0], &s_shaders[1]});
cmdBuf_.bindUniformBuffer (DkStage_Vertex, cmdBuf_.bindUniformBuffer (DkStage_Vertex,
0, 0,
@ -328,7 +328,9 @@ void imgui::deko3d::init (dk::UniqueDevice &device_,
// copy font texture atlas to image view // copy font texture atlas to image view
dk::ImageView imageView{fontTexture}; dk::ImageView imageView{fontTexture};
cmdBuf_.copyBufferToImage ({memBlock.getGpuAddr ()}, imageView, {0, 0, 0, width, height, 1}); cmdBuf_.copyBufferToImage ({memBlock.getGpuAddr (), 0, 0},
imageView,
{0, 0, 0, (unsigned int)width, (unsigned int)height, 1});
// submit commands to transfer font texture // submit commands to transfer font texture
queue_.submitCommands (cmdBuf_.finishList ()); queue_.submitCommands (cmdBuf_.finishList ());
@ -487,8 +489,11 @@ void imgui::deko3d::render (dk::UniqueDevice &device_,
clip.w = height; clip.w = height;
// apply scissor boundaries // apply scissor boundaries
cmdBuf_.setScissors ( cmdBuf_.setScissors (0,
0, DkScissor{clip.x, clip.y, clip.z - clip.x, clip.w - clip.y}); DkScissor{(unsigned int)clip.x,
(unsigned int)clip.y,
(unsigned int)(clip.z - clip.x),
(unsigned int)(clip.w - clip.y)});
// get texture handle // get texture handle
auto const textureHandle = reinterpret_cast<std::uintptr_t> (cmd.TextureId); auto const textureHandle = reinterpret_cast<std::uintptr_t> (cmd.TextureId);

View File

@ -1357,6 +1357,8 @@ void setClipboardText (void *const userData_, char const *const text_)
/// \param force_ Whether to ignore prior mouse position /// \param force_ Whether to ignore prior mouse position
void moveMouse (ImGuiIO &io_, ImVec2 const &pos_, bool const force_ = false) void moveMouse (ImGuiIO &io_, ImVec2 const &pos_, bool const force_ = false)
{ {
(void)io_;
// get update timestamp // get update timestamp
auto const now = std::chrono::steady_clock::now (); auto const now = std::chrono::steady_clock::now ();
@ -1606,14 +1608,14 @@ bool imgui::nx::init ()
auto rc = setInitialize (); auto rc = setInitialize ();
if (R_FAILED (rc)) if (R_FAILED (rc))
{ {
std::fprintf (stderr, "setInitialize: 0x%lx\n", rc); std::fprintf (stderr, "setInitialize: 0x%x\n", rc);
return false; return false;
} }
rc = setGetSystemLanguage (&languageCode); rc = setGetSystemLanguage (&languageCode);
if (R_FAILED (rc)) if (R_FAILED (rc))
{ {
std::fprintf (stderr, "setGetSystemLanguage: 0x%lx\n", rc); std::fprintf (stderr, "setGetSystemLanguage: 0x%x\n", rc);
setExit (); setExit ();
return false; return false;
} }
@ -1625,7 +1627,7 @@ bool imgui::nx::init ()
rc = plGetSharedFont (languageCode, fonts.data (), fonts.size (), &numFonts); rc = plGetSharedFont (languageCode, fonts.data (), fonts.size (), &numFonts);
if (R_FAILED (rc)) if (R_FAILED (rc))
{ {
std::fprintf (stderr, "plGetSharedFont: 0x%lx\n", rc); std::fprintf (stderr, "plGetSharedFont: 0x%x\n", rc);
return false; return false;
} }
fonts.resize (numFonts); fonts.resize (numFonts);

View File

@ -402,7 +402,7 @@ void loadTextures ()
// copy texture to image // copy texture to image
dk::ImageView imageView (image); dk::ImageView imageView (image);
cmdBuf.copyBufferToImage ({memBlock.getGpuAddr ()}, cmdBuf.copyBufferToImage ({memBlock.getGpuAddr (), 0, 0},
imageView, imageView,
{0, 0, 0, textureInfo.width, textureInfo.height, 1}); {0, 0, 0, textureInfo.width, textureInfo.height, 1});
s_queue.submitCommands (cmdBuf.finishList ()); s_queue.submitCommands (cmdBuf.finishList ());