Drop parentheses from thunks

This commit is contained in:
Jacek Galowicz 2023-11-02 15:50:00 +01:00
parent 1885d579db
commit c924147c9d
4 changed files with 10 additions and 10 deletions

View file

@ -96,7 +96,7 @@ void drainFD(int fd, Sink & sink, bool block)
throw SysError("making file descriptor non-blocking");
}
Finally finally([&]() {
Finally finally([&] {
if (!block) {
if (fcntl(fd, F_SETFL, saved) == -1)
throw SysError("making file descriptor blocking");

View file

@ -131,7 +131,7 @@ void killUser(uid_t uid)
users to which the current process can send signals. So we
fork a process, switch to uid, and send a mass kill. */
Pid pid = startProcess([&]() {
Pid pid = startProcess([&] {
if (setuid(uid) == -1)
throw SysError("setting uid");
@ -197,7 +197,7 @@ static int childEntry(void * arg)
pid_t startProcess(std::function<void()> fun, const ProcessOptions & options)
{
std::function<void()> wrapper = [&]() {
ChildWrapperFunction wrapper = [&] {
if (!options.allowVfork)
logger = makeSimpleLogger();
try {
@ -229,7 +229,7 @@ pid_t startProcess(std::function<void()> fun, const ProcessOptions & options)
PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0);
if (stack == MAP_FAILED) throw SysError("allocating stack");
Finally freeStack([&]() { munmap(stack, stackSize); });
Finally freeStack([&] { munmap(stack, stackSize); });
pid = clone(childEntry, stack + stackSize, options.cloneFlags | SIGCHLD, &wrapper);
#else
@ -308,7 +308,7 @@ void runProgram2(const RunOptions & options)
}
/* Fork. */
Pid pid = startProcess([&]() {
Pid pid = startProcess([&] {
if (options.environment)
replaceEnv(*options.environment);
if (options.standardOut && dup2(out.writeSide.get(), STDOUT_FILENO) == -1)
@ -350,7 +350,7 @@ void runProgram2(const RunOptions & options)
std::promise<void> promise;
Finally doJoin([&]() {
Finally doJoin([&] {
if (writerThread.joinable())
writerThread.join();
});
@ -358,7 +358,7 @@ void runProgram2(const RunOptions & options)
if (source) {
in.readSide.close();
writerThread = std::thread([&]() {
writerThread = std::thread([&] {
try {
std::vector<char> buf(8 * 1024);
while (true) {

View file

@ -47,7 +47,7 @@ void bind(int fd, const std::string & path)
addr.sun_family = AF_UNIX;
if (path.size() + 1 >= sizeof(addr.sun_path)) {
Pid pid = startProcess([&]() {
Pid pid = startProcess([&] {
Path dir = dirOf(path);
if (chdir(dir.c_str()) == -1)
throw SysError("chdir to '%s' failed", dir);
@ -78,7 +78,7 @@ void connect(int fd, const std::string & path)
if (path.size() + 1 >= sizeof(addr.sun_path)) {
Pipe pipe;
pipe.create();
Pid pid = startProcess([&]() {
Pid pid = startProcess([&] {
try {
pipe.readSide.close();
Path dir = dirOf(path);

View file

@ -183,7 +183,7 @@ std::string base64Encode(std::string_view s)
std::string base64Decode(std::string_view s)
{
constexpr char npos = -1;
constexpr std::array<char, 256> base64DecodeChars = [&]() {
constexpr std::array<char, 256> base64DecodeChars = [&] {
std::array<char, 256> result{};
for (auto& c : result)
c = npos;