make indent

This commit is contained in:
Robert Swiecki
2026-04-10 20:53:36 +02:00
parent 273a691dd5
commit f2157650b6
4 changed files with 58 additions and 21 deletions

View File

@@ -9,6 +9,8 @@ AlignEscapedNewlines: Right
AlignOperands: true
AllowShortFunctionsOnASingleLine: false
AlwaysBreakBeforeMultilineStrings: false
BreakBeforeCloseBracketBracedList: true
Cpp11BracedListStyle: FunctionCall
IndentCaseLabels: false
---
Language: Proto

View File

@@ -110,10 +110,15 @@ bool addFd(int fd, uint32_t events, fdCb_t cb, void* data) {
if (fd < 0) {
return false;
}
current_ctx.fd_handlers[fd] = {.cb = cb, .data = data};
current_ctx.fd_handlers[fd] = {
.cb = cb,
.data = data,
};
struct epoll_event ev = {
.events = events,
.data = {.fd = fd},
.data = {
.fd = fd,
},
};
if (epoll_ctl(current_ctx.epoll_fd, EPOLL_CTL_ADD, fd, &ev) == -1) {
PLOG_W("epoll_ctl(EPOLL_CTL_ADD, fd=%d)", fd);
@@ -140,7 +145,9 @@ bool modFd(int fd, uint32_t events) {
}
struct epoll_event ev = {
.events = events,
.data = {.fd = fd},
.data = {
.fd = fd,
},
};
if (epoll_ctl(current_ctx.epoll_fd, EPOLL_CTL_MOD, fd, &ev) == -1) {
PLOG_W("epoll_ctl(EPOLL_CTL_MOD, fd=%d)", fd);
@@ -505,8 +512,8 @@ static void startMonitorThread(
auto it = nsj->pids.find(pid);
if (it != nsj->pids.end()) {
args.start_time = it->second.start;
snprintf(args.remote_txt, sizeof(args.remote_txt), "%s",
it->second.remote_txt.c_str());
snprintf(
args.remote_txt, sizeof(args.remote_txt), "%s", it->second.remote_txt.c_str());
}
*thread_out = std::thread(monitorThread, args);
@@ -681,7 +688,10 @@ int runStandaloneMode(nsj_t* nsj) {
time_t now = time(nullptr);
if (now - start_time < 1) {
LOG_I("Child exited too quickly, rate-limiting respawn");
struct timespec ts = {.tv_sec = 1, .tv_nsec = 0};
struct timespec ts = {
.tv_sec = 1,
.tv_nsec = 0,
};
ppoll(nullptr, 0, &ts, nullptr);
}

View File

@@ -130,11 +130,10 @@ static bool setTimer(nsj_t* nsj) {
.tv_sec = 1,
.tv_usec = 0,
},
.it_value =
{
.tv_sec = 1,
.tv_usec = 0,
},
.it_value = {
.tv_sec = 1,
.tv_usec = 0,
},
};
if (setitimer(ITIMER_REAL, &it, NULL) == -1) {
PLOG_E("setitimer(ITIMER_REAL)");

View File

@@ -101,8 +101,14 @@ static std::string readStringFromMem(pid_t pid, uint64_t addr) {
/* Heap-allocate to avoid stack pressure, but avoid static buffer reuse
* in case it causes subtle issues with event interleaving */
std::string buf(kMaxPathLen - 1, '\0');
struct iovec local = {.iov_base = buf.data(), .iov_len = buf.size()};
struct iovec remote = {.iov_base = (void*)addr, .iov_len = buf.size()};
struct iovec local = {
.iov_base = buf.data(),
.iov_len = buf.size(),
};
struct iovec remote = {
.iov_base = (void*)addr,
.iov_len = buf.size(),
};
ssize_t ret = process_vm_readv(pid, &local, 1, &remote, 1, 0);
if (ret <= 0) {
@@ -122,9 +128,13 @@ static void appendStringArrayFromMem(
if (is_32bit) {
std::vector<uint32_t> ptrs(kMaxArgs);
struct iovec local = {
.iov_base = ptrs.data(), .iov_len = ptrs.size() * sizeof(uint32_t)};
.iov_base = ptrs.data(),
.iov_len = ptrs.size() * sizeof(uint32_t),
};
struct iovec remote = {
.iov_base = (void*)addr, .iov_len = ptrs.size() * sizeof(uint32_t)};
.iov_base = (void*)addr,
.iov_len = ptrs.size() * sizeof(uint32_t),
};
ssize_t ret = process_vm_readv(pid, &local, 1, &remote, 1, 0);
if (ret <= 0) {
@@ -143,9 +153,13 @@ static void appendStringArrayFromMem(
} else {
std::vector<uint64_t> ptrs(kMaxArgs);
struct iovec local = {
.iov_base = ptrs.data(), .iov_len = ptrs.size() * sizeof(uint64_t)};
.iov_base = ptrs.data(),
.iov_len = ptrs.size() * sizeof(uint64_t),
};
struct iovec remote = {
.iov_base = (void*)addr, .iov_len = ptrs.size() * sizeof(uint64_t)};
.iov_base = (void*)addr,
.iov_len = ptrs.size() * sizeof(uint64_t),
};
ssize_t ret = process_vm_readv(pid, &local, 1, &remote, 1, 0);
if (ret <= 0) {
@@ -301,8 +315,14 @@ static void parseSockaddr(struct seccomp_notif* req, SyscallRecord* rec, uint64_
}
struct sockaddr_storage ss = {};
struct iovec local = {.iov_base = &ss, .iov_len = addrlen};
struct iovec remote = {.iov_base = (void*)addr, .iov_len = addrlen};
struct iovec local = {
.iov_base = &ss,
.iov_len = addrlen,
};
struct iovec remote = {
.iov_base = (void*)addr,
.iov_len = addrlen,
};
ssize_t read_bytes = process_vm_readv(req->pid, &local, 1, &remote, 1, 0);
if (read_bytes >= (ssize_t)sizeof(sa_family_t)) {
char host[INET6_ADDRSTRLEN] = "unknown";
@@ -629,8 +649,14 @@ static void decodeSyscallArgs(
__u64 mode;
__u64 resolve;
} how = {};
struct iovec local = {.iov_base = &how, .iov_len = sizeof(how)};
struct iovec remote = {.iov_base = (void*)arg, .iov_len = sizeof(how)};
struct iovec local = {
.iov_base = &how,
.iov_len = sizeof(how),
};
struct iovec remote = {
.iov_base = (void*)arg,
.iov_len = sizeof(how),
};
if (process_vm_readv(req->pid, &local, 1, &remote, 1, 0) >=
(ssize_t)sizeof(how.flags)) {
if (last_path) {