Skip to content

Commit

Permalink
test: initialize _cleanup_ variables
Browse files Browse the repository at this point in the history
Otherwise static analysis will complain
  • Loading branch information
bluca authored and yuwata committed Apr 15, 2024
1 parent 091c26b commit e5689f0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/test/test-socket-util.c
Expand Up @@ -168,7 +168,7 @@ TEST(getpeercred_getpeergroups) {
uid_t test_uid;
gid_t test_gid;
struct ucred ucred;
int pair[2];
int pair[2] = EBADF_PAIR;

if (geteuid() == 0) {
test_uid = 1;
Expand Down Expand Up @@ -220,7 +220,7 @@ TEST(getpeercred_getpeergroups) {

TEST(passfd_read) {
static const char file_contents[] = "test contents for passfd";
_cleanup_close_pair_ int pair[2];
_cleanup_close_pair_ int pair[2] = EBADF_PAIR;
int r;

assert_se(socketpair(AF_UNIX, SOCK_DGRAM, 0, pair) >= 0);
Expand All @@ -246,7 +246,7 @@ TEST(passfd_read) {
/* Parent */
char buf[64];
struct iovec iov = IOVEC_MAKE(buf, sizeof(buf)-1);
_cleanup_close_ int fd;
_cleanup_close_ int fd = -EBADF;

pair[1] = safe_close(pair[1]);

Expand All @@ -260,7 +260,7 @@ TEST(passfd_read) {
}

TEST(passfd_contents_read) {
_cleanup_close_pair_ int pair[2];
_cleanup_close_pair_ int pair[2] = EBADF_PAIR;
static const char file_contents[] = "test contents in the file";
static const char wire_contents[] = "test contents on the wire";
int r;
Expand Down Expand Up @@ -308,7 +308,7 @@ TEST(passfd_contents_read) {
}

TEST(pass_many_fds_contents_read) {
_cleanup_close_pair_ int pair[2];
_cleanup_close_pair_ int pair[2] = EBADF_PAIR;
static const char file_contents[][STRLEN("test contents in the fileX") + 1] = {
"test contents in the file0",
"test contents in the file1",
Expand Down Expand Up @@ -373,7 +373,7 @@ TEST(pass_many_fds_contents_read) {
}

TEST(receive_nopassfd) {
_cleanup_close_pair_ int pair[2];
_cleanup_close_pair_ int pair[2] = EBADF_PAIR;
static const char wire_contents[] = "no fd passed here";
int r;

Expand Down Expand Up @@ -410,7 +410,7 @@ TEST(receive_nopassfd) {
}

TEST(send_nodata_nofd) {
_cleanup_close_pair_ int pair[2];
_cleanup_close_pair_ int pair[2] = EBADF_PAIR;
int r;

assert_se(socketpair(AF_UNIX, SOCK_DGRAM, 0, pair) >= 0);
Expand Down Expand Up @@ -443,7 +443,7 @@ TEST(send_nodata_nofd) {
}

TEST(send_emptydata) {
_cleanup_close_pair_ int pair[2];
_cleanup_close_pair_ int pair[2] = EBADF_PAIR;
int r;

assert_se(socketpair(AF_UNIX, SOCK_DGRAM, 0, pair) >= 0);
Expand Down

0 comments on commit e5689f0

Please sign in to comment.