[PATCH 2/2] virnuma: Annotate some functions as VIR_OPTNONE

Michal Privoznik mprivozn at redhat.com
Wed Mar 15 19:10:28 UTC 2023


Use newly introduced VIR_OPTNONE to stop clang from optimizing
our code so much that it ends up doing something else than it's
supposed to do.

The chosen functions are "random", until qemuxml2argvtest stops
failing (modulo one test case which uses virNumaCPUSetToNodeset()
and no matter what clang ignores optnone request).

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/util/virnuma.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index 4a15bf32c8..156b2e7bca 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -339,14 +339,14 @@ virNumaSetupMemoryPolicy(virDomainNumatuneMemMode mode G_GNUC_UNUSED,
     return 0;
 }
 
-bool
+bool VIR_OPTNONE
 virNumaIsAvailable(void)
 {
     return false;
 }
 
 
-int
+int VIR_OPTNONE
 virNumaGetMaxNode(void)
 {
     virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -355,7 +355,7 @@ virNumaGetMaxNode(void)
 }
 
 
-int
+int VIR_OPTNONE
 virNumaGetNodeMemory(int node G_GNUC_UNUSED,
                      unsigned long long *memsize,
                      unsigned long long *memfree)
@@ -371,7 +371,7 @@ virNumaGetNodeMemory(int node G_GNUC_UNUSED,
 }
 
 
-int
+int VIR_OPTNONE
 virNumaGetNodeCPUs(int node G_GNUC_UNUSED,
                    virBitmap **cpus)
 {
@@ -382,7 +382,7 @@ virNumaGetNodeCPUs(int node G_GNUC_UNUSED,
     return -1;
 }
 
-int
+int VIR_OPTNONE
 virNumaGetNodeOfCPU(int cpu G_GNUC_UNUSED)
 {
     errno = ENOSYS;
@@ -476,7 +476,7 @@ virNumaGetDistances(int node,
 
 #else /* !WITH_NUMACTL */
 
-bool
+bool VIR_OPTNONE
 virNumaNodeIsAvailable(int node)
 {
     int max_node = virNumaGetMaxNode();
@@ -489,7 +489,7 @@ virNumaNodeIsAvailable(int node)
 }
 
 
-int
+int VIR_OPTNONE
 virNumaGetDistances(int node G_GNUC_UNUSED,
                     int **distances,
                     int *ndistances)
@@ -938,7 +938,7 @@ virNumaGetPageInfo(int node G_GNUC_UNUSED,
 }
 
 
-int
+int VIR_OPTNONE
 virNumaGetPages(int node G_GNUC_UNUSED,
                 unsigned int **pages_size G_GNUC_UNUSED,
                 unsigned long long **pages_avail G_GNUC_UNUSED,
@@ -963,7 +963,7 @@ virNumaSetPagePoolSize(int node G_GNUC_UNUSED,
 }
 #endif /* #ifdef __linux__ */
 
-bool
+bool VIR_OPTNONE
 virNumaNodesetIsAvailable(virBitmap *nodeset)
 {
     ssize_t bit = -1;
@@ -1024,7 +1024,7 @@ virNumaGetHostMemoryNodeset(void)
  * Returns: 0 on success,
  *          -1 on failure (with error reported)
  */
-int
+int VIR_OPTNONE
 virNumaCPUSetToNodeset(virBitmap *cpuset,
                        virBitmap **nodeset)
 {
-- 
2.39.2



More information about the libvir-list mailing list