switch (type[1]) { // The address family
// The casting to apparently incompatible types by reinterpret_cast
- // is required by the C low-level interface. Unions are not used
- // because of the possibility of alignment issues.
+ // is required by the C low-level interface.
case '4':
addr = reinterpret_cast<sockaddr*>(&addr_in);
// ...and append the reason code to the error message
int error = errno;
- write_message(output_fd, static_cast<void *>(&error), sizeof error);
+ write_message(output_fd, static_cast<void*>(&error), sizeof error);
}
}
int
get_sock(const int type, struct sockaddr *bind_addr, const socklen_t addr_len)
{
- int sock(socket(bind_addr->sa_family, type, 0));
+ int sock = socket(bind_addr->sa_family, type, 0);
if (sock == -1) {
return -1;
}
- const int on(1);
+ const int on = 1;
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) {
return -2; // This is part of the binding process, so it's a bind error
}
// parses the commands correctly.
void run_test(const char* input_data, const size_t input_size,
const char* output_data, const size_t output_size,
- bool should_succeed = true, const close_t test_close = closeIgnore,
+ bool should_succeed = true,
+ const close_t test_close = closeIgnore,
const send_fd_t send_fd = send_fd_dummy)
{
// Prepare the input feeder and output checker processes. The feeder
// process sends data from the client to run() and the checker process
- // reads the response and checks the output.
+ // reads the response and checks it against the expected response.
int input_fd = 0;
pid_t input = provide_input(&input_fd, input_data, input_size);
ASSERT_NE(-1, input) << "Couldn't start input feeder";
close(input_fd);
close(output_fd);
- // Did it run well?
// Check the subprocesses say everything is OK too
EXPECT_TRUE(process_ok(input));
EXPECT_TRUE(process_ok(output));