summaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-07-14 07:29:30 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-07-14 07:29:30 +0200
commit855a9d81bacb290ac68e92a53b342489ee391c2e (patch)
tree5e9ab7945de56ee2885914097a2c8402660294ab /degesch.c
parentc57343599620435235c12c5a91f768e987687e79 (diff)
downloadxK-855a9d81bacb290ac68e92a53b342489ee391c2e.tar.gz
xK-855a9d81bacb290ac68e92a53b342489ee391c2e.tar.xz
xK-855a9d81bacb290ac68e92a53b342489ee391c2e.zip
degesch: simplify check_server_name_for_addition()
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/degesch.c b/degesch.c
index 00e50a1..a6babf4 100644
--- a/degesch.c
+++ b/degesch.c
@@ -6491,21 +6491,16 @@ validate_server_name (const char *name)
return true;
}
-static bool
+static const char *
check_server_name_for_addition (struct app_context *ctx, const char *name)
{
if (!strcasecmp_ascii (name, ctx->global_buffer->name))
- log_global_error (ctx, "Cannot create server `#s': #s",
- name, "name collides with the global buffer");
- else if (str_map_find (&ctx->servers, name))
- log_global_error (ctx, "Cannot create server `#s': #s",
- name, "server already exists");
- else if (!validate_server_name (name))
- log_global_error (ctx, "Cannot create server `#s': #s",
- name, "invalid server name");
- else
- return true;
- return false;
+ return "name collides with the global buffer";
+ if (str_map_find (&ctx->servers, name))
+ return "server already exists";
+ if (!validate_server_name (name))
+ return "invalid server name";
+ return NULL;
}
static struct server *
@@ -7511,7 +7506,10 @@ handle_server_add (struct handler_args *a)
struct app_context *ctx = a->ctx;
char *name = cut_word (&a->arguments);
- if (check_server_name_for_addition (ctx, name))
+ const char *err;
+ if ((err = check_server_name_for_addition (ctx, name)))
+ log_global_error (ctx, "Cannot create server `#s': #s", name, err);
+ else
{
server_add_new (ctx, name);
log_global_status (ctx, "Server added: #s", name);