[libvirt] [PATCH] tests: virpcimock: Always declare __open_2

Peter Krempa posted 1 patch 4 years, 8 months ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/5c825fd4ede2edf3705f7010c5c21eab216de9dd.1565941407.git.pkrempa@redhat.com
tests/virpcimock.c | 5 +++++
1 file changed, 5 insertions(+)
[libvirt] [PATCH] tests: virpcimock: Always declare __open_2
Posted by Peter Krempa 4 years, 8 months ago
In some cases e.g. with clang on fedora 30 __open2 isn't even declared
which results in the following build error:

/home/pipo/libvirt/tests/virpcimock.c:939:1: error: no previous prototype for function
      '__open_2' [-Werror,-Wmissing-prototypes]
__open_2(const char *path, int flags)

Add a separate declaration to appease the compiler.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 tests/virpcimock.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index 829d61cd3f..cfe91ba3ff 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -935,6 +935,11 @@ open(const char *path, int flags, ...)
 }


+/* in some cases this function may not be present in headers, so we need
+ * a declaration to silence the complier */
+int
+__open_2(const char *path, int flags);
+
 int
 __open_2(const char *path, int flags)
 {
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] tests: virpcimock: Always declare __open_2
Posted by Erik Skultety 4 years, 8 months ago
On Fri, Aug 16, 2019 at 09:43:27AM +0200, Peter Krempa wrote:
> In some cases e.g. with clang on fedora 30 __open2 isn't even declared
> which results in the following build error:
>
> /home/pipo/libvirt/tests/virpcimock.c:939:1: error: no previous prototype for function
>       '__open_2' [-Werror,-Wmissing-prototypes]
> __open_2(const char *path, int flags)
>
> Add a separate declaration to appease the compiler.
>
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
I guess you could have simply pushed this as a build breaker, anyway:

Reviewed-by: Erik Skultety <eskultet@redhat.com>

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] tests: virpcimock: Always declare __open_2
Posted by Peter Krempa 4 years, 8 months ago
On Fri, Aug 16, 2019 at 09:52:02 +0200, Erik Skultety wrote:
> On Fri, Aug 16, 2019 at 09:43:27AM +0200, Peter Krempa wrote:
> > In some cases e.g. with clang on fedora 30 __open2 isn't even declared
> > which results in the following build error:
> >
> > /home/pipo/libvirt/tests/virpcimock.c:939:1: error: no previous prototype for function
> >       '__open_2' [-Werror,-Wmissing-prototypes]
> > __open_2(const char *path, int flags)
> >
> > Add a separate declaration to appease the compiler.
> >
> > Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> > ---
> I guess you could have simply pushed this as a build breaker, anyway:

I find this solution kind of ugly, that's why I wasn't completely
persuaded to push it right away.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list