#include <stdlib.h>
#include <string.h>
#include <netdb.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
static const char *arg_remote_host = NULL;
-#define _cleanup_freeaddrinfo_ _cleanup_(freeaddrinfop)
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct addrinfo *, freeaddrinfo);
-
typedef struct Context {
sd_event *event;
sd_resolve *resolve;
return -errno;
}
- fcntl(buffer[0], F_SETPIPE_SZ, BUFFER_SIZE);
+ (void) fcntl(buffer[0], F_SETPIPE_SZ, BUFFER_SIZE);
r = fcntl(buffer[0], F_GETPIPE_SZ);
if (r < 0) {
return 0;
}
- r = set_ensure_allocated(&context->connections, trivial_hash_func, trivial_compare_func);
+ r = set_ensure_allocated(&context->connections, NULL);
if (r < 0) {
log_oom();
return 0;
assert(context);
assert(fd >= 0);
- r = set_ensure_allocated(&context->listen, trivial_hash_func, trivial_compare_func);
+ r = set_ensure_allocated(&context->listen, NULL);
if (r < 0) {
log_oom();
return r;
return 0;
}
-static int help(void) {
-
- printf("%s [HOST:PORT]\n"
- "%s [SOCKET]\n\n"
+static void help(void) {
+ printf("%1$s [HOST:PORT]\n"
+ "%1$s [SOCKET]\n\n"
"Bidirectionally proxy local sockets to another (possibly remote) socket.\n\n"
" -h --help Show this help\n"
" --version Show package version\n",
- program_invocation_short_name,
program_invocation_short_name);
-
- return 0;
}
static int parse_argv(int argc, char *argv[]) {
assert(argc >= 0);
assert(argv);
- while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0) {
+ while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0)
switch (c) {
case 'h':
- return help();
+ help();
+ return 0;
case ARG_VERSION:
puts(PACKAGE_STRING);
default:
assert_not_reached("Unhandled option");
}
- }
if (optind >= argc) {
log_error("Not enough parameters.");