changeset 993:3cd5039d0c67

misc: various fixes
author David Demelier <markand@malikania.fr>
date Wed, 10 Feb 2021 21:44:40 +0100
parents 462e12e434fb
children 56114ae85868
files extern/libcompat/CMakeLists.txt extern/libketopt/CMakeLists.txt irccd/dl-plugin.c irccd/js-plugin.c irccd/jsapi-directory.c irccd/jsapi-system.c irccd/jsapi-util.c irccd/peer.c lib/irccd/irccd.c
diffstat 9 files changed, 15 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/extern/libcompat/CMakeLists.txt	Wed Feb 10 21:31:32 2021 +0100
+++ b/extern/libcompat/CMakeLists.txt	Wed Feb 10 21:44:40 2021 +0100
@@ -92,6 +92,7 @@
 target_include_directories(
 	libirccd-compat
 	PUBLIC
+		$<BUILD_INTERFACE:${libirccd-compat_BINARY_DIR}>
 		$<BUILD_INTERFACE:${libirccd-compat_BINARY_DIR}/irccd>
 )
 set_target_properties(libirccd-compat PROPERTIES PREFIX "")
--- a/extern/libketopt/CMakeLists.txt	Wed Feb 10 21:31:32 2021 +0100
+++ b/extern/libketopt/CMakeLists.txt	Wed Feb 10 21:44:40 2021 +0100
@@ -18,7 +18,8 @@
 
 cmake_minimum_required(VERSION 3.0)
 project(libirccd-ketopt)
-add_library(libirccd-ketopt INTERFACE ketopt.h)
+add_library(libirccd-ketopt INTERFACE)
+target_sources(libirccd-ketopt INTERFACE ${libirccd-ketopt_SOURCE_DIR}/ketopt.h)
 target_include_directories(
 	libirccd-ketopt
 	INTERFACE
--- a/irccd/dl-plugin.c	Wed Feb 10 21:31:32 2021 +0100
+++ b/irccd/dl-plugin.c	Wed Feb 10 21:44:40 2021 +0100
@@ -236,7 +236,7 @@
 	struct self *self;
 
 	if (!(self = init(name, path)))
-		return false;
+		return NULL;
 
 	/* Data and all callbacks. */
 	self->plugin.data = self;
--- a/irccd/js-plugin.c	Wed Feb 10 21:31:32 2021 +0100
+++ b/irccd/js-plugin.c	Wed Feb 10 21:44:40 2021 +0100
@@ -145,16 +145,9 @@
 static void
 log_trace(struct self *self)
 {
-	const char *name, *message;
 	char *stack, *token, *p;
 	int linenumber;
 
-	duk_get_prop_string(self->ctx, -1, "name");
-	name = duk_get_string(self->ctx, -1);
-	duk_pop(self->ctx);
-	duk_get_prop_string(self->ctx, -1, "message");
-	message = duk_get_string(self->ctx, -1);
-	duk_pop(self->ctx);
 	duk_get_prop_string(self->ctx, -1, "stack");
 	stack = strdup(duk_opt_string(self->ctx, -1, ""));
 	duk_pop(self->ctx);
--- a/irccd/jsapi-directory.c	Wed Feb 10 21:31:32 2021 +0100
+++ b/irccd/jsapi-directory.c	Wed Feb 10 21:44:40 2021 +0100
@@ -85,7 +85,7 @@
 			strlcat(cs->path, "/", sizeof (cs->path));
 
 			entrylen += 1;
-	
+
 			if ((childfd = openat(dirfd, entry->d_name, O_RDONLY | O_DIRECTORY)) < 0)
 				continue;
 			if ((ret = recursedir(childfd, cs))) {
@@ -142,12 +142,12 @@
 	duk_get_prop_string(ctx, -1, "path");
 
 	if (duk_get_type(ctx, -1) != DUK_TYPE_STRING)
-		duk_error(ctx, DUK_ERR_TYPE_ERROR, "not a Directory object");
+		(void)duk_error(ctx, DUK_ERR_TYPE_ERROR, "not a Directory object");
 
 	ret = duk_get_string(ctx, -1);
 
 	if (!ret || !ret[0])
-		duk_error(ctx, DUK_ERR_TYPE_ERROR, "directory object has empty path");
+		(void)duk_error(ctx, DUK_ERR_TYPE_ERROR, "directory object has empty path");
 
 	duk_pop_n(ctx, 2);
 
--- a/irccd/jsapi-system.c	Wed Feb 10 21:31:32 2021 +0100
+++ b/irccd/jsapi-system.c	Wed Feb 10 21:44:40 2021 +0100
@@ -165,7 +165,7 @@
 	struct sysinfo info;
 
 	if (sysinfo(&info) < 0)
-		irc_jsapi_system_raise(ctx);
+		jsapi_system_raise(ctx);
 
 	duk_push_uint(ctx, info.uptime);
 #elif defined(__APPLE__)
@@ -186,7 +186,7 @@
 
 	/* Mostly POSIX compliant (CLOCK_UPTIME isn't POSIX though). */
 	if (clock_gettime(CLOCK_UPTIME, &ts) < 0)
-		irc_jsapi_system_raise(ctx);
+		jsapi_system_raise(ctx);
 
 	duk_push_uint(ctx, ts.tv_sec);
 #endif
--- a/irccd/jsapi-util.c	Wed Feb 10 21:31:32 2021 +0100
+++ b/irccd/jsapi-util.c	Wed Feb 10 21:44:40 2021 +0100
@@ -253,7 +253,7 @@
 	/* Join as new lines with a limit of maximum columns and lines. */
 	if (!(lines = join(ctx, maxc, maxl, &tokens))) {
 		stringlist_finish(&tokens);
-		duk_throw(ctx);
+		return duk_throw(ctx);
 	}
 
 	duk_push_array(ctx);
--- a/irccd/peer.c	Wed Feb 10 21:31:32 2021 +0100
+++ b/irccd/peer.c	Wed Feb 10 21:44:40 2021 +0100
@@ -28,6 +28,7 @@
 
 #include <assert.h>
 
+#include <irccd/compat.h>
 #include <irccd/irccd.h>
 #include <irccd/log.h>
 #include <irccd/server.h>
@@ -182,7 +183,7 @@
 
 /*
  * HOOK-ADD name path	fprintf(fp, "OK ");
- 
+
  LIST_FOREACH(s, &irc.servers, link) {
 		fprintf(fp, "%s", s->name);
 
@@ -395,7 +396,7 @@
 
 	if (sscanf(line, "RULE-ADD %*s") == EOF)
 		return EINVAL;
-		
+
 	line += strlen("RULE-ADD ");
 
 	if (strncmp(line, "accept", 6) == 0)
@@ -495,7 +496,7 @@
 
 		if (sscanf(token, "%c%c%*s", &key, &attr) != 2)
 			return EINVAL;
-	
+
 		if (key == 'a') {
 			if (attr != '=')
 				return EINVAL;
--- a/lib/irccd/irccd.c	Wed Feb 10 21:31:32 2021 +0100
+++ b/lib/irccd/irccd.c	Wed Feb 10 21:44:40 2021 +0100
@@ -18,6 +18,7 @@
 
 #include <config.h>
 
+#include <sys/wait.h>
 #include <assert.h>
 #include <ctype.h>
 #include <err.h>