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:
parent
b1e5cc66bd
commit
8bbeee1173
118 changed files with 720 additions and 679 deletions
|
|
@ -3,14 +3,13 @@
|
|||
|
||||
#include <format>
|
||||
#include <string>
|
||||
#include <errno.h>
|
||||
#include <cerrno>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <signal.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <csignal>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <sys/un.h>
|
||||
#include <unistd.h>
|
||||
#include <exception>
|
||||
|
|
@ -94,7 +93,7 @@ static int createSocket(struct sockaddr_un* addr, size_t path_size) {
|
|||
return fd;
|
||||
}
|
||||
|
||||
static bool checkPermissionsForSocketDir(void) {
|
||||
static bool checkPermissionsForSocketDir() {
|
||||
struct stat buf;
|
||||
|
||||
if (lstat("/tmp/.X11-unix", &buf)) {
|
||||
|
|
@ -107,7 +106,7 @@ static bool checkPermissionsForSocketDir(void) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!((buf.st_uid == 0) || (buf.st_uid == getuid()))) {
|
||||
if ((buf.st_uid != 0) && (buf.st_uid != getuid())) {
|
||||
Debug::log(ERR, "X11 socket dir is not owned by root or current user");
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ CXDataSource::CXDataSource(SXSelection& sel_) : selection(sel_) {
|
|||
1, // delete
|
||||
selection.window, HYPRATOMS["_WL_SELECTION"], XCB_GET_PROPERTY_TYPE_ANY, 0, 4096);
|
||||
|
||||
xcb_get_property_reply_t* reply = xcb_get_property_reply(g_pXWayland->pWM->connection, cookie, NULL);
|
||||
xcb_get_property_reply_t* reply = xcb_get_property_reply(g_pXWayland->pWM->connection, cookie, nullptr);
|
||||
if (!reply)
|
||||
return;
|
||||
|
||||
|
|
@ -23,9 +23,9 @@ CXDataSource::CXDataSource(SXSelection& sel_) : selection(sel_) {
|
|||
auto value = (xcb_atom_t*)xcb_get_property_value(reply);
|
||||
for (uint32_t i = 0; i < reply->value_len; i++) {
|
||||
if (value[i] == HYPRATOMS["UTF8_STRING"])
|
||||
mimeTypes.push_back("text/plain;charset=utf-8");
|
||||
mimeTypes.emplace_back("text/plain;charset=utf-8");
|
||||
else if (value[i] == HYPRATOMS["TEXT"])
|
||||
mimeTypes.push_back("text/plain");
|
||||
mimeTypes.emplace_back("text/plain");
|
||||
else if (value[i] != HYPRATOMS["TARGETS"] && value[i] != HYPRATOMS["TIMESTAMP"]) {
|
||||
|
||||
auto type = g_pXWayland->pWM->mimeFromAtom(value[i]);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ CXWaylandSurface::CXWaylandSurface(uint32_t xID_, CBox geometry_, bool OR) : xID
|
|||
}
|
||||
xcb_res_client_id_value_next(&iter);
|
||||
}
|
||||
if (ppid == NULL) {
|
||||
if (!ppid) {
|
||||
free(reply);
|
||||
return;
|
||||
}
|
||||
|
|
@ -208,7 +208,7 @@ void CXWaylandSurface::restackToTop() {
|
|||
}
|
||||
|
||||
void CXWaylandSurface::close() {
|
||||
xcb_client_message_data_t msg = {0};
|
||||
xcb_client_message_data_t msg = {};
|
||||
msg.data32[0] = HYPRATOMS["WM_DELETE_WINDOW"];
|
||||
msg.data32[1] = XCB_CURRENT_TIME;
|
||||
g_pXWayland->pWM->sendWMMessage(self.lock(), &msg, XCB_EVENT_MASK_NO_EVENT);
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ std::string CXWM::getAtomName(uint32_t atom) {
|
|||
|
||||
// Get the name of the atom
|
||||
auto const atom_name_cookie = xcb_get_atom_name(connection, atom);
|
||||
auto* atom_name_reply = xcb_get_atom_name_reply(connection, atom_name_cookie, NULL);
|
||||
auto* atom_name_reply = xcb_get_atom_name_reply(connection, atom_name_cookie, nullptr);
|
||||
|
||||
if (!atom_name_reply)
|
||||
return "Unknown";
|
||||
|
|
@ -247,7 +247,7 @@ void CXWM::readProp(SP<CXWaylandSurface> XSURF, uint32_t atom, xcb_get_property_
|
|||
if (XID) {
|
||||
if (const auto NEWXSURF = windowForXID(*XID); NEWXSURF && !lookupParentExists(XSURF, NEWXSURF)) {
|
||||
XSURF->parent = NEWXSURF;
|
||||
NEWXSURF->children.push_back(XSURF);
|
||||
NEWXSURF->children.emplace_back(XSURF);
|
||||
} else
|
||||
Debug::log(LOG, "[xwm] Denying transient because it would create a loop");
|
||||
}
|
||||
|
|
@ -763,7 +763,7 @@ void CXWM::gatherResources() {
|
|||
xcb_xfixes_query_version_cookie_t xfixes_cookie;
|
||||
xcb_xfixes_query_version_reply_t* xfixes_reply;
|
||||
xfixes_cookie = xcb_xfixes_query_version(connection, XCB_XFIXES_MAJOR_VERSION, XCB_XFIXES_MINOR_VERSION);
|
||||
xfixes_reply = xcb_xfixes_query_version_reply(connection, xfixes_cookie, NULL);
|
||||
xfixes_reply = xcb_xfixes_query_version_reply(connection, xfixes_cookie, nullptr);
|
||||
|
||||
Debug::log(LOG, "xfixes version: {}.{}", xfixes_reply->major_version, xfixes_reply->minor_version);
|
||||
xfixesMajor = xfixes_reply->major_version;
|
||||
|
|
@ -775,8 +775,8 @@ void CXWM::gatherResources() {
|
|||
return;
|
||||
|
||||
xcb_res_query_version_cookie_t xres_cookie = xcb_res_query_version(connection, XCB_RES_MAJOR_VERSION, XCB_RES_MINOR_VERSION);
|
||||
xcb_res_query_version_reply_t* xres_reply = xcb_res_query_version_reply(connection, xres_cookie, NULL);
|
||||
if (xres_reply == NULL)
|
||||
xcb_res_query_version_reply_t* xres_reply = xcb_res_query_version_reply(connection, xres_cookie, nullptr);
|
||||
if (xres_reply == nullptr)
|
||||
return;
|
||||
|
||||
Debug::log(LOG, "xres version: {}.{}", xres_reply->server_major, xres_reply->server_minor);
|
||||
|
|
@ -792,7 +792,7 @@ void CXWM::getVisual() {
|
|||
xcb_visualtype_t* visualtype;
|
||||
|
||||
d_iter = xcb_screen_allowed_depths_iterator(screen);
|
||||
visualtype = NULL;
|
||||
visualtype = nullptr;
|
||||
while (d_iter.rem > 0) {
|
||||
if (d_iter.data->depth == 32) {
|
||||
vt_iter = xcb_depth_visuals_iterator(d_iter.data);
|
||||
|
|
@ -803,7 +803,7 @@ void CXWM::getVisual() {
|
|||
xcb_depth_next(&d_iter);
|
||||
}
|
||||
|
||||
if (visualtype == NULL) {
|
||||
if (visualtype == nullptr) {
|
||||
Debug::log(LOG, "xwm: No 32-bit visualtype");
|
||||
return;
|
||||
}
|
||||
|
|
@ -815,13 +815,13 @@ void CXWM::getVisual() {
|
|||
|
||||
void CXWM::getRenderFormat() {
|
||||
xcb_render_query_pict_formats_cookie_t cookie = xcb_render_query_pict_formats(connection);
|
||||
xcb_render_query_pict_formats_reply_t* reply = xcb_render_query_pict_formats_reply(connection, cookie, NULL);
|
||||
xcb_render_query_pict_formats_reply_t* reply = xcb_render_query_pict_formats_reply(connection, cookie, nullptr);
|
||||
if (!reply) {
|
||||
Debug::log(LOG, "xwm: No xcb_render_query_pict_formats_reply_t reply");
|
||||
return;
|
||||
}
|
||||
xcb_render_pictforminfo_iterator_t iter = xcb_render_query_pict_formats_formats_iterator(reply);
|
||||
xcb_render_pictforminfo_t* format = NULL;
|
||||
xcb_render_pictforminfo_t* format = nullptr;
|
||||
while (iter.rem > 0) {
|
||||
if (iter.data->depth == 32) {
|
||||
format = iter.data;
|
||||
|
|
@ -831,7 +831,7 @@ void CXWM::getRenderFormat() {
|
|||
xcb_render_pictforminfo_next(&iter);
|
||||
}
|
||||
|
||||
if (format == NULL) {
|
||||
if (format == nullptr) {
|
||||
Debug::log(LOG, "xwm: No 32-bit render format");
|
||||
free(reply);
|
||||
return;
|
||||
|
|
@ -906,7 +906,7 @@ void CXWM::setActiveWindow(xcb_window_t window) {
|
|||
void CXWM::createWMWindow() {
|
||||
constexpr const char* wmName = "Hyprland :D";
|
||||
wmWindow = xcb_generate_id(connection);
|
||||
xcb_create_window(connection, XCB_COPY_FROM_PARENT, wmWindow, screen->root, 0, 0, 10, 10, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, 0, NULL);
|
||||
xcb_create_window(connection, XCB_COPY_FROM_PARENT, wmWindow, screen->root, 0, 0, 10, 10, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, 0, nullptr);
|
||||
xcb_change_property(connection, XCB_PROP_MODE_REPLACE, wmWindow, HYPRATOMS["_NET_WM_NAME"], HYPRATOMS["UTF8_STRING"],
|
||||
8, // format
|
||||
strlen(wmName), wmName);
|
||||
|
|
@ -986,7 +986,7 @@ void CXWM::onNewResource(SP<CXWaylandSurfaceResource> resource) {
|
|||
Debug::log(LOG, "[xwm] New XWayland resource at {:x}", (uintptr_t)resource.get());
|
||||
|
||||
std::erase_if(shellResources, [](const auto& e) { return e.expired(); });
|
||||
shellResources.push_back(resource);
|
||||
shellResources.emplace_back(resource);
|
||||
|
||||
for (auto const& surf : surfaces) {
|
||||
if (surf->resource || surf->wlSerial != resource->serial)
|
||||
|
|
@ -1157,7 +1157,7 @@ void CXWM::setCursor(unsigned char* pixData, uint32_t stride, const Vector2D& si
|
|||
xcb_render_create_picture(connection, pic, pix, render_format_id, 0, 0);
|
||||
|
||||
xcb_gcontext_t gc = xcb_generate_id(connection);
|
||||
xcb_create_gc(connection, gc, pix, 0, NULL);
|
||||
xcb_create_gc(connection, gc, pix, 0, nullptr);
|
||||
|
||||
xcb_put_image(connection, XCB_IMAGE_FORMAT_Z_PIXMAP, pix, gc, size.x, size.y, 0, 0, 0, CURSOR_DEPTH, stride * size.y * sizeof(uint8_t), pixData);
|
||||
xcb_free_gc(connection, gc);
|
||||
|
|
|
|||
|
|
@ -58,8 +58,8 @@ struct SXSelection {
|
|||
|
||||
class CXCBConnection {
|
||||
public:
|
||||
CXCBConnection(int fd) {
|
||||
connection = xcb_connect_to_fd(fd, nullptr);
|
||||
CXCBConnection(int fd) : connection{xcb_connect_to_fd(fd, nullptr)} {
|
||||
;
|
||||
}
|
||||
|
||||
~CXCBConnection() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue