From d66a818355d0c1a81be580f8bca13dc02bdbe045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 18 Sep 2023 18:17:42 +0200 Subject: =?UTF-8?q?m=C3=A5n=2018=20sep=202023=2018:17:41=20CEST?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 5 +++++ wiki.c | 27 +++++++++++++++------------ 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 -- cgit v1.2.3