diff --git a/Makefile b/Makefile index 37f1aa4..f4a7998 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,13 @@ CC := cc CPPFLAGS := -Iinclude -MMD -MP -CFLAGS := -std=c11 -Wall -Wextra -Wpedantic -Wconversion -ggdb + +# -O2 is not only about speed: without optimisation GCC skips the flow +# analysis that most of these warnings are derived from. +WARNINGS := -Wall -Wextra -Wpedantic -Wconversion -Wshadow -Wvla \ + -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition \ + -Wcast-qual -Wwrite-strings -Wdouble-promotion +CFLAGS := -std=c11 $(WARNINGS) -O2 -ggdb LDFLAGS := LDLIBS := @@ -26,16 +32,13 @@ DEPENDENCIES := $(OBJECTS:.o=.d) all: $(TARGET) -$(TARGET): $(OBJECTS) | $(BUILD_DIR) +$(TARGET): $(OBJECTS) $(CC) $(LDFLAGS) $(OBJECTS) $(LDLIBS) -o $@ $(BUILD_DIR)/%.o: %.c @mkdir -p $(dir $@) $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ -$(BUILD_DIR): - mkdir -p $@ - run: $(TARGET) ./$(TARGET) diff --git a/src/hash.c b/src/hash.c index 9714229..9f74a3b 100644 --- a/src/hash.c +++ b/src/hash.c @@ -6,7 +6,7 @@ static uint32_t crc32_table[256]; static int table_computed = 0; -static void init_crc32_table() { +static void init_crc32_table(void) { for (uint32_t i = 0; i < 256; i++) { uint32_t crc = i; for (int j = 0; j < 8; j++) { diff --git a/src/types.c b/src/types.c index c69cb20..2cfe8a3 100644 --- a/src/types.c +++ b/src/types.c @@ -254,7 +254,7 @@ struct RecordObject { uintmax_t fingerprint; }; -struct RecordObject *RecordObjectNew() { +struct RecordObject *RecordObjectNew(void) { struct RecordObject *ret = calloc(1, sizeof(*ret)); if (ret == NULL) return NULL; diff --git a/src/walk.c b/src/walk.c index 168246c..013ef55 100644 --- a/src/walk.c +++ b/src/walk.c @@ -8,10 +8,10 @@ #include #include -static char *blacklist[] = {".", ".."}; +static const char *const blacklist[] = {".", ".."}; static int ignore_file(const char *name) { - for (long unsigned int i = 0; i < sizeof(blacklist) / sizeof(char *); i++) { + for (size_t i = 0; i < sizeof(blacklist) / sizeof(blacklist[0]); i++) { if (strcmp(name, blacklist[i]) == 0) return 1; }