[libvirt] [PATCH] gcrypt: fix build in case we do not use gnutls and gcrypt

In case when we use any crypt library and gnutls make returns compilation errors. Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com> --- src/libvirt.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index 52462e3..77365d1 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -269,7 +269,7 @@ virWinsockInit(void) } #endif - +#ifdef WITH_GNUTLS #ifdef WITH_GNUTLS_GCRYPT static int virTLSMutexInit(void **priv) @@ -332,6 +332,7 @@ static struct gcry_thread_cbs virTLSThreadImpl = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; #endif /* WITH_GNUTLS_GCRYPT */ +#endif /* WITH_GNUTLS */ static bool virGlobalError; @@ -357,6 +358,7 @@ virGlobalInit(void) } #endif +#ifdef WITH_GNUTLS #ifdef WITH_GNUTLS_GCRYPT /* * This sequence of API calls it copied exactly from @@ -371,13 +373,10 @@ virGlobalInit(void) gcry_control(GCRYCTL_DISABLE_SECMEM, NULL, 0); gcry_control(GCRYCTL_INITIALIZATION_FINISHED, NULL, 0); } -#endif - - virLogSetFromEnv(); - -#ifdef WITH_GNUTLS +#endif /* End of WITH_GNUTLS_GCRYPT*/ virNetTLSInit(); -#endif +#endif /* End of WITH_GNUTLS*/ + virLogSetFromEnv(); #if WITH_CURL curl_global_init(CURL_GLOBAL_DEFAULT); -- 1.8.3.1

On 03/11/16 16:14, Olga Krishtal wrote:
In case when we use any crypt library and gnutls make returns compilation errors.
Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com> --- src/libvirt.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c index 52462e3..77365d1 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -269,7 +269,7 @@ virWinsockInit(void) } #endif
- +#ifdef WITH_GNUTLS #ifdef WITH_GNUTLS_GCRYPT static int virTLSMutexInit(void **priv) @@ -332,6 +332,7 @@ static struct gcry_thread_cbs virTLSThreadImpl = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; #endif /* WITH_GNUTLS_GCRYPT */ +#endif /* WITH_GNUTLS */
static bool virGlobalError; @@ -357,6 +358,7 @@ virGlobalInit(void) } #endif
+#ifdef WITH_GNUTLS #ifdef WITH_GNUTLS_GCRYPT /* * This sequence of API calls it copied exactly from @@ -371,13 +373,10 @@ virGlobalInit(void) gcry_control(GCRYCTL_DISABLE_SECMEM, NULL, 0); gcry_control(GCRYCTL_INITIALIZATION_FINISHED, NULL, 0); } -#endif - - virLogSetFromEnv(); - -#ifdef WITH_GNUTLS +#endif /* End of WITH_GNUTLS_GCRYPT*/ virNetTLSInit(); -#endif +#endif /* End of WITH_GNUTLS*/ + virLogSetFromEnv();
#if WITH_CURL curl_global_init(CURL_GLOBAL_DEFAULT); Error message:
libvirt.c:320:15: error: variable 'virTLSThreadImpl' has initializer but incomplete type static struct gcry_thread_cbs virTLSThreadImpl = { ^ libvirt.c:325:5: error: 'GCRY_THREAD_OPTION_PTHREAD' undeclared here (not in a function) GCRY_THREAD_OPTION_PTHREAD, ^ libvirt.c:325:5: error: excess elements in struct initializer [-Werror] libvirt.c:325:5: error: (near initialization for 'virTLSThreadImpl') [-Werror] libvirt.c:327:5: error: excess elements in struct initializer [-Werror] NULL, ^ libvirt.c:327:5: error: (near initialization for 'virTLSThreadImpl') [-Werror] libvirt.c:328:5: error: excess elements in struct initializer [-Werror] virTLSMutexInit, ^ libvirt.c:328:5: error: (near initialization for 'virTLSThreadImpl') [-Werror] libvirt.c:329:5: error: excess elements in struct initializer [-Werror] virTLSMutexDestroy, ^ libvirt.c:329:5: error: (near initialization for 'virTLSThreadImpl') [-Werror] libvirt.c:330:5: error: excess elements in struct initializer [-Werror] virTLSMutexLock, ^ libvirt.c:330:5: error: (near initialization for 'virTLSThreadImpl') [-Werror] libvirt.c:331:5: error: excess elements in struct initializer [-Werror] virTLSMutexUnlock, ^ libvirt.c:331:5: error: (near initialization for 'virTLSThreadImpl') [-Werror] libvirt.c:332:5: error: excess elements in struct initializer [-Werror] NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ^ libvirt.c:332:5: error: (near initialization for 'virTLSThreadImpl') [-Werror] libvirt.c:332:5: error: excess elements in struct initializer [-Werror] libvirt.c:332:5: error: (near initialization for 'virTLSThreadImpl') [-Werror] libvirt.c:332:5: error: excess elements in struct initializer [-Werror] libvirt.c:332:5: error: (near initialization for 'virTLSThreadImpl') [-Werror] libvirt.c:332:5: error: excess elements in struct initializer [-Werror] libvirt.c:332:5: error: (near initialization for 'virTLSThreadImpl') [-Werror] libvirt.c:332:5: error: excess elements in struct initializer [-Werror] libvirt.c:332:5: error: (near initialization for 'virTLSThreadImpl') [-Werror] libvirt.c:332:5: error: excess elements in struct initializer [-Werror] libvirt.c:332:5: error: (near initialization for 'virTLSThreadImpl') [-Werror] libvirt.c:332:5: error: excess elements in struct initializer [-Werror] libvirt.c:332:5: error: (near initialization for 'virTLSThreadImpl') [-Werror] libvirt.c:333:1: error: excess elements in struct initializer [-Werror] }; ^ libvirt.c:333:1: error: (near initialization for 'virTLSThreadImpl') [-Werror] libvirt.c: In function 'virGlobalInit': libvirt.c:367:5: error: implicit declaration of function 'gcry_control' [-Werror=implicit-function-declaration] if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0) { ^ libvirt.c:367:5: error: nested extern declaration of 'gcry_control' [-Werror=nested-externs] libvirt.c:367:22: error: 'GCRYCTL_ANY_INITIALIZATION_P' undeclared (first use in this function) if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0) { ^ libvirt.c:367:22: note: each undeclared identifier is reported only once for each function it appears in libvirt.c:368:22: error: 'GCRYCTL_SET_THREAD_CBS' undeclared (first use in this function) gcry_control(GCRYCTL_SET_THREAD_CBS, &virTLSThreadImpl); ^ libvirt.c:369:9: error: implicit declaration of function 'gcry_check_version' [-Werror=implicit-function-declaration] gcry_check_version(NULL); ^ libvirt.c:369:9: error: nested extern declaration of 'gcry_check_version' [-Werror=nested-externs] libvirt.c:371:22: error: 'GCRYCTL_DISABLE_SECMEM' undeclared (first use in this function) gcry_control(GCRYCTL_DISABLE_SECMEM, NULL, 0); ^ libvirt.c:372:22: error: 'GCRYCTL_INITIALIZATION_FINISHED' undeclared (first use in this function) gcry_control(GCRYCTL_INITIALIZATION_FINISHED, NULL, 0); -- Best regards, Olga

On Thu, Nov 03, 2016 at 04:14:34PM +0300, Olga Krishtal wrote:
In case when we use any crypt library and gnutls make returns compilation errors.
Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com> --- src/libvirt.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c index 52462e3..77365d1 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -269,7 +269,7 @@ virWinsockInit(void) } #endif
- +#ifdef WITH_GNUTLS #ifdef WITH_GNUTLS_GCRYPT
This doesn't make much sense. The WITH_GNUTLS_GCRYPT should be defined if-and-only-if WITH_GNUTLS is defined. If this isn't true, then we need to fix configure, rather than adding in this extra ifdef check. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ :|

On Thu, Nov 03, 2016 at 04:14:34PM +0300, Olga Krishtal wrote:
In case when we use any crypt library and gnutls make returns compilation errors.
Add info that it's caused by 680d2f49dad425395de627a31006cb84848cfa65, please.
Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com> --- src/libvirt.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c index 52462e3..77365d1 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -269,7 +269,7 @@ virWinsockInit(void) } #endif
- +#ifdef WITH_GNUTLS #ifdef WITH_GNUTLS_GCRYPT
This will fail syntax-check because the second line is not indented. I would rather change it to: #if defined WITH_GNUTLS && defined WITH_GNUTLS_GCRYPT With that you also don't need to add another #endif. But I feel like way better thing here would be to actually fix the offending commit by not even checking for GNUTLS_GCRYPT if we're not going to build with GNUTLS anyway. That's how it worked before.
static int virTLSMutexInit(void **priv) @@ -332,6 +332,7 @@ static struct gcry_thread_cbs virTLSThreadImpl = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; #endif /* WITH_GNUTLS_GCRYPT */ +#endif /* WITH_GNUTLS */
static bool virGlobalError; @@ -357,6 +358,7 @@ virGlobalInit(void) } #endif
+#ifdef WITH_GNUTLS #ifdef WITH_GNUTLS_GCRYPT /* * This sequence of API calls it copied exactly from @@ -371,13 +373,10 @@ virGlobalInit(void) gcry_control(GCRYCTL_DISABLE_SECMEM, NULL, 0); gcry_control(GCRYCTL_INITIALIZATION_FINISHED, NULL, 0); } -#endif - - virLogSetFromEnv(); - -#ifdef WITH_GNUTLS +#endif /* End of WITH_GNUTLS_GCRYPT*/ virNetTLSInit(); -#endif +#endif /* End of WITH_GNUTLS*/ + virLogSetFromEnv();
#if WITH_CURL curl_global_init(CURL_GLOBAL_DEFAULT); -- 1.8.3.1
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On 03/11/16 17:13, Martin Kletzander wrote:
On Thu, Nov 03, 2016 at 04:14:34PM +0300, Olga Krishtal wrote:
In case when we use any crypt library and gnutls make returns compilation errors.
Add info that it's caused by 680d2f49dad425395de627a31006cb84848cfa65, please.
Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com> --- src/libvirt.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c index 52462e3..77365d1 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -269,7 +269,7 @@ virWinsockInit(void) } #endif
- +#ifdef WITH_GNUTLS #ifdef WITH_GNUTLS_GCRYPT
This will fail syntax-check because the second line is not indented. I would rather change it to:
#if defined WITH_GNUTLS && defined WITH_GNUTLS_GCRYPT
With that you also don't need to add another #endif.
But I feel like way better thing here would be to actually fix the offending commit by not even checking for GNUTLS_GCRYPT if we're not going to build with GNUTLS anyway. That's how it worked before.
static int virTLSMutexInit(void **priv) @@ -332,6 +332,7 @@ static struct gcry_thread_cbs virTLSThreadImpl = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; #endif /* WITH_GNUTLS_GCRYPT */ +#endif /* WITH_GNUTLS */
static bool virGlobalError; @@ -357,6 +358,7 @@ virGlobalInit(void) } #endif
+#ifdef WITH_GNUTLS #ifdef WITH_GNUTLS_GCRYPT /* * This sequence of API calls it copied exactly from @@ -371,13 +373,10 @@ virGlobalInit(void) gcry_control(GCRYCTL_DISABLE_SECMEM, NULL, 0); gcry_control(GCRYCTL_INITIALIZATION_FINISHED, NULL, 0); } -#endif - - virLogSetFromEnv(); - -#ifdef WITH_GNUTLS +#endif /* End of WITH_GNUTLS_GCRYPT*/ virNetTLSInit(); -#endif +#endif /* End of WITH_GNUTLS*/ + virLogSetFromEnv();
#if WITH_CURL curl_global_init(CURL_GLOBAL_DEFAULT); -- 1.8.3.1
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Yes, I agree that fixing the commit is better idea. I'll send the second variant.
-- Best regards, Olga
participants (3)
-
Daniel P. Berrange
-
Martin Kletzander
-
Olga Krishtal