Build with -O2 and a stricter warning set, and fix what it found

Without optimisation GCC skips the flow analysis most of these warnings
are derived from, so -O2 is what makes the existing -W flags do their job.

The new flags found three real defects:

  -Wstrict-prototypes/-Wold-style-definition: init_crc32_table() and
  RecordObjectNew() were declared with (), which in C11 means "no
  prototype", not "no arguments". RecordObjectNew even contradicted its
  own header, which declares (void).

  -Wwrite-strings: walk's blacklist held string literals in a
  non-const char *[], so they were writable through the array.

Also make ignore_file size its loop with sizeof(blacklist[0]) instead of
repeating the element type, and drop the order-only build/ prerequisite
on the link rule, which the %.o rule's mkdir -p already covers.

The tree builds clean under all twelve flags.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018KyCHPAxWzqa3vHKdXJkgx
This commit is contained in:
Fabio Scotto di Santolo
2026-08-26 15:13:08 +02:00
parent 4aaaa8dd9c
commit 1302d5a946
4 changed files with 12 additions and 9 deletions

View File

@@ -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;