From 7eb20e7ddb51ee528887965913cdd674ba133c2e Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Tue, 15 Oct 2013 13:13:58 +0400 Subject: [PATCH] fsnotify: Move decoding handle into function Signed-off-by: Pavel Emelyanov --- fsnotify.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/fsnotify.c b/fsnotify.c index 9a721511f..09aac7557 100644 --- a/fsnotify.c +++ b/fsnotify.c @@ -175,6 +175,18 @@ const struct fdtype_ops fanotify_dump_ops = { .dump = dump_one_fanotify, }; +static void decode_handle(fh_t *handle, FhEntry *img) +{ + memzero(handle, sizeof(*handle)); + + handle->type = img->type; + handle->bytes = img->bytes; + + memcpy(handle->__handle, img->handle, + min(pb_repeated_size(img, handle), + sizeof(handle->__handle))); +} + static char *get_mark_path(const char *who, struct file_remap *remap, FhEntry *f_handle, unsigned long i_ino, unsigned int s_dev, char *buf, size_t size, @@ -190,14 +202,7 @@ static char *get_mark_path(const char *who, struct file_remap *remap, return remap->path; } - memzero(&handle, sizeof(handle)); - - handle.type = f_handle->type; - handle.bytes = f_handle->bytes; - - memcpy(handle.__handle, f_handle->handle, - min(pb_repeated_size(f_handle, handle), - sizeof(handle.__handle))); + decode_handle(&handle, f_handle); mntfd = open_mount(s_dev); if (mntfd < 0) {