Unify error handling: output parameter, goto cleanup, errno preservation

- Replace global field variable with output parameter enum Fields *err
- Adopt single goto cleanup pattern across all functions
- Add errno preservation around cleanup in all modules
- Fix early return bug in create.c cleanup block
- Add ferror check in crc32() for silent read errors
- Document error contracts in all public headers
This commit is contained in:
Fabio Scotto di Santolo
2026-08-26 14:20:00 +02:00
parent 464bb58c8c
commit c397728912
15 changed files with 237 additions and 195 deletions

View File

@@ -38,9 +38,11 @@ int list(const char *snapshot) {
rc = -1;
goto out;
}
int ret = RecordObjectUnpack(objp, buf);
if (field != NONE) {
fprintf(stderr, "%s:%d: invalid %s\n", snapshot, i + 1, RecordObjectFieldName(field));
enum Fields err = NONE;
int ret = RecordObjectUnpack(objp, buf, &err);
if (err != NONE) {
fprintf(stderr, "%s:%d: invalid %s\n", snapshot, i + 1,
RecordObjectFieldName(err));
rc = 128;
RecordObjectRelease(objp);
break;