[PATCH] fix build with gcc 4.8.5-4 and -Werror=inline option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



fix numerous inlining errors like:

In file included from vircgroupmock.c:24:0:
In function 'stat':
virmock.h:259:1: error: inlining failed in call to 'callStat.part.1':
call is unlikely and code size would grow [-Werror=inline]
 callStat(int (*realStat)(const char *, struct stat *),
---
 tests/Makefile.am |  8 +++++---
 tests/virmock.c   | 43 +++++++++++++++++++++++++++++++++++++++++++
 tests/virmock.h   | 16 ++--------------
 3 files changed, 50 insertions(+), 17 deletions(-)
 create mode 100644 tests/virmock.c

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 238f6da..1f73958 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1071,7 +1071,8 @@ vircgrouptest_SOURCES = \
 vircgrouptest_LDADD = $(LDADDS)
 
 vircgroupmock_la_SOURCES = \
-	vircgroupmock.c
+	vircgroupmock.c \
+	virmock.c
 vircgroupmock_la_CFLAGS = $(AM_CFLAGS)
 vircgroupmock_la_LDFLAGS = $(MOCKLIBS_LDFLAGS)
 vircgroupmock_la_LIBADD = $(MOCKLIBS_LIBS)
@@ -1081,7 +1082,7 @@ vircryptotest_SOURCES = \
 vircryptotest_LDADD = $(LDADDS)
 
 virhostdevtest_SOURCES = \
-	virhostdevtest.c testutils.h testutils.c
+	virhostdevtest.c testutils.h testutils.c virmock.c
 virhostdevtest_LDADD = $(LDADDS)
 
 virpcitest_SOURCES = \
@@ -1089,7 +1090,8 @@ virpcitest_SOURCES = \
 virpcitest_LDADD = $(LDADDS)
 
 virpcimock_la_SOURCES = \
-	virpcimock.c
+	virpcimock.c \
+	virmock.c
 virpcimock_la_CFLAGS = $(AM_CFLAGS)
 virpcimock_la_LDFLAGS = $(MOCKLIBS_LDFLAGS)
 virpcimock_la_LIBADD = $(MOCKLIBS_LIBS)
diff --git a/tests/virmock.c b/tests/virmock.c
new file mode 100644
index 0000000..98dd872
--- /dev/null
+++ b/tests/virmock.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <config.h>
+
+#ifdef __linux__
+# include "virmock.h"
+
+int callStat(int (*realStat)(const char *, struct stat *),
+             int (*realXstat)(int, const char *, struct stat *),
+             int __ver, const char *__filename, struct stat *__stat_buf)
+{
+    if (!realXstat) {
+        if (__ver == _STAT_VER) {
+            return realStat(__filename, __stat_buf);
+        } else {
+            fprintf(stderr, "Not handled __xstat(ver=%d)", __ver);
+            abort();
+        }
+    }
+
+    return realXstat(__ver, __filename, __stat_buf);
+}
+
+#else
+/* Nothing to override on non-__linux__ platforms */
+#endif
diff --git a/tests/virmock.h b/tests/virmock.h
index 27c03ba..4b50976 100644
--- a/tests/virmock.h
+++ b/tests/virmock.h
@@ -255,22 +255,10 @@
     static void (*real_##name)(void);                                   \
     void name(void)
 
-static inline int
+int
 callStat(int (*realStat)(const char *, struct stat *),
          int (*realXstat)(int, const char *, struct stat *),
-         int __ver, const char *__filename, struct stat *__stat_buf)
-{
-    if (!realXstat) {
-        if (__ver == _STAT_VER) {
-            return realStat(__filename, __stat_buf);
-        } else {
-            fprintf(stderr, "Not handled __xstat(ver=%d)", __ver);
-            abort();
-        }
-    }
-
-    return realXstat(__ver, __filename, __stat_buf);
-}
+         int __ver, const char *__filename, struct stat *__stat_buf);
 
 # define VIR_MOCK_CALL_STAT(__ver, __filename, __stat_buf)              \
     callStat(real_stat, real___xstat, __ver, __filename, __stat_buf)
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]