From: Guus Sliepen Date: Sun, 11 Oct 2009 11:54:05 +0000 (+0200) Subject: Remove code duplication when checking ADD_EDGE/DEL_EDGE messages. X-Git-Tag: release-1.0.10~9 X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=2762509be179dcb21d855f3d6f90d3ee686e3910;p=tinc Remove code duplication when checking ADD_EDGE/DEL_EDGE messages. --- diff --git a/src/protocol_edge.c b/src/protocol_edge.c index 57e202f6..9d439225 100644 --- a/src/protocol_edge.c +++ b/src/protocol_edge.c @@ -70,13 +70,7 @@ bool add_edge_h(connection_t *c) { /* Check if names are valid */ - if(!check_id(from_name)) { - logger(LOG_ERR, "Got bad %s from %s (%s): %s", "ADD_EDGE", c->name, - c->hostname, "invalid name"); - return false; - } - - if(!check_id(to_name)) { + if(!check_id(from_name) || !check_id(to_name)) { logger(LOG_ERR, "Got bad %s from %s (%s): %s", "ADD_EDGE", c->name, c->hostname, "invalid name"); return false; @@ -186,13 +180,7 @@ bool del_edge_h(connection_t *c) { /* Check if names are valid */ - if(!check_id(from_name)) { - logger(LOG_ERR, "Got bad %s from %s (%s): %s", "DEL_EDGE", c->name, - c->hostname, "invalid name"); - return false; - } - - if(!check_id(to_name)) { + if(!check_id(from_name) || !check_id(to_name)) { logger(LOG_ERR, "Got bad %s from %s (%s): %s", "DEL_EDGE", c->name, c->hostname, "invalid name"); return false;