diff mbox series

[1/3] mount: fix compilation if __GLIBC__ is not defined

Message ID 6de0089348765e60bcdf59ef5813d7bb631c967f.1566805721.git.ps@pks.im (mailing list archive)
State New, archived
Headers show
Series [1/3] mount: fix compilation if __GLIBC__ is not defined | expand

Commit Message

Patrick Steinhardt Aug. 26, 2019, 7:48 a.m. UTC
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 <ps@pks.im>
---
 utils/mount/network.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Steve Dickson Aug. 26, 2019, 6:03 p.m. UTC | #1
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 <ps@pks.im>
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
>
diff mbox series

Patch

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