linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] mount: fix compilation if __GLIBC__ is not defined
@ 2019-08-26  7:48 Patrick Steinhardt
  2019-08-26  7:48 ` [PATCH 2/3] nfsdcld: add missing include for PATH_MAX Patrick Steinhardt
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Patrick Steinhardt @ 2019-08-26  7:48 UTC (permalink / raw)
  To: linux-nfs; +Cc: Patrick Steinhardt

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(-)

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] nfsdcld: add missing include for PATH_MAX
  2019-08-26  7:48 [PATCH 1/3] mount: fix compilation if __GLIBC__ is not defined Patrick Steinhardt
@ 2019-08-26  7:48 ` Patrick Steinhardt
  2019-08-26 18:03   ` Steve Dickson
  2019-08-26  7:48 ` [PATCH 3/3] tests: add missing include for strerror(3P) Patrick Steinhardt
  2019-08-26 18:03 ` [PATCH 1/3] mount: fix compilation if __GLIBC__ is not defined Steve Dickson
  2 siblings, 1 reply; 6+ messages in thread
From: Patrick Steinhardt @ 2019-08-26  7:48 UTC (permalink / raw)
  To: linux-nfs; +Cc: Patrick Steinhardt

While glibc transitively includes <limits.h> and thus has PATH_MAX
available, other libc implementations may not have the transitive
include and thus miss the definition. Add an explicit include of
<limits.h> to fix compilation with musl libc.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 utils/nfsdcld/legacy.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/utils/nfsdcld/legacy.c b/utils/nfsdcld/legacy.c
index f0ca3168..07f477ab 100644
--- a/utils/nfsdcld/legacy.c
+++ b/utils/nfsdcld/legacy.c
@@ -24,6 +24,7 @@
 #include <errno.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <limits.h>
 #include "cld.h"
 #include "sqlite.h"
 #include "xlog.h"
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] tests: add missing include for strerror(3P)
  2019-08-26  7:48 [PATCH 1/3] mount: fix compilation if __GLIBC__ is not defined Patrick Steinhardt
  2019-08-26  7:48 ` [PATCH 2/3] nfsdcld: add missing include for PATH_MAX Patrick Steinhardt
@ 2019-08-26  7:48 ` Patrick Steinhardt
  2019-08-26 18:03   ` Steve Dickson
  2019-08-26 18:03 ` [PATCH 1/3] mount: fix compilation if __GLIBC__ is not defined Steve Dickson
  2 siblings, 1 reply; 6+ messages in thread
From: Patrick Steinhardt @ 2019-08-26  7:48 UTC (permalink / raw)
  To: linux-nfs; +Cc: Patrick Steinhardt

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 <ps@pks.im>
---
 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] mount: fix compilation if __GLIBC__ is not defined
  2019-08-26  7:48 [PATCH 1/3] mount: fix compilation if __GLIBC__ is not defined Patrick Steinhardt
  2019-08-26  7:48 ` [PATCH 2/3] nfsdcld: add missing include for PATH_MAX Patrick Steinhardt
  2019-08-26  7:48 ` [PATCH 3/3] tests: add missing include for strerror(3P) Patrick Steinhardt
@ 2019-08-26 18:03 ` Steve Dickson
  2 siblings, 0 replies; 6+ messages in thread
From: Steve Dickson @ 2019-08-26 18:03 UTC (permalink / raw)
  To: Patrick Steinhardt, linux-nfs



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
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] nfsdcld: add missing include for PATH_MAX
  2019-08-26  7:48 ` [PATCH 2/3] nfsdcld: add missing include for PATH_MAX Patrick Steinhardt
@ 2019-08-26 18:03   ` Steve Dickson
  0 siblings, 0 replies; 6+ messages in thread
From: Steve Dickson @ 2019-08-26 18:03 UTC (permalink / raw)
  To: Patrick Steinhardt, linux-nfs



On 8/26/19 3:48 AM, Patrick Steinhardt wrote:
> While glibc transitively includes <limits.h> and thus has PATH_MAX
> available, other libc implementations may not have the transitive
> include and thus miss the definition. Add an explicit include of
> <limits.h> to fix compilation with musl libc.
> 
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
Committed... 

steved.
> ---
>  utils/nfsdcld/legacy.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/utils/nfsdcld/legacy.c b/utils/nfsdcld/legacy.c
> index f0ca3168..07f477ab 100644
> --- a/utils/nfsdcld/legacy.c
> +++ b/utils/nfsdcld/legacy.c
> @@ -24,6 +24,7 @@
>  #include <errno.h>
>  #include <sys/types.h>
>  #include <sys/stat.h>
> +#include <limits.h>
>  #include "cld.h"
>  #include "sqlite.h"
>  #include "xlog.h"
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] tests: add missing include for strerror(3P)
  2019-08-26  7:48 ` [PATCH 3/3] tests: add missing include for strerror(3P) Patrick Steinhardt
@ 2019-08-26 18:03   ` Steve Dickson
  0 siblings, 0 replies; 6+ messages in thread
From: Steve Dickson @ 2019-08-26 18:03 UTC (permalink / raw)
  To: Patrick Steinhardt, linux-nfs



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 <ps@pks.im>
> ---
>  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>
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-08-26 18:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-26  7:48 [PATCH 1/3] mount: fix compilation if __GLIBC__ is not defined Patrick Steinhardt
2019-08-26  7:48 ` [PATCH 2/3] nfsdcld: add missing include for PATH_MAX Patrick Steinhardt
2019-08-26 18:03   ` Steve Dickson
2019-08-26  7:48 ` [PATCH 3/3] tests: add missing include for strerror(3P) Patrick Steinhardt
2019-08-26 18:03   ` Steve Dickson
2019-08-26 18:03 ` [PATCH 1/3] mount: fix compilation if __GLIBC__ is not defined Steve Dickson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).