Commit e40cec7b authored by Stephen Morris's avatar Stephen Morris
Browse files

[1593] Minor tidy up

parent 61dd1837
...@@ -98,8 +98,7 @@ handle_request(const int input_fd, const int output_fd, ...@@ -98,8 +98,7 @@ handle_request(const int input_fd, const int output_fd,
switch (type[1]) { // The address family switch (type[1]) { // The address family
// The casting to apparently incompatible types by reinterpret_cast // The casting to apparently incompatible types by reinterpret_cast
// is required by the C low-level interface. Unions are not used // is required by the C low-level interface.
// because of the possibility of alignment issues.
case '4': case '4':
addr = reinterpret_cast<sockaddr*>(&addr_in); addr = reinterpret_cast<sockaddr*>(&addr_in);
...@@ -162,7 +161,7 @@ handle_request(const int input_fd, const int output_fd, ...@@ -162,7 +161,7 @@ handle_request(const int input_fd, const int output_fd,
// ...and append the reason code to the error message // ...and append the reason code to the error message
int error = errno; int error = errno;
write_message(output_fd, static_cast<void *>(&error), sizeof error); write_message(output_fd, static_cast<void*>(&error), sizeof error);
} }
} }
...@@ -175,11 +174,11 @@ namespace socket_creator { ...@@ -175,11 +174,11 @@ namespace socket_creator {
int int
get_sock(const int type, struct sockaddr *bind_addr, const socklen_t addr_len) 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) { if (sock == -1) {
return -1; return -1;
} }
const int on(1); const int on = 1;
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(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 return -2; // This is part of the binding process, so it's a bind error
} }
......
...@@ -267,12 +267,13 @@ closeIgnore(int) { ...@@ -267,12 +267,13 @@ closeIgnore(int) {
// parses the commands correctly. // parses the commands correctly.
void run_test(const char* input_data, const size_t input_size, void run_test(const char* input_data, const size_t input_size,
const char* output_data, const size_t output_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) const send_fd_t send_fd = send_fd_dummy)
{ {
// Prepare the input feeder and output checker processes. The feeder // Prepare the input feeder and output checker processes. The feeder
// process sends data from the client to run() and the checker process // 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; int input_fd = 0;
pid_t input = provide_input(&input_fd, input_data, input_size); pid_t input = provide_input(&input_fd, input_data, input_size);
ASSERT_NE(-1, input) << "Couldn't start input feeder"; ASSERT_NE(-1, input) << "Couldn't start input feeder";
...@@ -294,7 +295,6 @@ void run_test(const char* input_data, const size_t input_size, ...@@ -294,7 +295,6 @@ void run_test(const char* input_data, const size_t input_size,
close(input_fd); close(input_fd);
close(output_fd); close(output_fd);
// Did it run well?
// Check the subprocesses say everything is OK too // Check the subprocesses say everything is OK too
EXPECT_TRUE(process_ok(input)); EXPECT_TRUE(process_ok(input));
EXPECT_TRUE(process_ok(output)); EXPECT_TRUE(process_ok(output));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment