src/switch_manager/switch_manager.c in trema-0.2.5 vs src/switch_manager/switch_manager.c in trema-0.2.6

- old
+ new

@@ -16,21 +16,21 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include <limits.h> #include <errno.h> #include <getopt.h> #include <inttypes.h> +#include <limits.h> +#include <openflow.h> +#include <signal.h> #include <stdio.h> #include <stdlib.h> -#include <signal.h> #include <string.h> -#include <unistd.h> #include <sys/wait.h> -#include <openflow.h> +#include <unistd.h> #include "trema.h" #include "secure_channel_listener.h" #include "switch_manager.h" #include "dpid_table.h" @@ -42,11 +42,11 @@ #ifdef printf #undef printf #endif #define printf( fmt, args... ) mock_printf2( fmt, ##args ) -int mock_printf2(const char *format, ...); +int mock_printf2( const char *format, ... ); #ifdef die #undef die #endif #define die( fmt, ... ) \ @@ -74,11 +74,11 @@ #ifdef access #undef access #endif #define access mock_access -int mock_access( const char *pathname, int mode); +int mock_access( const char *pathname, int mode ); #ifdef get_current_dir_name #undef get_current_dir_name #endif #define get_current_dir_name mock_get_current_dir_name @@ -134,11 +134,11 @@ #ifdef set_external_callback #undef set_external_callback #endif #define set_external_callback mock_set_external_callback -void mock_set_external_callback( void ( *callback ) ( void ) ); +void mock_set_external_callback( void ( *callback )( void ) ); #endif // UNIT_TESTING struct listener_info listener_info; @@ -154,21 +154,23 @@ void usage() { printf( - "OpenFlow Switch Manager.\n" - "Usage: %s [OPTION]... [-- SWITCH_MANAGER_OPTION]...\n" - "\n" - " -s, --switch=PATH the command path of switch\n" - " -n, --name=SERVICE_NAME service name\n" - " -p, --port=PORT server listen port (default %u)\n" - " -d, --daemonize run in the background\n" - " -l, --logging_level=LEVEL set logging level\n" - " -h, --help display this help and exit\n" - , get_executable_name(), OFP_TCP_PORT - ); + "OpenFlow Switch Manager.\n" + "Usage: %s [OPTION]... [-- SWITCH_MANAGER_OPTION]...\n" + "\n" + " -s, --switch=PATH the command path of switch\n" + " -n, --name=SERVICE_NAME service name\n" + " -p, --port=PORT server listen port (default %u)\n" + " -d, --daemonize run in the background\n" + " -l, --logging_level=LEVEL set logging level\n" + " -g, --syslog output log messages to syslog\n" + " -f, --logging_facility=FACILITY set syslog facility\n" + " -h, --help display this help and exit\n" + , get_executable_name(), OFP_TCP_PORT + ); } static void wait_child( void ) { @@ -255,13 +257,13 @@ listener_info->listen_fd = -1; } static void -finalize_listener_info( struct listener_info *listener_info ) { +finalize_listener_info( struct listener_info *listener_info ) { if ( listener_info->switch_daemon != NULL ) { - xfree( (void *)( uintptr_t )listener_info->switch_daemon ); + xfree( ( void * ) ( uintptr_t ) listener_info->switch_daemon ); listener_info->switch_daemon = NULL; } if ( listener_info->listen_fd >= 0 ) { set_readable( listener_info->listen_fd, false ); delete_fd_handler( listener_info->listen_fd ); @@ -297,11 +299,11 @@ if ( listener_info->listen_port == 0 ) { return false; } break; case 's': - xfree( (void *)( uintptr_t )listener_info->switch_daemon ); + xfree( ( void * ) ( uintptr_t ) listener_info->switch_daemon ); listener_info->switch_daemon = xstrdup( optarg ); break; default: usage(); exit( EXIT_SUCCESS ); @@ -411,10 +413,10 @@ start_service_management(); start_switch_management(); switch_daemon = listener_info.switch_daemon; listener_info.switch_daemon = absolute_path( startup_dir, switch_daemon ); - xfree( ( void * )( uintptr_t )switch_daemon ); + xfree( ( void * ) ( uintptr_t ) switch_daemon ); // free returned buffer of get_current_dir_name() free( startup_dir ); catch_sigchild();