3
0
mirror of https://github.com/hyprwm/Hyprland.git synced 2025-10-29 11:22:47 +00:00

internal: fix clang-tidy "errors" (#11862)

This commit is contained in:
UjinT34 2025-09-29 15:10:15 +03:00 committed by GitHub
parent 43fb4753fc
commit 4d82cc5957
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 133 additions and 26 deletions

View File

@ -1,4 +1,111 @@
WarningsAsErrors: '*'
WarningsAsErrors: >
-*,
bugprone-*,
-bugprone-multi-level-implicit-pointer-conversion,
-bugprone-empty-catch,
-bugprone-unused-return-value,
-bugprone-reserved-identifier,
-bugprone-switch-missing-default-case,
-bugprone-unused-local-non-trivial-variable,
-bugprone-easily-swappable-parameters,
-bugprone-forward-declararion-namespace,
-bugprone-forward-declararion-namespace,
-bugprone-macro-parentheses,
-bugprone-narrowing-conversions,
-bugprone-branch-clone,
-bugprone-assignment-in-if-condition,
concurrency-*,
-concurrency-mt-unsafe,
cppcoreguidelines-*,
-cppcoreguidelines-pro-type-const-cast,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-avoid-const-or-ref-data-members,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-avoid-goto,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-avoid-do-while,
-cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-special-member-functions,
-cppcoreguidelines-explicit-virtual-functions,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-narrowing-conversions,
-cppcoreguidelines-pro-type-union-access,
-cppcoreguidelines-pro-type-member-init,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-macro-to-enum,
-cppcoreguidelines-init-variables,
-cppcoreguidelines-pro-type-cstyle-cast,
-cppcoreguidelines-pro-type-vararg,
-cppcoreguidelines-pro-type-reinterpret-cast,
-google-global-names-in-headers,
-google-readability-casting,
google-runtime-operator,
misc-*,
-misc-use-internal-linkage,
-misc-unused-parameters,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
-misc-include-cleaner,
-misc-use-anonymous-namespace,
-misc-const-correctness,
modernize-*,
-modernize-use-emplace,
-modernize-redundant-void-arg,
-modernize-use-starts-ends-with,
-modernize-use-designated-initializers,
-modernize-use-std-numbers,
-modernize-return-braced-init-list,
-modernize-use-trailing-return-type,
-modernize-use-using,
-modernize-use-override,
-modernize-avoid-c-arrays,
-modernize-macro-to-enum,
-modernize-loop-convert,
-modernize-use-nodiscard,
-modernize-pass-by-value,
-modernize-use-auto,
performance-*,
-performance-inefficient-vector-operation,
-performance-inefficient-string-concatenation,
-performance-enum-size,
-performance-move-const-arg,
-performance-avoid-endl,
-performance-unnecessary-value-param,
portability-std-allocator-const,
readability-*,
-readability-identifier-naming,
-readability-use-std-min-max,
-readability-math-missing-parentheses,
-readability-simplify-boolean-expr,
-readability-static-accessed-through-instance,
-readability-use-anyofallof,
-readability-enum-initial-value,
-readability-redundant-inline-specifier,
-readability-function-cognitive-complexity,
-readability-function-size,
-readability-identifier-length,
-readability-magic-numbers,
-readability-uppercase-literal-suffix,
-readability-braces-around-statements,
-readability-redundant-access-specifiers,
-readability-else-after-return,
-readability-container-data-pointer,
-readability-implicit-bool-conversion,
-readability-avoid-nested-conditional-operator,
-readability-redundant-member-init,
-readability-redundant-string-init,
-readability-avoid-const-params-in-decls,
-readability-named-parameter,
-readability-convert-member-functions-to-static,
-readability-qualified-auto,
-readability-make-member-function-const,
-readability-isolate-declaration,
-readability-inconsistent-declaration-parameter-name,
-clang-diagnostic-error,
HeaderFilterRegex: '.*\.hpp'
FormatStyle: file
Checks: >

View File

@ -3016,11 +3016,11 @@ std::optional<std::string> CConfigManager::handleSource(const std::string& comma
return "source= path " + rawpath + " bogus!";
}
std::unique_ptr<glob_t, void (*)(glob_t*)> glob_buf{sc<glob_t*>(calloc(1, sizeof(glob_t))), // allocate and zero-initialize
std::unique_ptr<glob_t, void (*)(glob_t*)> glob_buf{sc<glob_t*>(calloc(1, sizeof(glob_t))), // allocate and zero-initialize NOLINT(cppcoreguidelines-no-malloc)
[](glob_t* g) {
if (g) {
globfree(g); // free internal resources allocated by glob()
free(g); // free the memory for the glob_t structure
free(g); // free the memory for the glob_t structure NOLINT(cppcoreguidelines-no-malloc)
}
}};

View File

@ -155,10 +155,10 @@ void IKeyboard::updateKeymapFD() {
auto cKeymapStr = xkb_keymap_get_as_string(m_xkbKeymap, XKB_KEYMAP_FORMAT_TEXT_V2);
m_xkbKeymapString = cKeymapStr;
free(cKeymapStr);
free(cKeymapStr); // NOLINT(cppcoreguidelines-no-malloc,-warnings-as-errors)
auto cKeymapV1Str = xkb_keymap_get_as_string(m_xkbKeymap, XKB_KEYMAP_FORMAT_TEXT_V1);
m_xkbKeymapV1String = cKeymapV1Str;
free(cKeymapV1Str);
free(cKeymapV1Str); // NOLINT(cppcoreguidelines-no-malloc,-warnings-as-errors)
CFileDescriptor rw, ro, rwV1, roV1;
if (!allocateSHMFilePair(m_xkbKeymapString.length() + 1, rw, ro))

View File

@ -264,13 +264,13 @@ uint32_t NFormatUtils::glFormatToType(uint32_t gl) {
std::string NFormatUtils::drmFormatName(DRMFormat drm) {
auto n = drmGetFormatName(drm);
std::string name = n;
free(n);
free(n); // NOLINT(cppcoreguidelines-no-malloc,-warnings-as-errors)
return name;
}
std::string NFormatUtils::drmModifierName(uint64_t mod) {
auto n = drmGetFormatModifierName(mod);
std::string name = n;
free(n);
free(n); // NOLINT(cppcoreguidelines-no-malloc,-warnings-as-errors)
return name;
}

View File

@ -599,7 +599,7 @@ int64_t getPPIDof(int64_t pid) {
fclose(infile);
if (line)
free(line);
free(line); // NOLINT(cppcoreguidelines-no-malloc)
try {
return std::stoll(pidstr);

View File

@ -49,7 +49,7 @@ namespace NSplashes {
"By dt, do you mean damage tracking or distrotube?",
"Made in Poland",
"\"I use Arch, btw\" - John Cena",
"\"Hyper\".replace(\"e\", \"\")",
R"("Hyper".replace("e", ""))",
"\"my win11 install runs hyprland that is true\" - raf",
"\"stop playing league loser\" - hyprBot",
"\"If it ain't broke, don't fix it\" - Lucascito_03",

View File

@ -1103,8 +1103,8 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
const bool IGNORE_IF_MASTER = vars.size() >= 2 && std::ranges::any_of(vars, [](const auto& e) { return e == "ignoremaster"; });
if (PMASTER->pWindow.lock() != PWINDOW) {
const auto NEWMASTER = PWINDOW;
const bool newFocusToChild = vars.size() >= 2 && vars[1] == "child";
const auto& NEWMASTER = PWINDOW;
const bool newFocusToChild = vars.size() >= 2 && vars[1] == "child";
switchWindows(NEWMASTER, NEWCHILD);
const auto NEWFOCUS = newFocusToChild ? NEWCHILD : NEWMASTER;
switchToWindow(NEWFOCUS);

View File

@ -159,7 +159,7 @@ CLayerShellResource::CLayerShellResource(SP<CZwlrLayerSurfaceV1> resource_, SP<C
return;
}
if (anchor && (!m_pending.anchor || !(m_pending.anchor & anchor))) {
if (!m_pending.anchor || !(m_pending.anchor & anchor)) {
r->error(ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_EXCLUSIVE_EDGE, "Exclusive edge doesn't align with anchor");
return;
}

View File

@ -109,7 +109,7 @@ static int openRenderNode(int drmFd) {
if (render_version && render_version->name) {
Debug::log(LOG, "DRM dev versionName", render_version->name);
if (strcmp(render_version->name, "evdi") == 0) {
free(renderName);
free(renderName); // NOLINT(cppcoreguidelines-no-malloc)
renderName = strdup("/dev/dri/card0");
}
drmFreeVersion(render_version);
@ -122,7 +122,7 @@ static int openRenderNode(int drmFd) {
if (renderFD < 0)
Debug::log(ERR, "openRenderNode failed to open drm device {}", renderName);
free(renderName);
free(renderName); // NOLINT(cppcoreguidelines-no-malloc)
return renderFD;
}
@ -505,9 +505,9 @@ void CHyprOpenGLImpl::initDRMFormats() {
for (auto const& mod : mods) {
auto modName = drmGetFormatModifierName(mod);
modifierData.emplace_back(std::make_pair<>(mod, modName ? modName : "?unknown?"));
free(modName);
free(modName); // NOLINT(cppcoreguidelines-no-malloc)
}
free(fmtName);
free(fmtName); // NOLINT(cppcoreguidelines-no-malloc)
mods.clear();
std::ranges::sort(modifierData, [](const auto& a, const auto& b) {

View File

@ -64,9 +64,9 @@ xcb_window_t CX11DataDevice::getProxyWindow(xcb_window_t window) {
Debug::log(LOG, "Using XdndProxy window {:x} for window {:x}", proxyWindow, window);
}
}
free(proxyVerifyReply);
free(proxyVerifyReply); // NOLINT(cppcoreguidelines-no-malloc)
}
free(proxyReply);
free(proxyReply); // NOLINT(cppcoreguidelines-no-malloc)
return targetWindow;
}

View File

@ -17,7 +17,7 @@ CXDataSource::CXDataSource(SXSelection& sel_) : m_selection(sel_) {
return;
if (reply->type != XCB_ATOM_ATOM) {
free(reply);
free(reply); // NOLINT(cppcoreguidelines-no-malloc)
return;
}
@ -41,7 +41,7 @@ CXDataSource::CXDataSource(SXSelection& sel_) : m_selection(sel_) {
m_mimeAtoms.push_back(value[i]);
}
free(reply);
free(reply); // NOLINT(cppcoreguidelines-no-malloc)
}
std::vector<std::string> CXDataSource::mimes() {

View File

@ -35,11 +35,11 @@ CXWaylandSurface::CXWaylandSurface(uint32_t xID_, CBox geometry_, bool OR) : m_x
xcb_res_client_id_value_next(&iter);
}
if (!ppid) {
free(reply);
free(reply); // NOLINT(cppcoreguidelines-no-malloc)
return;
}
m_pid = *ppid;
free(reply);
free(reply); // NOLINT(cppcoreguidelines-no-malloc)
}
m_events.resourceChange.listenStatic([this] { ensureListeners(); });

View File

@ -33,7 +33,7 @@ static int onX11Event(int fd, uint32_t mask, void* data) {
struct SFreeDeleter {
void operator()(void* ptr) const {
std::free(ptr);
std::free(ptr); // NOLINT(cppcoreguidelines-no-malloc)
}
};
@ -1292,7 +1292,7 @@ void CXWM::getTransferData(SXSelection& sel) {
if (transfer->propertyReply->type == HYPRATOMS["INCR"]) {
transfer->incremental = true;
transfer->propertyStart = 0;
free(transfer->propertyReply);
free(transfer->propertyReply); // NOLINT(cppcoreguidelines-no-malloc)
transfer->propertyReply = nullptr;
return;
}
@ -1544,7 +1544,7 @@ int SXSelection::onWrite() {
if (!transfer->incremental) {
transfers.erase(it);
} else {
free(transfer->propertyReply);
free(transfer->propertyReply); // NOLINT(cppcoreguidelines-no-malloc)
transfer->propertyReply = nullptr;
transfer->propertyStart = 0;
}
@ -1559,7 +1559,7 @@ SXTransfer::~SXTransfer() {
if (incomingWindow)
xcb_destroy_window(*g_pXWayland->m_wm->m_connection, incomingWindow);
if (propertyReply)
free(propertyReply);
free(propertyReply); // NOLINT(cppcoreguidelines-no-malloc)
}
bool SXTransfer::getIncomingSelectionProp(bool erase) {