Cosmetic cleanups across the tree

No behavioural change; verified byte-identical scan output over
/usr/include and /etc and byte-identical snapshots against the previous
build, with valgrind clean on every command.

- free() accepts NULL, so drop six guards around it in types.c.
- RecordObjectRelease returned an int no caller ever read; make it void,
  which is the idiom for a free-like function.
- RecordObjectFieldName bounded its index only from above. The underlying
  type of an enum is the compiler's choice, so compare as unsigned and
  catch a negative value too.
- copy() opened the destination "w+" but never reads it back; "w" says
  what it does.
- Testing strlen(s) == 0 walks the whole string to answer a question
  about its first byte.
- Two comments contradicted the code: split_record finds eight
  separators, not six, and strconcat explains itself in terms of a strcat
  it does not call.
- Drop includes nothing uses: <inttypes.h> from list.c and create.c, and
  <string.h> from list.c and from scan.c, which stopped needing it once
  the strlen above was gone.

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:37:57 +02:00
parent 381f7b242d
commit 93e78fc7b3
6 changed files with 20 additions and 33 deletions

View File

@@ -57,7 +57,7 @@ const char *RecordObjectPath(const struct RecordObject *self);
const char *RecordObjectTarget(const struct RecordObject *self);
uintmax_t RecordObjectFingerPrint(const struct RecordObject *self);
/* Free self and all owned resources. Returns 0, or -1 if self is NULL. */
int RecordObjectRelease(struct RecordObject *self);
/* Free self and all owned resources. Does nothing if self is NULL. */
void RecordObjectRelease(struct RecordObject *self);
#endif