diff options
| author | David M. Syzdek <david@syzdek.net> | 2022-01-14 01:29:19 -0900 |
|---|---|---|
| committer | David M. Syzdek <david@syzdek.net> | 2022-01-14 01:29:19 -0900 |
| commit | 3e88d7fbf8e0d33b2d3acfa3004946aa0b9c3626 (patch) | |
| tree | 4d98d0a3f3df8fb8b511faf1b24eddd4ceaa6a3c /examples | |
| parent | 57af4dc6abed68c2d9074cc1fec032ed384e2451 (diff) | |
| download | tinyrad-3e88d7fbf8e0d33b2d3acfa3004946aa0b9c3626.tar.gz tinyrad-3e88d7fbf8e0d33b2d3acfa3004946aa0b9c3626.tar.bz2 tinyrad-3e88d7fbf8e0d33b2d3acfa3004946aa0b9c3626.tar.xz tinyrad-3e88d7fbf8e0d33b2d3acfa3004946aa0b9c3626.zip | |
examples: fixing compiler warnings
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/socket-example.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/examples/socket-example.c b/examples/socket-example.c index b372e8e..2aaa9cc 100644 --- a/examples/socket-example.c +++ b/examples/socket-example.c | |||
| @@ -79,11 +79,11 @@ | |||
| 79 | # define PACKAGE_VERSION "unknown" | 79 | # define PACKAGE_VERSION "unknown" |
| 80 | #endif | 80 | #endif |
| 81 | 81 | ||
| 82 | #define MY_VERBOSE 0x0001 | 82 | #define MY_VERBOSE 0x0001U |
| 83 | #define MY_QUIET 0x0002 | 83 | #define MY_QUIET 0x0002U |
| 84 | #define MY_SERVER 0x0004 | 84 | #define MY_SERVER 0x0004U |
| 85 | #define MY_TCP 0x0008 | 85 | #define MY_TCP 0x0008U |
| 86 | #define MY_UDP 0x0000 | 86 | #define MY_UDP 0x0000U |
| 87 | 87 | ||
| 88 | #define MY_TIMEOUT 30 // in seconds | 88 | #define MY_TIMEOUT 30 // in seconds |
| 89 | 89 | ||
| @@ -95,7 +95,7 @@ | |||
| 95 | ///////////////// | 95 | ///////////////// |
| 96 | #pragma mark - Variables | 96 | #pragma mark - Variables |
| 97 | 97 | ||
| 98 | int should_exit = 0; | 98 | static int should_exit = 0; |
| 99 | 99 | ||
| 100 | 100 | ||
| 101 | ////////////////// | 101 | ////////////////// |
| @@ -107,17 +107,17 @@ int should_exit = 0; | |||
| 107 | 107 | ||
| 108 | int main( int argc, char * argv[] ); | 108 | int main( int argc, char * argv[] ); |
| 109 | 109 | ||
| 110 | int my_client( int s, int opts, struct sockaddr_storage * sap ); | 110 | int my_client( int s, unsigned opts, struct sockaddr_storage * sap ); |
| 111 | void my_connlog( int opts, const struct sockaddr_storage * sa, const char * fmt, ...); | 111 | void my_connlog( unsigned opts, const struct sockaddr_storage * sa, const char * fmt, ...); |
| 112 | int my_error( const char * fmt, ...); | 112 | int my_error( const char * fmt, ...); |
| 113 | char * my_ntop(const struct sockaddr_storage * sa, char * buff, size_t len); | 113 | char * my_ntop(const struct sockaddr_storage * sa, char * buff, size_t len); |
| 114 | void my_print( int opts, const char * fmt, ...); | 114 | void my_print( unsigned opts, const char * fmt, ...); |
| 115 | int my_server( int s, int opts ); | 115 | int my_server( int s, unsigned opts ); |
| 116 | int my_server_tcp( int s, int opts ); | 116 | int my_server_tcp( int s, unsigned opts ); |
| 117 | int my_server_udp( int s, int opts ); | 117 | int my_server_udp( int s, unsigned opts ); |
| 118 | void my_signal( int sig ); | 118 | void my_signal( int sig ); |
| 119 | void my_usage( void ); | 119 | void my_usage( void ); |
| 120 | void my_verbose( int opts, const char * fmt, ...); | 120 | void my_verbose( unsigned opts, const char * fmt, ...); |
| 121 | 121 | ||
| 122 | 122 | ||
| 123 | ///////////////// | 123 | ///////////////// |
| @@ -133,7 +133,7 @@ int main(int argc, char * argv[]) | |||
| 133 | int opt_index; | 133 | int opt_index; |
| 134 | int rc; | 134 | int rc; |
| 135 | int s; | 135 | int s; |
| 136 | int opt; | 136 | unsigned opt; |
| 137 | unsigned opts; | 137 | unsigned opts; |
| 138 | const char * laddr; | 138 | const char * laddr; |
| 139 | const char * port; | 139 | const char * port; |
| @@ -311,7 +311,7 @@ int main(int argc, char * argv[]) | |||
| 311 | } | 311 | } |
| 312 | 312 | ||
| 313 | 313 | ||
| 314 | int my_client( int s, int opts, struct sockaddr_storage * sap ) | 314 | int my_client( int s, unsigned opts, struct sockaddr_storage * sap ) |
| 315 | { | 315 | { |
| 316 | struct pollfd fds[2]; | 316 | struct pollfd fds[2]; |
| 317 | int rc; | 317 | int rc; |
| @@ -417,7 +417,7 @@ int my_client( int s, int opts, struct sockaddr_storage * sap ) | |||
| 417 | } | 417 | } |
| 418 | 418 | ||
| 419 | 419 | ||
| 420 | void my_connlog( int opts, const struct sockaddr_storage * sa, const char * fmt, ...) | 420 | void my_connlog( unsigned opts, const struct sockaddr_storage * sa, const char * fmt, ...) |
| 421 | { | 421 | { |
| 422 | va_list args; | 422 | va_list args; |
| 423 | char host[INET6_ADDRSTRLEN+32]; | 423 | char host[INET6_ADDRSTRLEN+32]; |
| @@ -466,7 +466,7 @@ char * my_ntop(const struct sockaddr_storage * sa, char * buff, size_t len) | |||
| 466 | } | 466 | } |
| 467 | 467 | ||
| 468 | 468 | ||
| 469 | void my_print( int opts, const char * fmt, ...) | 469 | void my_print( unsigned opts, const char * fmt, ...) |
| 470 | { | 470 | { |
| 471 | va_list args; | 471 | va_list args; |
| 472 | if ((opts & MY_QUIET)) | 472 | if ((opts & MY_QUIET)) |
| @@ -480,7 +480,7 @@ void my_print( int opts, const char * fmt, ...) | |||
| 480 | } | 480 | } |
| 481 | 481 | ||
| 482 | 482 | ||
| 483 | int my_server( int s, int opts ) | 483 | int my_server( int s, unsigned opts ) |
| 484 | { | 484 | { |
| 485 | struct sockaddr_storage sa; | 485 | struct sockaddr_storage sa; |
| 486 | socklen_t sa_len; | 486 | socklen_t sa_len; |
| @@ -498,7 +498,7 @@ int my_server( int s, int opts ) | |||
| 498 | } | 498 | } |
| 499 | 499 | ||
| 500 | 500 | ||
| 501 | int my_server_tcp( int s, int opts ) | 501 | int my_server_tcp( int s, unsigned opts ) |
| 502 | { | 502 | { |
| 503 | struct pollfd fds[10]; | 503 | struct pollfd fds[10]; |
| 504 | nfds_t nfds; | 504 | nfds_t nfds; |
| @@ -610,7 +610,7 @@ int my_server_tcp( int s, int opts ) | |||
| 610 | } | 610 | } |
| 611 | 611 | ||
| 612 | 612 | ||
| 613 | int my_server_udp( int s, int opts ) | 613 | int my_server_udp( int s, unsigned opts ) |
| 614 | { | 614 | { |
| 615 | struct pollfd fds[1]; | 615 | struct pollfd fds[1]; |
| 616 | int rc; | 616 | int rc; |
| @@ -693,7 +693,7 @@ void my_usage(void) | |||
| 693 | return; | 693 | return; |
| 694 | } | 694 | } |
| 695 | 695 | ||
| 696 | void my_verbose( int opts, const char * fmt, ...) | 696 | void my_verbose( unsigned opts, const char * fmt, ...) |
| 697 | { | 697 | { |
| 698 | va_list args; | 698 | va_list args; |
| 699 | if (!(opts & MY_VERBOSE)) | 699 | if (!(opts & MY_VERBOSE)) |
