Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/checkpoint-restore/criu.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Safonov <dima@arista.com>2019-11-10 01:20:45 +0300
committerAndrei Vagin <avagin@gmail.com>2020-02-04 23:39:04 +0300
commit1c0716924bbc1128c478388b70904438a5934e73 (patch)
treeeb3f9b6fcbeb25ab0368466a9dd5a7b589ba3e27 /include
parent56bc4189e47c3f356c6f407544f5a88768bd4f00 (diff)
compel/criu: Add __must_check
All those compel functions can fail by various reasons. It may be status of the system, interruption by user or anything else. It's really desired to handle as many PIE related errors as possible otherwise it's hard to analyze statuses of parasite/restorer and the C/R process. At least warning for logs should be produced or even C/R stopped. Signed-off-by: Dmitry Safonov <dima@arista.com> Signed-off-by: Andrei Vagin <avagin@gmail.com>
Diffstat (limited to 'include')
-rw-r--r--include/common/compiler.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/common/compiler.h b/include/common/compiler.h
index fc8abcfef..1d431a529 100644
--- a/include/common/compiler.h
+++ b/include/common/compiler.h
@@ -22,6 +22,7 @@
#define __used __attribute__((__used__))
#define __maybe_unused __attribute__((unused))
#define __always_unused __attribute__((unused))
+#define __must_check __attribute__((__warn_unused_result__))
#define __section(S) __attribute__ ((__section__(#S)))
@@ -99,4 +100,30 @@
#define is_log2(v) (((v) & ((v) - 1)) == 0)
+/*
+ * Use "__ignore_value" to avoid a warning when using a function declared with
+ * gcc's warn_unused_result attribute, but for which you really do want to
+ * ignore the result. Traditionally, people have used a "(void)" cast to
+ * indicate that a function's return value is deliberately unused. However,
+ * if the function is declared with __attribute__((warn_unused_result)),
+ * gcc issues a warning even with the cast.
+ *
+ * Caution: most of the time, you really should heed gcc's warning, and
+ * check the return value. However, in those exceptional cases in which
+ * you're sure you know what you're doing, use this function.
+ *
+ * Normally casting an expression to void discards its value, but GCC
+ * versions 3.4 and newer have __attribute__ ((__warn_unused_result__))
+ * which may cause unwanted diagnostics in that case. Use __typeof__
+ * and __extension__ to work around the problem, if the workaround is
+ * known to be needed.
+ * Written by Jim Meyering, Eric Blake and Pádraig Brady.
+ * (See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425 for the details)
+ */
+#if 3 < __GNUC__ + (4 <= __GNUC_MINOR__)
+# define __ignore_value(x) ({ __typeof__ (x) __x = (x); (void) __x; })
+#else
+# define __ignore_value(x) ((void) (x))
+#endif
+
#endif /* __CR_COMPILER_H__ */