Skip to content

Commit

Permalink
utils: Avoid shadowing the names of global functions
Browse files Browse the repository at this point in the history
dirfd() and socket() are POSIX standard library functions, so use dfd
and sockfd instead.

Signed-off-by: Simon McVittie <[email protected]>
  • Loading branch information
smcv committed Oct 8, 2024
1 parent 5dab8b8 commit 73abd50
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,15 +451,15 @@ write_to_fd (int fd,

/* Sets errno on error (!= 0), ENOSPC on short write */
int
write_file_at (int dirfd,
write_file_at (int dfd,
const char *path,
const char *content)
{
int fd;
bool res;
int errsv;

fd = TEMP_FAILURE_RETRY (openat (dirfd, path, O_RDWR | O_CLOEXEC, 0));
fd = TEMP_FAILURE_RETRY (openat (dfd, path, O_RDWR | O_CLOEXEC, 0));
if (fd == -1)
return -1;

Expand Down Expand Up @@ -639,14 +639,14 @@ load_file_data (int fd,
/* Sets errno on error (== NULL),
* Always ensures terminating zero */
char *
load_file_at (int dirfd,
load_file_at (int dfd,
const char *path)
{
int fd;
char *data;
int errsv;

fd = TEMP_FAILURE_RETRY (openat (dirfd, path, O_CLOEXEC | O_RDONLY));
fd = TEMP_FAILURE_RETRY (openat (dfd, path, O_CLOEXEC | O_RDONLY));
if (fd == -1)
return NULL;

Expand Down Expand Up @@ -752,7 +752,7 @@ mkdir_with_parents (const char *pathname,
read back with read_pid_from_socket(), and then the kernel has
translated it between namespaces as needed. */
void
send_pid_on_socket (int socket)
send_pid_on_socket (int sockfd)
{
char buf[1] = { 0 };
struct msghdr msg = {};
Expand All @@ -777,7 +777,7 @@ send_pid_on_socket (int socket)
cred->uid = geteuid ();
cred->gid = getegid ();

if (TEMP_FAILURE_RETRY (sendmsg (socket, &msg, 0)) < 0)
if (TEMP_FAILURE_RETRY (sendmsg (sockfd, &msg, 0)) < 0)
die_with_error ("Can't send pid");
}

Expand All @@ -794,7 +794,7 @@ create_pid_socketpair (int sockets[2])
}

int
read_pid_from_socket (int socket)
read_pid_from_socket (int sockfd)
{
char recv_buf[1] = { 0 };
struct msghdr msg = {};
Expand All @@ -808,7 +808,7 @@ read_pid_from_socket (int socket)
msg.msg_control = control_buf_rcv;
msg.msg_controllen = control_len_rcv;

if (TEMP_FAILURE_RETRY (recvmsg (socket, &msg, 0)) < 0)
if (TEMP_FAILURE_RETRY (recvmsg (sockfd, &msg, 0)) < 0)
die_with_error ("Can't read pid from socket");

if (msg.msg_controllen <= 0)
Expand Down

0 comments on commit 73abd50

Please sign in to comment.