Fix naming inconsistencies: header guard, FieldName prefix, Operation typedef

This commit is contained in:
Fabio Scotto di Santolo
2026-08-25 23:54:31 +02:00
parent ad062794d8
commit a7f13e408b
5 changed files with 9 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
#ifndef TYPE_H #ifndef TYPES_H
#define TYPE_H #define TYPES_H
#include <inttypes.h> #include <inttypes.h>
#include <stdio.h> #include <stdio.h>
@@ -19,7 +19,7 @@ enum Fields {
extern enum Fields field; extern enum Fields field;
const char *FieldName(enum Fields f); const char *RecordObjectFieldName(enum Fields f);
struct RecordObject; struct RecordObject;

View File

@@ -1,8 +1,8 @@
#ifndef WALK_H #ifndef WALK_H
#define WALK_H #define WALK_H
typedef int(*operation)(const char *, void *); typedef int(*WalkOp)(const char *, void *);
int walk(const char *directory, operation op, void *context); int walk(const char *directory, WalkOp op, void *context);
#endif #endif

View File

@@ -40,7 +40,7 @@ int list(const char *snapshot) {
} }
int ret = RecordObjectUnpack(objp, buf); int ret = RecordObjectUnpack(objp, buf);
if (field != NONE) { if (field != NONE) {
fprintf(stderr, "%s:%d: invalid %s\n", snapshot, i + 1, FieldName(field)); fprintf(stderr, "%s:%d: invalid %s\n", snapshot, i + 1, RecordObjectFieldName(field));
rc = 128; rc = 128;
RecordObjectRelease(objp); RecordObjectRelease(objp);
break; break;

View File

@@ -20,7 +20,7 @@ static const char *field_names[] = {
"file type", "permissions", "uid", "gid", "size", "file type", "permissions", "uid", "gid", "size",
"time", "target", "fingerprint", "path", "none"}; "time", "target", "fingerprint", "path", "none"};
const char *FieldName(enum Fields f) { const char *RecordObjectFieldName(enum Fields f) {
return (f <= NONE) ? field_names[f] : "unknown"; return (f <= NONE) ? field_names[f] : "unknown";
} }

View File

@@ -18,7 +18,7 @@ static int ignore_file(const char *name) {
return 0; return 0;
} }
static int handle_unknown(const char *path, operation op, void *context) { static int handle_unknown(const char *path, WalkOp op, void *context) {
struct stat st; struct stat st;
if (lstat(path, &st) == -1) { if (lstat(path, &st) == -1) {
@@ -36,7 +36,7 @@ static int handle_unknown(const char *path, operation op, void *context) {
return 0; return 0;
} }
int walk(const char *directory, operation op, void *context) { int walk(const char *directory, WalkOp op, void *context) {
errno = 0; errno = 0;
DIR *dirp = opendir(directory); DIR *dirp = opendir(directory);
if (dirp == NULL) { if (dirp == NULL) {