Skip to contentSkip to conversation

compiler.h: replace QEMU_WARN_UNUSED_RESULT with G_GNUC_WARN_UNUSED_RESULT

PATCH In review [email protected] 2 participants 2 messages Mar 16, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 8/27 compiler.h: replace QEMU_WARN_UNUSED_RESULT with G_GNUC_WARN_UNUSED_RESULT

From: Marc-André Lureau <[email protected]>

One less qemu-specific macro. It also helps to make some headers/units only depend on glib, and thus moved in standalone projects eventually.

---
 include/qemu-common.h      |  2 +-
 include/qemu/compiler.h    |  2 --
 include/qemu/range.h       |  4 ++--
 scripts/cocci-macro-file.h |  2 +-
 block/qcow2-refcount.c     | 20 +++++++++++---------
 scripts/checkpatch.pl      |  2 +-
 6 files changed, 16 insertions(+), 16 deletions(-)
include/qemu-common.h +1 -1
index a049ac073874..a577ca92b1f1 100644
@@ -27,7 +27,7 @@ int qemu_main(int argc, char **argv, char **envp);
 #endif
 
 ssize_t qemu_write_full(int fd, const void *buf, size_t count)
-    QEMU_WARN_UNUSED_RESULT;
+    G_GNUC_WARN_UNUSED_RESULT;
 
 #ifndef _WIN32
 int qemu_pipe(int pipefd[2]);
include/qemu/compiler.h +0 -2
index f2bd050e3b9a..8385e477c18e 100644
@@ -19,8 +19,6 @@
 
 #define QEMU_NORETURN __attribute__ ((__noreturn__))
 
-#define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
-
 #define QEMU_SENTINEL __attribute__((sentinel))
 
 #if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__))
include/qemu/range.h +2 -2
index f62b363e0d12..7e2b1cc447af 100644
@@ -114,8 +114,8 @@ static inline uint64_t range_upb(Range *range)
  * @size may be 0. If the range would overflow, returns -ERANGE, otherwise
  * 0.
  */
-static inline int QEMU_WARN_UNUSED_RESULT range_init(Range *range, uint64_t lob,
-                                                     uint64_t size)
+G_GNUC_WARN_UNUSED_RESULT
+static inline int range_init(Range *range, uint64_t lob, uint64_t size)
 {
     if (lob + size < lob) {
         return -ERANGE;
scripts/cocci-macro-file.h +1 -1
index c2fcea8e77a2..9daec24d7825 100644
@@ -20,7 +20,7 @@
 
 /* From qemu/compiler.h */
 #define QEMU_NORETURN __attribute__ ((__noreturn__))
-#define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
+#define G_GNUC_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
 #define QEMU_SENTINEL __attribute__((sentinel))
 
 #if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__))
block/qcow2-refcount.c +11 -9
index 94033972bedc..b91499410c0c 100644
@@ -33,9 +33,11 @@
 
 static int64_t alloc_clusters_noref(BlockDriverState *bs, uint64_t size,
                                     uint64_t max);
-static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs,
-                            int64_t offset, int64_t length, uint64_t addend,
-                            bool decrease, enum qcow2_discard_type type);
+
+G_GNUC_WARN_UNUSED_RESULT
+static int update_refcount(BlockDriverState *bs,
+                           int64_t offset, int64_t length, uint64_t addend,
+                           bool decrease, enum qcow2_discard_type type);
 
 static uint64_t get_refcount_ro0(const void *refcount_array, uint64_t index);
 static uint64_t get_refcount_ro1(const void *refcount_array, uint64_t index);
@@ -803,12 +805,12 @@ found:
 /* XXX: cache several refcount block clusters ? */
 /* @addend is the absolute value of the addend; if @decrease is set, @addend
  * will be subtracted from the current refcount, otherwise it will be added */
-static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs,
-                                                   int64_t offset,
-                                                   int64_t length,
-                                                   uint64_t addend,
-                                                   bool decrease,
-                                                   enum qcow2_discard_type type)
+static int update_refcount(BlockDriverState *bs,
+                           int64_t offset,
+                           int64_t length,
+                           uint64_t addend,
+                           bool decrease,
+                           enum qcow2_discard_type type)
 {
     BDRVQcow2State *s = bs->opaque;
     int64_t start, last, cluster_offset;
scripts/checkpatch.pl +1 -1
index a07f0effb540..797738a8e839 100755
@@ -224,7 +224,7 @@ our $Attribute	= qr{
 			const|
 			volatile|
 			QEMU_NORETURN|
-			QEMU_WARN_UNUSED_RESULT|
+			G_GNUC_WARN_UNUSED_RESULT|
 			QEMU_SENTINEL|
 			QEMU_PACKED|
 			G_GNUC_PRINTF
Signature · 1 line
2.35.1.273.ge6ebfd0e8cbb
Reviewed-by on v1 8/27
#1 lore raw
Quoted 7 lines · On 16/3/22 10:52, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

One less qemu-specific macro. It also helps to make some headers/units only depend on glib, and thus moved in standalone projects eventually.

Quoted 8 lines
---
  include/qemu-common.h      |  2 +-
  include/qemu/compiler.h    |  2 --
  include/qemu/range.h       |  4 ++--
  scripts/cocci-macro-file.h |  2 +-
  block/qcow2-refcount.c     | 20 +++++++++++---------
  scripts/checkpatch.pl      |  2 +-
  6 files changed, 16 insertions(+), 16 deletions(-)

Preferably poisoning QEMU_WARN_UNUSED_RESULT: