]> git.meshlink.io Git - meshlink/commitdiff
Remove code duplication when checking ADD_EDGE/DEL_EDGE messages.
authorGuus Sliepen <guus@tinc-vpn.org>
Sun, 11 Oct 2009 11:54:05 +0000 (13:54 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Sun, 11 Oct 2009 11:54:05 +0000 (13:54 +0200)
src/protocol_edge.c

index 57e202f605ff8719535dd85c168ee207c71b9574..9d439225678b12d1afdfcd66774c8ef2d346be73 100644 (file)
@@ -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;