about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2023-03-21 19:44:10 +0100
committerLeah Neukirchen <leah@vuxu.org>2023-03-21 20:21:45 +0100
commitfce8d1ec3329a97fc8886cf71eb3d1a763d71ad7 (patch)
treebe31fc1a0631e75faa7642ba018311df22bda995
parentec01c6149dfc00dcf93a73ef829541a8b1a996a1 (diff)
downloadlibste-fce8d1ec3329a97fc8886cf71eb3d1a763d71ad7.tar.gz
libste-fce8d1ec3329a97fc8886cf71eb3d1a763d71ad7.tar.xz
libste-fce8d1ec3329a97fc8886cf71eb3d1a763d71ad7.zip
set reasonable CFLAGS
-rw-r--r--Makefile2
-rw-r--r--example.c6
-rw-r--r--stecpe.c2
-rw-r--r--tests.c2
4 files changed, 7 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 0be968b..7773c49 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,5 @@
+CFLAGS=-g -O2 -Wall -Wno-switch -Wextra -Wwrite-strings
+
 all: libste.a example
 
 libste.a: stechr.o stecpe.o stecpy.o steprn.o
diff --git a/example.c b/example.c
index e9f57d5..0429663 100644
--- a/example.c
+++ b/example.c
@@ -11,13 +11,13 @@
 int
 main(int argc, char *argv[])
 {
-	char *path = getenv("PATH");
+	const char *path = getenv("PATH");
 	if (!path)
 	    path = "";
 
-	char *program = argc > 1 ? argv[1] : "xyzzy";
+	const char *program = argc > 1 ? argv[1] : "xyzzy";
 
-	char *pathend = path + strlen(path);
+	const char *pathend = path + strlen(path);
 
 	char buf[PATH_MAX];
 	char *bufend = buf + sizeof buf;
diff --git a/stecpe.c b/stecpe.c
index 0cfbaad..b943843 100644
--- a/stecpe.c
+++ b/stecpe.c
@@ -7,7 +7,7 @@ stecpe(char *dst, const char *end, const char *src, const char *srcend)
         if (dst >= end)
                 return dst;
 
-	size_t l = end - dst - 1;
+	ptrdiff_t l = end - dst - 1;
 	size_t t = 1;
 	if (srcend - src < l) {
 		l = srcend - src;
diff --git a/tests.c b/tests.c
index 306a693..fa2e0ff 100644
--- a/tests.c
+++ b/tests.c
@@ -6,7 +6,7 @@
 static int status;
 
 void
-is(char *desc, int ok)
+is(const char *desc, int ok)
 {
 	if (!ok)
 		status = 1;