Skip to content

Commit 14b10cb

Browse files
committed
Use maybe_unused attribute instead of casting variables to void
1 parent 8690807 commit 14b10cb

13 files changed

+33
-80
lines changed

gframe/CGUICustomTabControl/CGUICustomTabControl.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ s32 CGUICustomTabControl::getTabIndex(const IGUIElement *tab) const
802802

803803
//! Removes a child.
804804
void CGUICustomTabControl::removeChild(IGUIElement* child) {
805-
bool isTab = false;
805+
[[maybe_unused]] bool isTab = false;
806806

807807
u32 i = 0;
808808
// check if it is a tab
@@ -814,7 +814,6 @@ void CGUICustomTabControl::removeChild(IGUIElement* child) {
814814
} else
815815
++i;
816816
}
817-
(void)isTab;
818817

819818
#if !(IRRLICHT_VERSION_MAJOR==1 && IRRLICHT_VERSION_MINOR==9)
820819
// reassign numbers

gframe/bufferio.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ class BufferIO {
5050
private:
5151
static constexpr inline bool isUtf16 = sizeof(wchar_t) == 2;
5252
template<bool check_output_size = false>
53-
static int EncodeUTF8internal(epro::wstringview source, char* out, size_t size = 0) {
54-
(void)size;
53+
static int EncodeUTF8internal(epro::wstringview source, char* out, [[maybe_unused]] size_t size = 0) {
5554
char* pstr = out;
5655
auto GetNextSize = [](auto cur) -> size_t {
5756
if(cur < 0x80u)
@@ -112,8 +111,7 @@ class BufferIO {
112111
return static_cast<int>(out - pstr);
113112
}
114113
template<bool check_output_size = false>
115-
static int DecodeUTF8internal(epro::stringview source, wchar_t* out, size_t size = 0) {
116-
(void)size;
114+
static int DecodeUTF8internal(epro::stringview source, wchar_t* out, [[maybe_unused]] size_t size = 0) {
117115
wchar_t* pstr = out;
118116
while(!source.empty()) {
119117
auto first_codepoint = static_cast<unsigned char>(*source.begin());

gframe/client_updater.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ struct Payload {
4545
};
4646

4747
template<typename off_type>
48-
static int progress_callback(void* ptr, off_type TotalToDownload, off_type NowDownloaded, off_type TotalToUpload, off_type NowUploaded) {
49-
(void)TotalToUpload;
50-
(void)NowUploaded;
48+
static int progress_callback(void* ptr, off_type TotalToDownload, [[maybe_unused]] off_type NowDownloaded, [[maybe_unused]] off_type TotalToUpload, off_type NowUploaded) {
5149
Payload* payload = static_cast<Payload*>(ptr);
5250
if(payload && payload->callback) {
5351
int percentage = 0;

gframe/deck_manager.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,7 @@ bool DeckManager::ImportDeckBase64Omega(Deck& deck, epro::wstringview buffer) {
578578
LoadDeckFromBuffer(deck, reinterpret_cast<uint32_t*>(out_buf + 2), mainc, sidec);
579579
return true;
580580
}
581-
bool DeckManager::DeleteDeck(Deck& deck, epro::path_stringview name) {
582-
(void)deck;
581+
bool DeckManager::DeleteDeck([[maybe_unused]] Deck& deck, epro::path_stringview name) {
583582
return Utils::FileDelete(epro::format(EPRO_TEXT("./deck/{}.ydk"), name));
584583
}
585584
bool DeckManager::RenameDeck(epro::path_stringview oldname, epro::path_stringview newname) {

gframe/discord_wrapper.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ bool DiscordWrapper::Initialize() {
4848
#endif //DISCORD_APP_ID
4949
}
5050

51-
void DiscordWrapper::UpdatePresence(PresenceType type) {
52-
(void)type;
51+
void DiscordWrapper::UpdatePresence([[maybe_unused]] PresenceType type) {
5352
#ifdef DISCORD_APP_ID
5453
auto CreateSecret = [&secret_buf=secret_buf](bool update) {
5554
if(update) {

gframe/duelclient.cpp

+3-8
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,7 @@ bool DuelClient::StartClient(const epro::Address& ip, uint16_t port, uint32_t ga
146146
client_thread = epro::thread(ClientThread);
147147
return true;
148148
}
149-
void DuelClient::ConnectTimeout(evutil_socket_t fd, short events, void* arg) {
150-
(void)fd;
151-
(void)events;
152-
(void)arg;
149+
void DuelClient::ConnectTimeout([[maybe_unused]] evutil_socket_t fd, [[maybe_unused]] short events, [[maybe_unused]] void* arg) {
153150
if(connect_state & 0x7)
154151
return;
155152
if(!is_closing) {
@@ -192,8 +189,7 @@ void DuelClient::StopClient(bool is_exiting) {
192189
client_thread.join();
193190
mainGame->frameSignal.SetNoWait(false);
194191
}
195-
void DuelClient::ClientRead(bufferevent* bev, void* ctx) {
196-
(void)ctx;
192+
void DuelClient::ClientRead(bufferevent* bev, [[maybe_unused]] void* ctx) {
197193
evbuffer* input = bufferevent_get_input(bev);
198194
size_t len = evbuffer_get_length(input);
199195
uint16_t packet_len = 0;
@@ -214,8 +210,7 @@ void DuelClient::ClientRead(bufferevent* bev, void* ctx) {
214210

215211
#define INTERNAL_HANDLE_CONNECTION_END 0
216212

217-
void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
218-
(void)bev;
213+
void DuelClient::ClientEvent([[maybe_unused]] bufferevent *bev, short events, void *ctx) {
219214
if (events & BEV_EVENT_CONNECTED) {
220215
bool create_game = (size_t)ctx != 0;
221216
CTOS_PlayerInfo cspi;

gframe/generic_duel.cpp

+5-14
Original file line numberDiff line numberDiff line change
@@ -788,9 +788,7 @@ void GenericDuel::Surrender(DuelPlayer* dp) {
788788
}
789789
}
790790
#define SEND(to) NetServer::SendCoreUtilsPacketToPlayer(to, STOC_GAME_MSG, packet)
791-
void GenericDuel::BeforeParsing(const CoreUtils::Packet& packet, int& return_value, bool& record, bool& record_last) {
792-
(void)return_value;
793-
(void)record;
791+
void GenericDuel::BeforeParsing(const CoreUtils::Packet& packet, [[maybe_unused]] int& return_value, [[maybe_unused]] bool& record, bool& record_last) {
794792
const auto* pbuf = packet.data();
795793
switch(packet.message) {
796794
case MSG_SELECT_BATTLECMD:
@@ -824,8 +822,7 @@ void GenericDuel::BeforeParsing(const CoreUtils::Packet& packet, int& return_val
824822
return;
825823
}
826824
}
827-
void GenericDuel::Sending(CoreUtils::Packet& packet, int& return_value, bool& record, bool& record_last) {
828-
(void)record_last;
825+
void GenericDuel::Sending(CoreUtils::Packet& packet, int& return_value, bool& record, [[maybe_unused]] bool& record_last) {
829826
uint8_t& message = packet.message;
830827
uint32_t type, count;
831828
uint8_t player;
@@ -1118,10 +1115,7 @@ void GenericDuel::Sending(CoreUtils::Packet& packet, int& return_value, bool& re
11181115
}
11191116
#undef SEND
11201117

1121-
void GenericDuel::AfterParsing(const CoreUtils::Packet& packet, int& return_value, bool& record, bool& record_last) {
1122-
(void)return_value;
1123-
(void)record;
1124-
(void)record_last;
1118+
void GenericDuel::AfterParsing(const CoreUtils::Packet& packet, [[maybe_unused]] int& return_value, [[maybe_unused]] bool& record, [[maybe_unused]] bool& record_last) {
11251119
const auto message = packet.message;
11261120
int player;
11271121
const auto* pbuf = packet.data();
@@ -1322,8 +1316,7 @@ void GenericDuel::WaitforResponse(uint8_t playerid) {
13221316
}
13231317
cur_player[playerid]->state = CTOS_RESPONSE;
13241318
}
1325-
void GenericDuel::TimeConfirm(DuelPlayer* dp) {
1326-
(void)dp;
1319+
void GenericDuel::TimeConfirm([[maybe_unused]] DuelPlayer* dp) {
13271320
return;
13281321
/*if(host_info.time_limit == 0)
13291322
return;
@@ -1415,9 +1408,7 @@ void GenericDuel::PseudoRefreshDeck(uint8_t player, uint32_t flag) {
14151408
memcpy(&buffer[3], buff, len);
14161409
replay_stream.emplace_back(buffer.data(), buffer.size() - 1);
14171410
}
1418-
void GenericDuel::GenericTimer(evutil_socket_t fd, short events, void* arg) {
1419-
(void)fd;
1420-
(void)events;
1411+
void GenericDuel::GenericTimer([[maybe_unused]] evutil_socket_t fd, [[maybe_unused]] short events, void* arg) {
14211412
GenericDuel* sd = static_cast<GenericDuel*>(arg);
14221413
if(sd->last_response < 2 && sd->cur_player[sd->last_response]->state == CTOS_RESPONSE) {
14231414
if(sd->grace_period >= 0) {

gframe/ireadfile_sqlite.cpp

+4-11
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ int fileFileSize(sqlite3_file* file, sqlite3_int64* size) {
3939
return SQLITE_OK;
4040
}
4141

42-
int fileCheckReservedLock(sqlite3_file* file, int* result) {
43-
(void)file;
42+
int fileCheckReservedLock([[maybe_unused]] sqlite3_file* file, int* result) {
4443
*result = 0;
4544
return SQLITE_OK;
4645
}
@@ -63,9 +62,7 @@ constexpr sqlite3_io_methods iomethods{
6362

6463
//===========================================================================
6564

66-
int vfsOpen(sqlite3_vfs* vfs, const char* path, sqlite3_file* file, int flags, int* outflags) {
67-
(void)vfs;
68-
65+
int vfsOpen([[maybe_unused]] sqlite3_vfs* vfs, const char* path, sqlite3_file* file, int flags, int* outflags) {
6966
if(!(SQLITE_OPEN_READONLY & flags))
7067
return SQLITE_ERROR;
7168

@@ -82,16 +79,12 @@ int vfsOpen(sqlite3_vfs* vfs, const char* path, sqlite3_file* file, int flags, i
8279
return SQLITE_OK;
8380
}
8481

85-
int vfsAccess(sqlite3_vfs* vfs, const char* path, int flags, int* result) {
86-
(void)vfs;
87-
(void)path;
88-
(void)flags;
82+
int vfsAccess([[maybe_unused]] sqlite3_vfs* vfs, [[maybe_unused]] const char* path, [[maybe_unused]] int flags, int* result) {
8983
*result = 0;
9084
return SQLITE_OK;
9185
}
9286

93-
int vfsFullPathname(sqlite3_vfs* vfs, const char* path, int len, char* fullpath) {
94-
(void)vfs;
87+
int vfsFullPathname([[maybe_unused]] sqlite3_vfs* vfs, const char* path, int len, char* fullpath) {
9588
sqlite3_snprintf(len, fullpath, "%s", path);
9689
return SQLITE_OK;
9790
}

gframe/joystick_wrapper.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "joystick_wrapper.h"
22
#ifndef YGOPRO_USE_JOYSTICK
3-
JWrapper::JWrapper(irr::IrrlichtDevice* _device) {
4-
(void)_device;
3+
JWrapper::JWrapper([[maybe_unused]] irr::IrrlichtDevice* _device) {
54
}
65

76
JWrapper::~JWrapper() {

gframe/netserver.cpp

+6-15
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,7 @@ void NetServer::StopListen() {
203203
evconnlistener_disable(listener);
204204
StopBroadcast();
205205
}
206-
void NetServer::BroadcastEvent(evutil_socket_t fd, short events, void* arg) {
207-
(void)events;
208-
(void)arg;
206+
void NetServer::BroadcastEvent(evutil_socket_t fd, [[maybe_unused]] short events, [[maybe_unused]] void* arg) {
209207
sockaddr_storage bc_addr;
210208
ev_socklen_t sz = sizeof(bc_addr);
211209
char buf[256];
@@ -227,11 +225,8 @@ void NetServer::BroadcastEvent(evutil_socket_t fd, short events, void* arg) {
227225
sendto(fd, (const char*)&hp, sizeof(HostPacket), 0, (sockaddr*)&bc_addr, bc_addr.ss_family == AF_INET ? sizeof(sockaddr_in) : sizeof(sockaddr_in6));
228226
}
229227
}
230-
void NetServer::ServerAccept(evconnlistener* bev_listener, evutil_socket_t fd, sockaddr* address, int socklen, void* ctx) {
231-
(void)bev_listener;
232-
(void)address;
233-
(void)socklen;
234-
(void)ctx;
228+
void NetServer::ServerAccept([[maybe_unused]] evconnlistener* bev_listener, evutil_socket_t fd, [[maybe_unused]] sockaddr* address,
229+
[[maybe_unused]] int socklen, [[maybe_unused]] void* ctx) {
235230
bufferevent* bev = bufferevent_socket_new(net_evbase, fd, BEV_OPT_CLOSE_ON_FREE);
236231
DuelPlayer dp;
237232
dp.name[0] = 0;
@@ -241,13 +236,10 @@ void NetServer::ServerAccept(evconnlistener* bev_listener, evutil_socket_t fd, s
241236
bufferevent_setcb(bev, ServerEchoRead, nullptr, ServerEchoEvent, nullptr);
242237
bufferevent_enable(bev, EV_READ);
243238
}
244-
void NetServer::ServerAcceptError(evconnlistener* bev_listener, void* ctx) {
245-
(void)bev_listener;
246-
(void)ctx;
239+
void NetServer::ServerAcceptError([[maybe_unused]] evconnlistener* bev_listener, [[maybe_unused]] void* ctx) {
247240
event_base_loopexit(net_evbase, 0);
248241
}
249-
void NetServer::ServerEchoRead(bufferevent *bev, void *ctx) {
250-
(void)ctx;
242+
void NetServer::ServerEchoRead(bufferevent *bev, [[maybe_unused]] void *ctx) {
251243
evbuffer* input = bufferevent_get_input(bev);
252244
size_t len = evbuffer_get_length(input);
253245
uint16_t packet_len = 0;
@@ -263,8 +255,7 @@ void NetServer::ServerEchoRead(bufferevent *bev, void *ctx) {
263255
len -= packet_len + 2;
264256
}
265257
}
266-
void NetServer::ServerEchoEvent(bufferevent* bev, short events, void* ctx) {
267-
(void)ctx;
258+
void NetServer::ServerEchoEvent(bufferevent* bev, short events, [[maybe_unused]] void* ctx) {
268259
if (events & (BEV_EVENT_EOF | BEV_EVENT_ERROR)) {
269260
DuelPlayer* dp = &users[bev];
270261
DuelMode* dm = dp->game;

gframe/repo_manager.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,7 @@ int RepoManager::FetchCb(const git_indexer_progress* stats, void* payload) {
364364
return pl->rm->fetchReturnValue;
365365
}
366366

367-
void RepoManager::CheckoutCb(const char* path, size_t completed_steps, size_t total_steps, void* payload) {
368-
(void)path;
367+
void RepoManager::CheckoutCb([[maybe_unused]] const char* path, size_t completed_steps, size_t total_steps, void* payload) {
369368
int percent;
370369
if(total_steps == 0)
371370
percent = CHECKOUT_PERCENTAGE;

gframe/utils.cpp

+4-9
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ struct THREADNAME_INFO {
7070
DWORD dwFlags; // Reserved for future use, must be zero.
7171
};
7272

73-
LONG NTAPI PvectoredExceptionHandler(EXCEPTION_POINTERS* ExceptionInfo) {
74-
(void)ExceptionInfo;
73+
LONG NTAPI PvectoredExceptionHandler([[maybe_unused]] EXCEPTION_POINTERS* ExceptionInfo) {
7574
return EXCEPTION_CONTINUE_EXECUTION;
7675
}
7776

@@ -173,8 +172,7 @@ namespace ygo {
173172

174173
RNG::SplitMix64 Utils::generator(std::chrono::high_resolution_clock::now().time_since_epoch().count());
175174

176-
void Utils::InternalSetThreadName(const char* name, const wchar_t* wname) {
177-
(void)wname;
175+
void Utils::InternalSetThreadName(const char* name, [[maybe_unused]] const wchar_t* wname) {
178176
#if EDOPRO_WINDOWS
179177
NameThread(name, wname);
180178
#elif EDOPRO_LINUX_KERNEL
@@ -276,7 +274,7 @@ namespace ygo {
276274
return SetLastErrorStringIfFailed(mkdir(path.data(), 0777) == 0 || errno == EEXIST);
277275
#endif
278276
}
279-
bool Utils::FileCopyFD(int source, int destination) {
277+
bool Utils::FileCopyFD([[maybe_unused]] int source, [[maybe_unused]] int destination) {
280278
#if EDOPRO_LINUX_KERNEL
281279
off_t bytesCopied = 0;
282280
Stat fileinfo{};
@@ -286,8 +284,6 @@ namespace ygo {
286284
#elif EDOPRO_APPLE
287285
return SetLastErrorStringIfFailed(fcopyfile(source, destination, 0, COPYFILE_ALL) == 0);
288286
#else
289-
(void)source;
290-
(void)destination;
291287
return false;
292288
#endif
293289
}
@@ -769,15 +765,14 @@ namespace ygo {
769765
chmod(path.data(), fileStat.st_mode | S_IXUSR | S_IXGRP | S_IXOTH);
770766
#endif
771767
{
772-
const auto* path_cstr = path.data();
768+
[[maybe_unused]] const auto* path_cstr = path.data();
773769
const auto& workdir = GetWorkingDirectory();
774770
const auto* workdir_cstr = workdir.data();
775771
auto pid = vfork();
776772
if(pid == 0) {
777773
#if EDOPRO_LINUX
778774
execl(path_cstr, path_cstr, "-C", workdir_cstr, "-l", nullptr);
779775
#else
780-
(void)path_cstr;
781776
execlp("open", "open", "-b", "io.github.edo9300.ygoprodll", "--args", "-C", workdir_cstr, "-l", nullptr);
782777
#endif
783778
_exit(EXIT_FAILURE);

gframe/utils_gui.cpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ static HWND GetWindowHandle(irr::video::IVideoDriver* driver) {
6262
}
6363
#endif
6464

65-
static inline irr::video::E_DRIVER_TYPE getDefaultDriver(irr::E_DEVICE_TYPE device_type) {
66-
(void)device_type;
65+
static inline irr::video::E_DRIVER_TYPE getDefaultDriver([[maybe_unused]] irr::E_DEVICE_TYPE device_type) {
6766
#if EDOPRO_ANDROID
6867
return irr::video::EDT_OGLES2;
6968
#elif EDOPRO_IOS
@@ -211,8 +210,7 @@ bool GUIUtils::TakeScreenshot(std::shared_ptr<irr::IrrlichtDevice>& device) {
211210
return written;
212211
}
213212
#if (IRRLICHT_VERSION_MAJOR==1 && IRRLICHT_VERSION_MINOR==9)
214-
void GUIUtils::ToggleFullscreen(std::shared_ptr<irr::IrrlichtDevice>& device, bool& fullscreen) {
215-
(void)fullscreen;
213+
void GUIUtils::ToggleFullscreen(std::shared_ptr<irr::IrrlichtDevice>& device, [[maybe_unused]] bool& fullscreen) {
216214
#if EDOPRO_MACOS
217215
EDOPRO_ToggleFullScreen();
218216
#elif EDOPRO_WINDOWS || EDOPRO_LINUX
@@ -229,8 +227,7 @@ static BOOL CALLBACK callback(HMONITOR hMon, HDC hdc, LPRECT lprcMonitor, LPARAM
229227
return TRUE;
230228
}
231229
#endif
232-
void GUIUtils::ToggleFullscreen(std::shared_ptr<irr::IrrlichtDevice>& device, bool& fullscreen) {
233-
(void)fullscreen;
230+
void GUIUtils::ToggleFullscreen(std::shared_ptr<irr::IrrlichtDevice>& device, [[maybe_unused]] bool& fullscreen) {
234231
#if EDOPRO_MACOS
235232
EDOPRO_ToggleFullScreen();
236233
#elif EDOPRO_WINDOWS

0 commit comments

Comments
 (0)