Skip to content

Commit 94fda0b

Browse files
authored
Merge pull request containers#1993 from eriksjolund/linux-do-not-use-errno-after-success
linux: do not use errno after success
2 parents 60c363d + 47c36ca commit 94fda0b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/libcrun/linux.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3693,10 +3693,11 @@ libcrun_set_sysctl (libcrun_container_t *container, libcrun_error_t *err)
36933693
ret = TEMP_FAILURE_RETRY (write (fd, def->linux->sysctl->values[i], strlen (def->linux->sysctl->values[i])));
36943694
if (UNLIKELY (ret < 0))
36953695
{
3696+
int saved_errno = errno;
36963697
cleanup_free char *reason = NULL;
36973698

3698-
reason = sysctl_error_reason (def->linux->sysctl->keys[i], namespaces_created, errno);
3699-
return crun_make_error (err, errno, "write to `/proc/sys/%s`%s%s%s", name, reason ? " (" : "", reason ?: "", reason ? ")" : "");
3699+
reason = sysctl_error_reason (def->linux->sysctl->keys[i], namespaces_created, saved_errno);
3700+
return crun_make_error (err, saved_errno, "write to `/proc/sys/%s`%s%s%s", name, reason ? " (" : "", reason ?: "", reason ? ")" : "");
37003701
}
37013702
}
37023703
return 0;

0 commit comments

Comments
 (0)