Browse Source

[1593] Minor tidy up

Stephen Morris 13 years ago
parent
commit
e40cec7b4d

+ 4 - 5
src/bin/sockcreator/sockcreator.cc

@@ -98,8 +98,7 @@ handle_request(const int input_fd, const int output_fd,
     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);
@@ -162,7 +161,7 @@ handle_request(const int input_fd, const int output_fd,
 
         // ...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);
     }
 }
 
@@ -175,11 +174,11 @@ namespace socket_creator {
 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
     }

+ 3 - 3
src/bin/sockcreator/tests/sockcreator_tests.cc

@@ -267,12 +267,13 @@ closeIgnore(int) {
 // 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";
@@ -294,7 +295,6 @@ void run_test(const char* input_data, const size_t input_size,
     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));