Skip to content

Commit 301d299

Browse files
committed
Gate FAN_FS_ERROR helpers by header support
Older kernel headers can leave FAPOLICYD_HAVE_FANOTIFY_FS_ERROR disabled while still compiling daemon/fanotify-fs-error.c. In that configuration, record_fs_error_event() and escape_path_for_log() were defined even though their only callers were inside FAN_FS_ERROR-only code paths, which produced -Wunused-function warnings on builds such as RHEL 8. Guard the private FAN_FS_ERROR helper prototypes, state, and implementations with the existing FAPOLICYD_HAVE_FANOTIFY_FS_ERROR check, and remove the unused old-header parse stub. The public fallback entry points remain available so unsupported-header builds keep the same no-op behavior.
1 parent 973f241 commit 301d299

1 file changed

Lines changed: 10 additions & 18 deletions

File tree

src/daemon/fanotify-fs-error.c

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,16 @@ struct fanotify_fs_error_details {
9090
time_t when;
9191
};
9292

93-
extern atomic_bool stop, run_stats;
93+
extern atomic_bool stop;
94+
#if FAPOLICYD_HAVE_FANOTIFY_FS_ERROR
95+
extern atomic_bool run_stats;
96+
#endif
9497

9598
static int fs_error_fd = -1;
99+
#if FAPOLICYD_HAVE_FANOTIFY_FS_ERROR
96100
static struct message_rate_limit fanotify_fs_error_log =
97101
MESSAGE_RATE_LIMIT_INIT(FS_ERROR_LOG_INTERVAL);
102+
#endif
98103
static pthread_mutex_t fs_error_lock = PTHREAD_MUTEX_INITIALIZER;
99104
static struct fanotify_fs_error_details last_fs_error;
100105

@@ -103,6 +108,7 @@ static const char *fs_error_status(
103108
static const char *fs_error_code_text(int error);
104109
static const char *format_fs_error_time(time_t when, char *buf,
105110
size_t buf_size);
111+
#if FAPOLICYD_HAVE_FANOTIFY_FS_ERROR
106112
static int parse_fs_error_record(
107113
const struct fanotify_event_metadata *metadata,
108114
struct fanotify_fs_error_details *details);
@@ -115,6 +121,7 @@ static void record_fs_error_event(
115121
const struct fanotify_event_metadata *metadata);
116122
static void fanotify_fs_error_failure_action(void);
117123
static const char *escape_path_for_log(const char *path, char **escaped);
124+
#endif
118125

119126
/*
120127
* getFanotifyFilesystemErrors - return FAN_FS_ERROR health event count.
@@ -260,22 +267,6 @@ static int parse_fs_error_record(
260267

261268
return 0;
262269
}
263-
#else
264-
/*
265-
* parse_fs_error_record - older headers cannot expose FAN_FS_ERROR details.
266-
* @metadata: unused fanotify event metadata.
267-
* @details: unused details destination.
268-
* Returns -1 because this build cannot parse FAN_FS_ERROR records.
269-
*/
270-
static int parse_fs_error_record(
271-
const struct fanotify_event_metadata *metadata,
272-
struct fanotify_fs_error_details *details)
273-
{
274-
(void)metadata;
275-
(void)details;
276-
return -1;
277-
}
278-
#endif
279270

280271
/*
281272
* save_fs_error_details - publish recent filesystem error details.
@@ -344,6 +335,7 @@ static void record_fs_error_event(
344335
log_fs_error_event(&details, total);
345336
fanotify_fs_error_failure_action();
346337
}
338+
#endif
347339

348340
/*
349341
* fanotify_fs_error_report - write recent FAN_FS_ERROR details.
@@ -387,6 +379,7 @@ void fanotify_fs_error_report(FILE *f)
387379
details.metadata_len);
388380
}
389381

382+
#if FAPOLICYD_HAVE_FANOTIFY_FS_ERROR
390383
/*
391384
* fanotify_fs_error_failure_action - run the observe-only failure response.
392385
* Returns nothing.
@@ -427,7 +420,6 @@ static const char *escape_path_for_log(const char *path, char **escaped)
427420
return "<unavailable>";
428421
}
429422

430-
#if FAPOLICYD_HAVE_FANOTIFY_FS_ERROR
431423
/*
432424
* fanotify_fs_error_close - close the filesystem error fanotify group.
433425
* Returns nothing.

0 commit comments

Comments
 (0)