aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-09-18 18:17:42 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2023-09-18 18:17:42 +0200
commitd66a818355d0c1a81be580f8bca13dc02bdbe045 (patch)
treee8ee87e5a2d07078c032aec39c3c81eb9e8b3522
parentlör 16 sep 2023 20:46:57 CEST (diff)
downloadwiki-public-d66a818355d0c1a81be580f8bca13dc02bdbe045.tar.gz
wiki-public-d66a818355d0c1a81be580f8bca13dc02bdbe045.tar.xz
mån 18 sep 2023 18:17:41 CEST
-rw-r--r--Makefile5
-rw-r--r--wiki.c27
2 files changed, 20 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index aa84950..9d93ccd 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,5 @@
+.PHONY: check
+
CFLAGS = -Wall -pedantic -std=c2x -ggdb \
-D_POSIX_C_SOURCE=200809L \
-D_XOPEN_SOURCE=700 \
@@ -11,3 +13,6 @@ LDFLAGS = -pthread -L/usr/local/lib
LDLIBS = -lpthread
wiki: wiki.c
+
+check:
+ cppcheck --enable=all --suppress=missingIncludeSystem wiki.c
diff --git a/wiki.c b/wiki.c
index 05b6537..eae2ae1 100644
--- a/wiki.c
+++ b/wiki.c
@@ -177,9 +177,9 @@ static void *start_thread(void *d) {
fprintf(stderr, "Signaled\n");
munmap(data->cond, sizeof data->cond);
- struct timeval timeout = {
- .tv_sec = 1,
- };
+ // struct timeval timeout = {
+ // .tv_sec = 1,
+ // };
int count;
@@ -496,6 +496,7 @@ int errfunc(const char *path, int err) {
return 0;
}
+#if 0
int commit_ammend (const char* action, const char *msg) {
char *buf = NULL;
@@ -506,11 +507,12 @@ int commit_ammend (const char* action, const char *msg) {
struct tm result;
if (localtime_r(&now, &result) == NULL) {
msg = "Now";
+ } else {
+ buf = malloc(1024);
+ /* TODO check result */
+ strftime(buf, 1024, DATE_FORMAT, &result);
+ msg = buf;
}
- buf = malloc(1024);
- /* TODO check result */
- strftime(buf, 1024, DATE_FORMAT, &result);
- msg = buf;
}
@@ -523,9 +525,10 @@ int commit_ammend (const char* action, const char *msg) {
return 0;
}
+#endif
-int git(size_t argc, const char *argv[]) {
#if 0
+int git(size_t argc, const char *argv[]) {
pid_t pid;
int ret;
@@ -567,9 +570,9 @@ int git(size_t argc, const char *argv[]) {
}
return ret;
-#endif
return 0;
}
+#endif
void print_available_wikis() {
printf(
@@ -645,12 +648,12 @@ int wiki_do(const char *wiki_root,
}
if (cmp("echo", command[0])) {
syslog(3, "-- %s --", wiki);
- char *buf = malloc(0x100);
+ // char *buf = malloc(0x100);
// sprintf(buf, "/tmp/hugo/%i", getpid());
// FILE *log = fopen("/tmp/hugo/log", "a");
// fprintf(log, "Gonna write!\n");
- int count = printf("-- %s --\n", wiki);
+ /* int count = */printf("-- %s --\n", wiki);
fflush(stdout);
// fprintf(log, "Wrote %i bytes\n", count);
@@ -671,7 +674,7 @@ int wiki_do(const char *wiki_root,
}
closedir(d);
#endif
- // free(buf);
+ free(buf);
// :fclose(log);
// fflush()q