diff options
author | cbdev <cb@cbcdn.com> | 2019-12-08 02:27:57 +0100 |
---|---|---|
committer | cbdev <cb@cbcdn.com> | 2019-12-08 02:27:57 +0100 |
commit | 4ca0acff460c1c02a11cb9f246fb755cd4f4f792 (patch) | |
tree | c70f42e0915ffb305d48f2c2202272f622357cab | |
parent | 612ae7200b5f367af4a3f2553fb3f3851773c69a (diff) | |
download | midimonster-4ca0acff460c1c02a11cb9f246fb755cd4f4f792.tar.gz midimonster-4ca0acff460c1c02a11cb9f246fb755cd4f4f792.tar.bz2 midimonster-4ca0acff460c1c02a11cb9f246fb755cd4f4f792.zip |
Minor logic cleanup
-rw-r--r-- | backends/artnet.c | 12 | ||||
-rw-r--r-- | backends/sacn.c | 10 |
2 files changed, 4 insertions, 18 deletions
diff --git a/backends/artnet.c b/backends/artnet.c index 57eb7b1..e01f038 100644 --- a/backends/artnet.c +++ b/backends/artnet.c @@ -77,16 +77,12 @@ static int artnet_configure(char* option, char* value){ else if(!strcmp(option, "bind")){ mmbackend_parse_hostspec(value, &host, &port); - if(!port){ - port = ARTNET_PORT; - } - if(!host){ fprintf(stderr, "Not valid ArtNet bind address given\n"); return 1; } - if(artnet_listener(host, port)){ + if(artnet_listener(host, (port ? port : ARTNET_PORT))){ fprintf(stderr, "Failed to bind ArtNet descriptor: %s\n", value); return 1; } @@ -140,16 +136,12 @@ static int artnet_configure_instance(instance* inst, char* option, char* value){ else if(!strcmp(option, "dest") || !strcmp(option, "destination")){ mmbackend_parse_hostspec(value, &host, &port); - if(!port){ - port = ARTNET_PORT; - } - if(!host){ fprintf(stderr, "Not a valid ArtNet destination for instance %s\n", inst->name); return 1; } - return mmbackend_parse_sockaddr(host, port, &data->dest_addr, &data->dest_len); + return mmbackend_parse_sockaddr(host, port ? port : ARTNET_PORT, &data->dest_addr, &data->dest_len); } fprintf(stderr, "Unknown ArtNet option %s for instance %s\n", option, inst->name); diff --git a/backends/sacn.c b/backends/sacn.c index 2229b8a..edb648d 100644 --- a/backends/sacn.c +++ b/backends/sacn.c @@ -111,16 +111,13 @@ static int sacn_configure(char* option, char* value){ } else if(!strcmp(option, "bind")){ mmbackend_parse_hostspec(value, &host, &port); - if(!port){ - port = SACN_PORT; - } if(!host){ fprintf(stderr, "No valid sACN bind address provided\n"); return 1; } - if(sacn_listener(host, port, flags)){ + if(sacn_listener(host, port ? port : SACN_PORT, flags)){ fprintf(stderr, "Failed to bind sACN descriptor: %s\n", value); return 1; } @@ -155,16 +152,13 @@ static int sacn_configure_instance(instance* inst, char* option, char* value){ } else if(!strcmp(option, "destination")){ mmbackend_parse_hostspec(value, &host, &port); - if(!port){ - port = SACN_PORT; - } if(!host){ fprintf(stderr, "No valid sACN destination for instance %s\n", inst->name); return 1; } - return mmbackend_parse_sockaddr(host, port, &data->dest_addr, &data->dest_len); + return mmbackend_parse_sockaddr(host, port ? port : SACN_PORT, &data->dest_addr, &data->dest_len); } else if(!strcmp(option, "from")){ next = value; |