[CRIU] [PATCH] img: Simplify the open_image() macro

Pavel Emelyanov xemul at parallels.com
Thu Mar 5 13:00:34 PST 2015


Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 image.c         | 3 +++
 include/image.h | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/image.c b/image.c
index e60cda7..4f8a31b 100644
--- a/image.c
+++ b/image.c
@@ -210,6 +210,9 @@ struct cr_img *open_image_at(int dfd, int type, unsigned long flags, ...)
 	va_list args;
 	int ret;
 
+	if (dfd == -1)
+		dfd = get_service_fd(IMG_FD_OFF);
+
 	img = xmalloc(sizeof(*img));
 	if (!img)
 		goto errn;
diff --git a/include/image.h b/include/image.h
index 7c79b99..53c2998 100644
--- a/include/image.h
+++ b/include/image.h
@@ -138,7 +138,7 @@ extern int open_image_dir(char *dir);
 extern void close_image_dir(void);
 
 extern struct cr_img *open_image_at(int dfd, int type, unsigned long flags, ...);
-#define open_image(typ, flags, ...) open_image_at(get_service_fd(IMG_FD_OFF), typ, flags, ##__VA_ARGS__)
+#define open_image(typ, flags, ...) open_image_at(-1, typ, flags, ##__VA_ARGS__)
 extern struct cr_img *open_pages_image(unsigned long flags, struct cr_img *pmi);
 extern struct cr_img *open_pages_image_at(int dfd, unsigned long flags, struct cr_img *pmi);
 extern void up_page_ids_base(void);
-- 
1.8.4.2



More information about the CRIU mailing list