Skip to content
Snippets Groups Projects
Commit 423e9d85 authored by Daniel Salzman's avatar Daniel Salzman
Browse files

modules: add general MODULE_ERR macro

parent c51b0076
No related branches found
No related tags found
No related merge requests found
......@@ -45,9 +45,6 @@ int check_mod_dnsproxy(conf_check_t *args)
return KNOT_EOK;
}
/* Defines. */
#define MODULE_ERR(msg, ...) log_error("module 'dnsproxy', " msg, ##__VA_ARGS__)
struct dnsproxy {
conf_remote_t remote;
bool catch_nxdomain;
......@@ -114,7 +111,6 @@ int dnsproxy_load(struct query_plan *plan, struct query_module *self)
struct dnsproxy *proxy = mm_alloc(self->mm, sizeof(struct dnsproxy));
if (proxy == NULL) {
MODULE_ERR("not enough memory");
return KNOT_ENOMEM;
}
memset(proxy, 0, sizeof(struct dnsproxy));
......
......@@ -48,9 +48,6 @@ int check_mod_dnstap(conf_check_t *args)
return KNOT_EOK;
}
/* Defines. */
#define MODULE_ERR(msg, ...) log_error("module 'dnstap', " msg, ##__VA_ARGS__)
static int log_message(int state, const knot_pkt_t *pkt, struct query_data *qdata, void *ctx)
{
if (pkt == NULL || qdata == NULL || ctx == NULL) {
......@@ -233,9 +230,8 @@ int dnstap_load(struct query_plan *plan, struct query_module *self)
query_plan_step(plan, QPLAN_END, dnstap_message_log, self->ctx);
return KNOT_EOK;
fail:
MODULE_ERR("failed for init sink '%s'", sink);
MODULE_ERR(C_MOD_DNSTAP, "failed to init sink '%s'", sink);
return KNOT_ENOMEM;
}
......
......@@ -353,7 +353,6 @@ int cache_remove(MDB_txn *txn, MDB_dbi dbi, const knot_dname_t *name)
#define DEFAULT_PORT 514
#define SYSLOG_BUFLEN 1024 /* RFC3164, 4.1 message size. */
#define SYSLOG_FACILITY 3 /* System daemon. */
#define MODULE_ERR(msg, ...) log_error("module 'rose', " msg, ##__VA_ARGS__)
/*! \brief Safe stream skipping. */
static int stream_skip(char **stream, size_t *maxlen, int nbytes)
......@@ -623,7 +622,7 @@ int rosedb_load(struct query_plan *plan, struct query_module *self)
conf_val_t val = conf_mod_get(self->config, MOD_DBDIR, self->id);
struct cache *cache = cache_open(conf_str(&val), 0, self->mm);
if (cache == NULL) {
MODULE_ERR("failed to open db '%s'", conf_str(&val));
MODULE_ERR(C_MOD_ROSEDB, "failed to open db '%s'", conf_str(&val));
return KNOT_ENOMEM;
}
......
......@@ -117,7 +117,6 @@ int check_mod_synth_record(conf_check_t *args)
/* Defines. */
#define ARPA_ZONE_LABELS 2
#define MODULE_ERR(msg, ...) log_error("module 'synth_record', " msg, ##__VA_ARGS__)
/*!
* \brief Synthetic response template.
......@@ -420,7 +419,6 @@ int synth_record_load(struct query_plan *plan, struct query_module *self)
/* Create synthesis template. */
struct synth_template *tpl = mm_alloc(self->mm, sizeof(struct synth_template));
if (tpl == NULL) {
MODULE_ERR("not enough memory");
return KNOT_ENOMEM;
}
......@@ -439,7 +437,6 @@ int synth_record_load(struct query_plan *plan, struct query_module *self)
val = conf_mod_get(self->config, MOD_ORIGIN, self->id);
tpl->zone = knot_dname_to_str_alloc(conf_dname(&val));
if (tpl->zone == NULL) {
MODULE_ERR("not enough memory");
free(tpl->prefix);
mm_free(self->mm, tpl);
return KNOT_ENOMEM;
......
......@@ -46,6 +46,9 @@
#include "knot/conf/conf.h"
#include "knot/conf/tools.h"
#define MODULE_ERR(mod, msg, ...) \
log_error("module '%.*s', " msg, mod[0], mod + 1, ##__VA_ARGS__)
/* Query module processing stages. */
enum query_stage {
QPLAN_BEGIN = 0, /* Before query processing. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment