mirror of
https://github.com/hyprwm/hyprutils.git
synced 2025-01-27 19:59:48 +01:00
misc: fix some compile warnings (#25)
- Cleans up compile warnings - Formats code - Cleans up unused vars - etc
This commit is contained in:
parent
5e45b1a1b9
commit
9be03a8562
8 changed files with 29 additions and 29 deletions
|
@ -86,14 +86,8 @@ bool Hyprutils::OS::CProcess::runSync() {
|
|||
return false;
|
||||
|
||||
pollfd pollfds[2] = {
|
||||
{
|
||||
.fd = outPipe[0],
|
||||
.events = POLLIN,
|
||||
},
|
||||
{
|
||||
.fd = errPipe[0],
|
||||
.events = POLLIN,
|
||||
},
|
||||
{.fd = outPipe[0], .events = POLLIN, .revents = 0},
|
||||
{.fd = errPipe[0], .events = POLLIN, .revents = 0},
|
||||
};
|
||||
|
||||
while (1337) {
|
||||
|
@ -188,26 +182,33 @@ bool Hyprutils::OS::CProcess::runAsync() {
|
|||
std::vector<const char*> argsC;
|
||||
argsC.emplace_back(strdup(binary.c_str()));
|
||||
for (auto& arg : args) {
|
||||
// TODO: does this leak? Can we just pipe c_str() as the strings won't be realloc'd?
|
||||
argsC.emplace_back(strdup(arg.c_str()));
|
||||
}
|
||||
|
||||
argsC.emplace_back(nullptr);
|
||||
|
||||
execvp(binary.c_str(), (char* const*)argsC.data());
|
||||
// exit grandchild
|
||||
_exit(0);
|
||||
}
|
||||
close(socket[0]);
|
||||
write(socket[1], &grandchild, sizeof(grandchild));
|
||||
if (write(socket[1], &grandchild, sizeof(grandchild)) != sizeof(grandchild)) {
|
||||
close(socket[1]);
|
||||
_exit(1);
|
||||
}
|
||||
close(socket[1]);
|
||||
// exit child
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
// run in parent
|
||||
close(socket[1]);
|
||||
read(socket[0], &grandchild, sizeof(grandchild));
|
||||
ssize_t bytesRead = read(socket[0], &grandchild, sizeof(grandchild));
|
||||
close(socket[0]);
|
||||
|
||||
if (bytesRead != sizeof(grandchild)) {
|
||||
waitpid(child, nullptr, 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
// clear child and leave grandchild to init
|
||||
waitpid(child, nullptr, 0);
|
||||
|
||||
|
|
|
@ -12,8 +12,7 @@ Hyprutils::String::CVarList::CVarList(const std::string& in, const size_t lastAr
|
|||
std::string args{in};
|
||||
size_t idx = 0;
|
||||
size_t pos = 0;
|
||||
std::ranges::replace_if(
|
||||
args, [&](const char& c) { return delim == 's' ? std::isspace(c) : c == delim; }, 0);
|
||||
std::ranges::replace_if(args, [&](const char& c) { return delim == 's' ? std::isspace(c) : c == delim; }, 0);
|
||||
|
||||
for (const auto& s : args | std::views::split(0)) {
|
||||
if (removeEmpty && s.empty())
|
||||
|
|
|
@ -10,7 +10,7 @@ int main(int argc, char** argv, char** envp) {
|
|||
|
||||
CSignal signal;
|
||||
int data = 0;
|
||||
auto listener = signal.registerListener([&](std::any d) { data = 1; });
|
||||
auto listener = signal.registerListener([&]([[maybe_unused]] std::any d) { data = 1; });
|
||||
|
||||
signal.emit();
|
||||
|
||||
|
|
Loading…
Reference in a new issue