We're about to add one more condition to the flags comparison that requires an ifdef. Move the code into a separate function now to make it cleaner after the next patch.
Signed-off-by: Fabiano Rosas <faro...@suse.de> --- monitor/fds.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/monitor/fds.c b/monitor/fds.c index 4ec3b7eea9..9a28e4b72b 100644 --- a/monitor/fds.c +++ b/monitor/fds.c @@ -406,6 +406,19 @@ AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id, return fdinfo; } +#ifndef _WIN32 +static bool monitor_fdset_flags_match(int flags, int fd_flags) +{ + bool match = false; + + if ((flags & O_ACCMODE) == (fd_flags & O_ACCMODE)) { + match = true; + } + + return match; +} +#endif + int monitor_fdset_dup_fd_add(int64_t fdset_id, int flags) { #ifdef _WIN32 @@ -431,7 +444,7 @@ int monitor_fdset_dup_fd_add(int64_t fdset_id, int flags) return -1; } - if ((flags & O_ACCMODE) == (mon_fd_flags & O_ACCMODE)) { + if (monitor_fdset_flags_match(flags, mon_fd_flags)) { fd = mon_fdset_fd->fd; break; } -- 2.35.3