aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Jung <mail@umaxx.net>2016-04-11 20:35:28 +0200
committerJoerg Jung <mail@umaxx.net>2016-04-11 20:35:28 +0200
commit1be5b03fad0fb215d8f249c4de8cf86d073b91b7 (patch)
treeae241ca6c8239238f160705676cb23559ece573f
parentadd limit option based on pull request #30 from Lévai Dániel (diff)
downloadOpenSMTPD-extras-1be5b03fad0fb215d8f249c4de8cf86d073b91b7.tar.xz
OpenSMTPD-extras-1be5b03fad0fb215d8f249c4de8cf86d073b91b7.zip
replace malloc with xmalloc, change return style, and fix a few strings
-rw-r--r--extras/wip/filters/filter-clamav/filter_clamav.c4
-rw-r--r--extras/wip/filters/filter-dkim-signer/filter_dkim_signer.c8
-rw-r--r--extras/wip/filters/filter-dnsbl/filter_dnsbl.c4
-rw-r--r--extras/wip/filters/filter-lua/filter_lua.c36
-rw-r--r--extras/wip/filters/filter-monkey/filter_monkey.c8
-rw-r--r--extras/wip/filters/filter-pause/filter_pause.c4
-rw-r--r--extras/wip/filters/filter-perl/filter_perl.c4
-rw-r--r--extras/wip/filters/filter-python/filter_python.c23
-rw-r--r--extras/wip/filters/filter-regex/filter_regex.c4
-rw-r--r--extras/wip/filters/filter-spamassassin/filter_spamassassin.c4
-rw-r--r--extras/wip/filters/filter-stub/filter_stub.c4
-rw-r--r--extras/wip/filters/filter-trace/filter_trace.c4
-rw-r--r--extras/wip/filters/filter-void/filter_void.c4
-rw-r--r--extras/wip/queues/queue-python/queue_python.c3
-rw-r--r--extras/wip/schedulers/scheduler-python/scheduler_python.c3
-rw-r--r--extras/wip/tables/table-mysql/table_mysql.c2
-rw-r--r--extras/wip/tables/table-passwd/table_passwd.c2
-rw-r--r--extras/wip/tables/table-postgres/table_postgres.c2
-rw-r--r--extras/wip/tables/table-python/table_python.c3
-rw-r--r--extras/wip/tables/table-redis/table_redis.c4
20 files changed, 63 insertions, 67 deletions
diff --git a/extras/wip/filters/filter-clamav/filter_clamav.c b/extras/wip/filters/filter-clamav/filter_clamav.c
index 3cf629e..089c3c4 100644
--- a/extras/wip/filters/filter-clamav/filter_clamav.c
+++ b/extras/wip/filters/filter-clamav/filter_clamav.c
@@ -285,7 +285,7 @@ main(int argc, char **argv)
break;
default:
log_warnx("warn: bad option");
- return (1);
+ return 1;
/* NOTREACHED */
}
}
@@ -307,5 +307,5 @@ main(int argc, char **argv)
filter_api_loop();
log_debug("debug: exiting");
- return (1);
+ return 1;
}
diff --git a/extras/wip/filters/filter-dkim-signer/filter_dkim_signer.c b/extras/wip/filters/filter-dkim-signer/filter_dkim_signer.c
index 8e6a9a1..ad2029f 100644
--- a/extras/wip/filters/filter-dkim-signer/filter_dkim_signer.c
+++ b/extras/wip/filters/filter-dkim-signer/filter_dkim_signer.c
@@ -126,10 +126,10 @@ add_hdr_line(struct signer *s, const char *line)
sizeof(s->hdrs_list)) >= sizeof(s->hdrs_list))
fatalx("headers list overflow");
else
- return (1);
+ return 1;
}
- return (0);
+ return 0;
}
static void
@@ -293,7 +293,7 @@ main(int argc, char **argv)
break;
default:
log_warnx("warn: bad option");
- return (1);
+ return 1;
/* NOTREACHED */
}
}
@@ -339,5 +339,5 @@ main(int argc, char **argv)
filter_api_loop();
log_debug("debug: exiting");
- return (1);
+ return 1;
}
diff --git a/extras/wip/filters/filter-dnsbl/filter_dnsbl.c b/extras/wip/filters/filter-dnsbl/filter_dnsbl.c
index 79a97f9..d79b331 100644
--- a/extras/wip/filters/filter-dnsbl/filter_dnsbl.c
+++ b/extras/wip/filters/filter-dnsbl/filter_dnsbl.c
@@ -117,7 +117,7 @@ main(int argc, char **argv)
break;
default:
log_warnx("warn: bad option");
- return (1);
+ return 1;
/* NOTREACHED */
}
}
@@ -141,5 +141,5 @@ main(int argc, char **argv)
log_debug("debug: exiting");
- return (1);
+ return 1;
}
diff --git a/extras/wip/filters/filter-lua/filter_lua.c b/extras/wip/filters/filter-lua/filter_lua.c
index e2e735d..16c065d 100644
--- a/extras/wip/filters/filter-lua/filter_lua.c
+++ b/extras/wip/filters/filter-lua/filter_lua.c
@@ -61,12 +61,12 @@ l_filter_accept(lua_State *L)
const char *s_hex_id;
if (lua_gettop(L) != 1)
- return (0);
+ return 0;
s_hex_id = luaL_checklstring(L, 1, NULL);
id = strtoumax(s_hex_id, NULL, 16);
filter_api_accept(id);
- return (0);
+ return 0;
}
static int
@@ -77,7 +77,7 @@ l_filter_reject(lua_State *L)
uint32_t action;
if (lua_gettop(L) != 2)
- return (0);
+ return 0;
s_hex_id = luaL_checklstring(L, 1, NULL);
id = strtoumax(s_hex_id, NULL, 16);
@@ -89,7 +89,7 @@ l_filter_reject(lua_State *L)
break;
}
- return (0);
+ return 0;
}
static int
@@ -102,7 +102,7 @@ l_filter_reject_code(lua_State *L)
const char *line;
if (lua_gettop(L) != 4)
- return (0);
+ return 0;
s_hex_id = luaL_checklstring(L, 1, NULL);
id = strtoumax(s_hex_id, NULL, 16);
@@ -117,7 +117,7 @@ l_filter_reject_code(lua_State *L)
break;
}
- return (0);
+ return 0;
}
static int
@@ -128,7 +128,7 @@ l_filter_writeln(lua_State *L)
const char *line;
if (lua_gettop(L) != 2)
- return (0);
+ return 0;
s_hex_id = luaL_checklstring(L, 1, NULL);
id = strtoumax(s_hex_id, NULL, 16);
@@ -136,7 +136,7 @@ l_filter_writeln(lua_State *L)
filter_api_writeln(id, line);
- return (0);
+ return 0;
}
static const luaL_Reg l_filter [] = {
@@ -168,7 +168,7 @@ on_connect(uint64_t id, struct filter_connect *conn)
exit(1);
}
- return (1);
+ return 1;
}
static int
@@ -187,7 +187,7 @@ on_helo(uint64_t id, const char *helo)
exit(1);
}
- return (1);
+ return 1;
}
static int
@@ -206,7 +206,7 @@ on_mail(uint64_t id, struct mailaddr *mail)
exit(1);
}
- return (1);
+ return 1;
}
static int
@@ -225,7 +225,7 @@ on_rcpt(uint64_t id, struct mailaddr *rcpt)
exit(1);
}
- return (1);
+ return 1;
}
static int
@@ -243,7 +243,7 @@ on_data(uint64_t id)
exit(1);
}
- return (1);
+ return 1;
}
static void
@@ -277,7 +277,7 @@ on_eom(uint64_t id, size_t size)
exit(1);
}
- return (1);
+ return 1;
}
static void
@@ -346,7 +346,7 @@ main(int argc, char **argv)
break;
default:
log_warnx("warn: bad option");
- return (1);
+ return 1;
/* NOTREACHED */
}
}
@@ -364,7 +364,7 @@ main(int argc, char **argv)
if ((L = luaL_newstate()) == NULL) {
log_warnx("warn: can't create lua state");
- return (1);
+ return 1;
}
luaL_openlibs(L);
luaL_newlib(L, l_filter);
@@ -384,7 +384,7 @@ main(int argc, char **argv)
if (luaL_dofile(L, path) != 0) {
log_warnx("warn: error loading script: %s",
path);
- return (1);
+ return 1;
}
lua_getglobal(L, "on_connect");
@@ -452,5 +452,5 @@ main(int argc, char **argv)
log_debug("debug: exiting");
- return (0);
+ return 0;
}
diff --git a/extras/wip/filters/filter-monkey/filter_monkey.c b/extras/wip/filters/filter-monkey/filter_monkey.c
index 16884a6..bfa65db 100644
--- a/extras/wip/filters/filter-monkey/filter_monkey.c
+++ b/extras/wip/filters/filter-monkey/filter_monkey.c
@@ -90,7 +90,7 @@ monkey(uint64_t id, const char *cmd)
fatalx("invalid status");
}
- return (0);
+ return 0;
}
static void
@@ -124,7 +124,7 @@ defer_monkey(uint64_t id, const char *cmd)
tv.tv_sec = delay / 1000;
tv.tv_usec = (delay % 1000) * 1000;
evtimer_add(&d->ev, &tv);
- return (0);
+ return 0;
}
static int
@@ -311,7 +311,7 @@ main(int argc, char **argv)
break;
default:
log_warnx("warn: bad option");
- return (1);
+ return 1;
/* NOTREACHED */
}
}
@@ -336,5 +336,5 @@ main(int argc, char **argv)
log_debug("debug: exiting");
- return (0);
+ return 0;
}
diff --git a/extras/wip/filters/filter-pause/filter_pause.c b/extras/wip/filters/filter-pause/filter_pause.c
index b4adf38..66c83da 100644
--- a/extras/wip/filters/filter-pause/filter_pause.c
+++ b/extras/wip/filters/filter-pause/filter_pause.c
@@ -62,7 +62,7 @@ main(int argc, char **argv)
break;
default:
log_warnx("warn: bad option");
- return (1);
+ return 1;
/* NOTREACHED */
}
}
@@ -85,5 +85,5 @@ main(int argc, char **argv)
log_debug("debug: exiting");
- return (1);
+ return 1;
}
diff --git a/extras/wip/filters/filter-perl/filter_perl.c b/extras/wip/filters/filter-perl/filter_perl.c
index 442ea44..4591886 100644
--- a/extras/wip/filters/filter-perl/filter_perl.c
+++ b/extras/wip/filters/filter-perl/filter_perl.c
@@ -235,7 +235,7 @@ main(int argc, char **argv)
break;
default:
log_warnx("warn: bad option");
- return (1);
+ return 1;
/* NOTREACHED */
}
}
@@ -288,5 +288,5 @@ main(int argc, char **argv)
perl_destruct(pi);
perl_free(pi);
- return (1);
+ return 1;
}
diff --git a/extras/wip/filters/filter-python/filter_python.c b/extras/wip/filters/filter-python/filter_python.c
index 7f03cd9..9e0ac45 100644
--- a/extras/wip/filters/filter-python/filter_python.c
+++ b/extras/wip/filters/filter-python/filter_python.c
@@ -151,7 +151,7 @@ on_connect(uint64_t id, struct filter_connect *conn)
exit(1);
}
- return (1);
+ return 1;
}
static int
@@ -203,7 +203,7 @@ on_mail(uint64_t id, struct mailaddr *mail)
exit(1);
}
- return (1);
+ return 1;
}
static int
@@ -230,7 +230,7 @@ on_rcpt(uint64_t id, struct mailaddr *rcpt)
exit(1);
}
- return (1);
+ return 1;
}
static int
@@ -252,7 +252,7 @@ on_data(uint64_t id)
exit(1);
}
- return (1);
+ return 1;
}
static int
@@ -277,7 +277,7 @@ on_eom(uint64_t id, size_t sz)
exit(1);
}
- return (1);
+ return 1;
}
static void
@@ -389,8 +389,7 @@ loadfile(const char * path)
sz = oz;
- if ((buf = malloc(sz + 1)) == NULL)
- err(1, "malloc");
+ buf = xmalloc(sz + 1, "loadfile");
if (fread(buf, 1, sz, f) != sz)
err(1, "fread");
@@ -399,7 +398,7 @@ loadfile(const char * path)
fclose(f);
- return (buf);
+ return buf;
}
int
@@ -421,7 +420,7 @@ main(int argc, char **argv)
break;
default:
log_warnx("warn: bad option");
- return (1);
+ return 1;
/* NOTREACHED */
}
}
@@ -448,7 +447,7 @@ main(int argc, char **argv)
if (code == NULL) {
PyErr_Print();
log_warnx("warn: failed to compile %s", path);
- return (1);
+ return 1;
}
module = PyImport_ExecCodeModuleEx("myfilter", code, path);
@@ -456,7 +455,7 @@ main(int argc, char **argv)
if (module == NULL) {
PyErr_Print();
log_warnx("warn: failed to install module %s", path);
- return (1);
+ return 1;
}
log_debug("debug: starting...");
@@ -507,5 +506,5 @@ main(int argc, char **argv)
log_debug("debug: exiting");
Py_Finalize();
- return (1);
+ return 1;
}
diff --git a/extras/wip/filters/filter-regex/filter_regex.c b/extras/wip/filters/filter-regex/filter_regex.c
index 425a276..b9e0cbb 100644
--- a/extras/wip/filters/filter-regex/filter_regex.c
+++ b/extras/wip/filters/filter-regex/filter_regex.c
@@ -281,7 +281,7 @@ main(int argc, char **argv)
break;
default:
log_warnx("warn: bad option");
- return (1);
+ return 1;
/* NOTREACHED */
}
}
@@ -317,5 +317,5 @@ main(int argc, char **argv)
regex_clear();
log_debug("debug: exiting");
- return (1);
+ return 1;
}
diff --git a/extras/wip/filters/filter-spamassassin/filter_spamassassin.c b/extras/wip/filters/filter-spamassassin/filter_spamassassin.c
index b0576f2..0cc40e5 100644
--- a/extras/wip/filters/filter-spamassassin/filter_spamassassin.c
+++ b/extras/wip/filters/filter-spamassassin/filter_spamassassin.c
@@ -354,7 +354,7 @@ main(int argc, char **argv)
break;
default:
log_warnx("warn: bad option");
- return (1);
+ return 1;
/* NOTREACHED */
}
}
@@ -392,5 +392,5 @@ main(int argc, char **argv)
filter_api_loop();
log_debug("debug: exiting");
- return (1);
+ return 1;
}
diff --git a/extras/wip/filters/filter-stub/filter_stub.c b/extras/wip/filters/filter-stub/filter_stub.c
index 6537893..25620c8 100644
--- a/extras/wip/filters/filter-stub/filter_stub.c
+++ b/extras/wip/filters/filter-stub/filter_stub.c
@@ -118,7 +118,7 @@ main(int argc, char **argv)
break;
default:
log_warnx("warn: bad option");
- return (1);
+ return 1;
/* NOTREACHED */
}
}
@@ -145,5 +145,5 @@ main(int argc, char **argv)
filter_api_loop();
log_debug("debug: exiting");
- return (1);
+ return 1;
}
diff --git a/extras/wip/filters/filter-trace/filter_trace.c b/extras/wip/filters/filter-trace/filter_trace.c
index eb6e7c5..3edd970 100644
--- a/extras/wip/filters/filter-trace/filter_trace.c
+++ b/extras/wip/filters/filter-trace/filter_trace.c
@@ -125,7 +125,7 @@ main(int argc, char **argv)
break;
default:
log_warnx("warn: bad option");
- return (1);
+ return 1;
/* NOTREACHED */
}
}
@@ -155,5 +155,5 @@ main(int argc, char **argv)
log_debug("debug: exiting");
- return (1);
+ return 1;
}
diff --git a/extras/wip/filters/filter-void/filter_void.c b/extras/wip/filters/filter-void/filter_void.c
index 416dadd..6677f95 100644
--- a/extras/wip/filters/filter-void/filter_void.c
+++ b/extras/wip/filters/filter-void/filter_void.c
@@ -45,7 +45,7 @@ main(int argc, char **argv)
break;
default:
log_warnx("warn: bad option");
- return (1);
+ return 1;
/* NOTREACHED */
}
}
@@ -60,5 +60,5 @@ main(int argc, char **argv)
filter_api_loop();
log_debug("debug: exiting");
- return (1);
+ return 1;
}
diff --git a/extras/wip/queues/queue-python/queue_python.c b/extras/wip/queues/queue-python/queue_python.c
index b7f019e..264df62 100644
--- a/extras/wip/queues/queue-python/queue_python.c
+++ b/extras/wip/queues/queue-python/queue_python.c
@@ -398,8 +398,7 @@ loadfile(const char * path)
sz = oz;
- if ((buf = malloc(sz + 1)) == NULL)
- err(1, "malloc");
+ buf = xmalloc(sz + 1, "loadfile");
if (fread(buf, 1, sz, f) != sz)
err(1, "fread");
diff --git a/extras/wip/schedulers/scheduler-python/scheduler_python.c b/extras/wip/schedulers/scheduler-python/scheduler_python.c
index c6d4a22..9328aab 100644
--- a/extras/wip/schedulers/scheduler-python/scheduler_python.c
+++ b/extras/wip/schedulers/scheduler-python/scheduler_python.c
@@ -494,8 +494,7 @@ loadfile(const char * path)
sz = oz;
- if ((buf = malloc(sz + 1)) == NULL)
- err(1, "malloc");
+ buf = xmalloc(sz + 1, "loadfile");
if (fread(buf, 1, sz, f) != sz)
err(1, "fread");
diff --git a/extras/wip/tables/table-mysql/table_mysql.c b/extras/wip/tables/table-mysql/table_mysql.c
index bef04c6..7039ff5 100644
--- a/extras/wip/tables/table-mysql/table_mysql.c
+++ b/extras/wip/tables/table-mysql/table_mysql.c
@@ -235,7 +235,7 @@ config_load(const char *path)
value = strdup(value);
if (value == NULL) {
- log_warn("warn: table-mysql: malloc");
+ log_warn("warn: table-mysql: strdup");
goto end;
}
diff --git a/extras/wip/tables/table-passwd/table_passwd.c b/extras/wip/tables/table-passwd/table_passwd.c
index 99f1712..ea37dd4 100644
--- a/extras/wip/tables/table-passwd/table_passwd.c
+++ b/extras/wip/tables/table-passwd/table_passwd.c
@@ -93,7 +93,7 @@ table_passwd_update(void)
struct passwd pw;
struct dict *npasswd;
- /* Parse configuration */
+ /* parse configuration */
if ((fp = fopen(config, "r")) == NULL) {
log_warn("warn: Table \"%s\"", config);
return 0;
diff --git a/extras/wip/tables/table-postgres/table_postgres.c b/extras/wip/tables/table-postgres/table_postgres.c
index bb0b742..26be0d4 100644
--- a/extras/wip/tables/table-postgres/table_postgres.c
+++ b/extras/wip/tables/table-postgres/table_postgres.c
@@ -211,7 +211,7 @@ config_load(const char *path)
value = strdup(value);
if (value == NULL) {
- log_warn("warn: table-postgres: malloc");
+ log_warn("warn: table-postgres: strdup");
goto end;
}
diff --git a/extras/wip/tables/table-python/table_python.c b/extras/wip/tables/table-python/table_python.c
index bfa3037..e23bf1f 100644
--- a/extras/wip/tables/table-python/table_python.c
+++ b/extras/wip/tables/table-python/table_python.c
@@ -264,8 +264,7 @@ loadfile(const char * path)
sz = oz;
- if ((buf = malloc(sz + 1)) == NULL)
- err(1, "malloc");
+ buf = xmalloc(sz + 1, "loadfile");
if (fread(buf, 1, sz, f) != sz)
err(1, "fread");
diff --git a/extras/wip/tables/table-redis/table_redis.c b/extras/wip/tables/table-redis/table_redis.c
index 529e768..228e4ad 100644
--- a/extras/wip/tables/table-redis/table_redis.c
+++ b/extras/wip/tables/table-redis/table_redis.c
@@ -171,7 +171,7 @@ config_load(const char *path)
value = strdup(value);
if (value == NULL) {
- log_warn("warn: table-redis: malloc");
+ log_warn("warn: table-redis: strdup");
goto end;
}
@@ -357,7 +357,7 @@ config_connect(struct config *config)
else
config->queries[i] = strdup(qspec[i].default_query);
if (config->queries[i] == NULL) {
- log_warn("warn: table-redis: malloc");
+ log_warn("warn: table-redis: strdup");
goto end;
}
}