2019-08-26 07:49:38

by Patrick Steinhardt

[permalink] [raw]
Subject: [PATCH 1/3] mount: fix compilation if __GLIBC__ is not defined

As glibc versions before v2.24 couldn't safely include <linux/in6.h>,
commit 8af595b7 (mount: support compiling with old glibc, 2017-07-26)
introduced some preprocessor checks to special-case such old versions.
While there is a check whether __GLIBC__ is defined at all, it only
applies to the first comparison `__GLIBC__ < 2`, but doesn't apply to
the second check due to operator precedence. Thus the preprocessor may
use an undefined value and thus generate an error if __GLIBC__ is not
defined.

Fix the issue by wrapping the version check in braces.

Signed-off-by: Patrick Steinhardt <[email protected]>
---
utils/mount/network.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/utils/mount/network.c b/utils/mount/network.c
index e166a823..6ac913d9 100644
--- a/utils/mount/network.c
+++ b/utils/mount/network.c
@@ -39,7 +39,7 @@
#include <sys/socket.h>
#include <sys/wait.h>
#include <sys/stat.h>
-#if defined(__GLIBC__) && (__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 24)
+#if defined(__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 24))
/* Cannot safely include linux/in6.h in old glibc, so hardcode the needed values */
# define IPV6_PREFER_SRC_PUBLIC 2
# define IPV6_ADDR_PREFERENCES 72
--
2.23.0


2019-08-26 07:50:13

by Patrick Steinhardt

[permalink] [raw]
Subject: [PATCH 3/3] tests: add missing include for strerror(3P)

The function strerror(3P) is declared in <string.h>, but it is not
included in "statdb_dump.c". Include it to fix compile errors.

Signed-off-by: Patrick Steinhardt <[email protected]>
---
tests/statdb_dump.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/tests/statdb_dump.c b/tests/statdb_dump.c
index 92d63f29..3ac12bff 100644
--- a/tests/statdb_dump.c
+++ b/tests/statdb_dump.c
@@ -23,6 +23,7 @@
#include "config.h"
#endif

+#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <arpa/inet.h>
--
2.23.0

2019-08-26 18:55:06

by Steve Dickson

[permalink] [raw]
Subject: Re: [PATCH 1/3] mount: fix compilation if __GLIBC__ is not defined



On 8/26/19 3:48 AM, Patrick Steinhardt wrote:
> As glibc versions before v2.24 couldn't safely include <linux/in6.h>,
> commit 8af595b7 (mount: support compiling with old glibc, 2017-07-26)
> introduced some preprocessor checks to special-case such old versions.
> While there is a check whether __GLIBC__ is defined at all, it only
> applies to the first comparison `__GLIBC__ < 2`, but doesn't apply to
> the second check due to operator precedence. Thus the preprocessor may
> use an undefined value and thus generate an error if __GLIBC__ is not
> defined.
>
> Fix the issue by wrapping the version check in braces.
>
> Signed-off-by: Patrick Steinhardt <[email protected]>
Commited....

steved.
> ---
> utils/mount/network.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/utils/mount/network.c b/utils/mount/network.c
> index e166a823..6ac913d9 100644
> --- a/utils/mount/network.c
> +++ b/utils/mount/network.c
> @@ -39,7 +39,7 @@
> #include <sys/socket.h>
> #include <sys/wait.h>
> #include <sys/stat.h>
> -#if defined(__GLIBC__) && (__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 24)
> +#if defined(__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 24))
> /* Cannot safely include linux/in6.h in old glibc, so hardcode the needed values */
> # define IPV6_PREFER_SRC_PUBLIC 2
> # define IPV6_ADDR_PREFERENCES 72
>

2019-08-26 18:55:36

by Steve Dickson

[permalink] [raw]
Subject: Re: [PATCH 3/3] tests: add missing include for strerror(3P)



On 8/26/19 3:48 AM, Patrick Steinhardt wrote:
> The function strerror(3P) is declared in <string.h>, but it is not
> included in "statdb_dump.c". Include it to fix compile errors.
>
> Signed-off-by: Patrick Steinhardt <[email protected]>
> ---
> tests/statdb_dump.c | 1 +
> 1 file changed, 1 insertion(+)
Committed...

steved.
>
> diff --git a/tests/statdb_dump.c b/tests/statdb_dump.c
> index 92d63f29..3ac12bff 100644
> --- a/tests/statdb_dump.c
> +++ b/tests/statdb_dump.c
> @@ -23,6 +23,7 @@
> #include "config.h"
> #endif
>
> +#include <string.h>
> #include <stdio.h>
> #include <errno.h>
> #include <arpa/inet.h>
>