From 2362ee4a4897502b3ccedf7af31d6d1ad89cff8e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 21 Jan 2009 08:48:02 +0100 Subject: use config_get_positive() instead of manual parsing Simplify some code by using config_get_positive(), instead of doing manual parsing and validation each time. --- src/listen.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'src/listen.c') diff --git a/src/listen.c b/src/listen.c index eac166330..a0efbe148 100644 --- a/src/listen.c +++ b/src/listen.c @@ -253,23 +253,9 @@ parseListenConfigParam(G_GNUC_UNUSED unsigned int port, void listenOnPort(void) { - int port = DEFAULT_PORT; + int port = config_get_positive(CONF_PORT, DEFAULT_PORT); struct config_param *param = config_get_next_param(CONF_BIND_TO_ADDRESS, NULL); - struct config_param *portParam = config_get_param(CONF_PORT); - - if (portParam) { - char *test; - port = strtol(portParam->value, &test, 10); - if (port <= 0 || *test != '\0') { - g_error("%s \"%s\" specified at line %i is not a " - "positive integer", - CONF_PORT, - portParam->value, portParam->line); - } - } - - boundPort = port; do { parseListenConfigParam(port, param); -- cgit v1.2.3