core: Add clang-tidy (#8664)

This adds a .clang-tidy file for us.

It's not a strict requirement to be compliant, but I tuned it to be alright.
This commit is contained in:
Vaxry 2024-12-07 18:51:18 +01:00 committed by GitHub
parent b1e5cc66bd
commit 8bbeee1173
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
118 changed files with 720 additions and 679 deletions

View file

@ -14,10 +14,8 @@
#include <sys/stat.h>
#include <sys/types.h>
CFunctionHook::CFunctionHook(HANDLE owner, void* source, void* destination) {
m_pSource = source;
m_pDestination = destination;
m_pOwner = owner;
CFunctionHook::CFunctionHook(HANDLE owner, void* source, void* destination) : m_pSource(source), m_pDestination(destination), m_pOwner(owner) {
;
}
CFunctionHook::~CFunctionHook() {
@ -88,7 +86,7 @@ CFunctionHook::SAssembly CFunctionHook::fixInstructionProbeRIPCalls(const SInstr
finalBytes[currentDestinationOffset + i] = *(char*)(currentAddress + i);
}
std::string code = probe.assembly.substr(lastAsmNewline, probe.assembly.find("\n", lastAsmNewline) - lastAsmNewline);
std::string code = probe.assembly.substr(lastAsmNewline, probe.assembly.find('\n', lastAsmNewline) - lastAsmNewline);
if (code.contains("%rip")) {
CVarList tokens{code, 0, 's'};
size_t plusPresent = tokens[1][0] == '+' ? 1 : 0;
@ -132,7 +130,7 @@ CFunctionHook::SAssembly CFunctionHook::fixInstructionProbeRIPCalls(const SInstr
currentDestinationOffset += len;
}
lastAsmNewline = probe.assembly.find("\n", lastAsmNewline) + 1;
lastAsmNewline = probe.assembly.find('\n', lastAsmNewline) + 1;
currentAddress += len;
}

View file

@ -320,7 +320,7 @@ APICALL std::vector<SFunctionMatch> HyprlandAPI::findFunctionsByName(HANDLE hand
};
if (SYMBOLS.empty()) {
Debug::log(ERR, "Unable to search for function \"{}\": no symbols found in binary (is \"{}\" in path?)", name,
Debug::log(ERR, R"(Unable to search for function "{}": no symbols found in binary (is "{}" in path?))", name,
#ifdef __clang__
"llvm-nm"
#else

View file

@ -96,7 +96,7 @@ typedef REQUIRED PLUGIN_DESCRIPTION_INFO (*PPLUGIN_INIT_FUNC)(HANDLE);
Hooks are unloaded after exit.
*/
typedef OPTIONAL void (*PPLUGIN_EXIT_FUNC)(void);
typedef OPTIONAL void (*PPLUGIN_EXIT_FUNC)();
#define PLUGIN_EXIT pluginExit
#define PLUGIN_EXIT_FUNC_STR "pluginExit"
@ -104,6 +104,7 @@ typedef OPTIONAL void (*PPLUGIN_EXIT_FUNC)(void);
End plugin methods
*/
// NOLINTNEXTLINE(readability-identifier-naming)
namespace HyprlandAPI {
/*
@ -290,6 +291,7 @@ namespace HyprlandAPI {
APICALL bool unregisterHyprCtlCommand(HANDLE handle, SP<SHyprCtlCommand> cmd);
};
// NOLINTBEGIN
/*
Get the hash this plugin/server was compiled with.
@ -303,3 +305,4 @@ APICALL EXPORT const char* __hyprland_api_get_hash();
APICALL inline EXPORT const char* __hyprland_api_get_client_hash() {
return GIT_COMMIT_HASH;
}
// NOLINTEND

View file

@ -82,7 +82,7 @@ CPlugin* CPluginSystem::loadPlugin(const std::string& path) {
g_pConfigManager->m_bForceReload = true;
Debug::log(LOG, " [PluginSystem] Plugin {} loaded. Handle: {:x}, path: \"{}\", author: \"{}\", description: \"{}\", version: \"{}\"", PLUGINDATA.name, (uintptr_t)MODULE, path,
Debug::log(LOG, R"( [PluginSystem] Plugin {} loaded. Handle: {:x}, path: "{}", author: "{}", description: "{}", version: "{}")", PLUGINDATA.name, (uintptr_t)MODULE, path,
PLUGINDATA.author, PLUGINDATA.description, PLUGINDATA.version);
return PLUGIN;
@ -201,7 +201,7 @@ size_t CPluginSystem::pluginCount() {
return m_vLoadedPlugins.size();
}
void CPluginSystem::sig_getPlugins(CPlugin** data, size_t len) {
void CPluginSystem::sigGetPlugins(CPlugin** data, size_t len) {
for (size_t i = 0; i < std::min(m_vLoadedPlugins.size(), len); i++) {
data[i] = m_vLoadedPlugins[i].get();
}

View file

@ -38,7 +38,7 @@ class CPluginSystem {
CPlugin* getPluginByHandle(HANDLE handle);
std::vector<CPlugin*> getAllPlugins();
size_t pluginCount();
void sig_getPlugins(CPlugin** data, size_t len);
void sigGetPlugins(CPlugin** data, size_t len);
bool m_bAllowConfigVars = false;
std::string m_szLastError = "";