test-container: Fix "unused code" warnings on HURD

Message ID xno817tnds.fsf@greed.delorie.com (mailing list archive)
State Committed
Headers
Series test-container: Fix "unused code" warnings on HURD |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent
dj/TryBot-32bit success Build for i686

Commit Message

DJ Delorie April 11, 2022, 7:45 p.m. UTC
  [mix of my previous patch plus fixing Florian's reported bug]

[I tried to install HURD locally in a VM and couldn't, so... untested
on HURD]

Comment out bits of code that are only used when we *have* pid
namespaces, to avoid "unused code" warnings.
  

Comments

Samuel Thibault April 11, 2022, 11:29 p.m. UTC | #1
DJ Delorie via Libc-alpha, le lun. 11 avril 2022 15:45:35 -0400, a ecrit:
> Comment out bits of code that are only used when we *have* pid
> namespaces, to avoid "unused code" warnings.

Tested and applied, thanks!

> [I tried to install HURD locally in a VM and couldn't, so... untested
> on HURD]

How did it fail?

> diff --git a/support/test-container.c b/support/test-container.c
> index c837c4d758..7557aac441 100644
> --- a/support/test-container.c
> +++ b/support/test-container.c
> @@ -230,6 +230,7 @@ concat (const char *str, ...)
>    return bufs[n];
>  }
>  
> +#ifdef CLONE_NEWNS
>  /* Like the above, but put spaces between words.  Caller frees.  */
>  static char *
>  concat_words (char **words, int num_words)
> @@ -255,6 +256,7 @@ concat_words (char **words, int num_words)
>  
>    return rv;
>  }
> +#endif
>  
>  /* Try to mount SRC onto DEST.  */
>  static void
> @@ -756,7 +758,9 @@ main (int argc, char **argv)
>    /* If set, the test runs as root instead of the user running the testsuite.  */
>    int be_su = 0;
>    int require_pidns = 0;
> +#ifdef CLONE_NEWNS
>    const char *pidns_comment = NULL;
> +#endif
>    int do_proc_mounts = 0;
>    int UMAP;
>    int GMAP;
> @@ -1046,8 +1050,10 @@ main (int argc, char **argv)
>  	    else if (nt >= 1 && strcmp (the_words[0], "pidns") == 0)
>  	      {
>  		require_pidns = 1;
> +#ifdef CLONE_NEWNS
>  		if (nt > 1)
>  		  pidns_comment = concat_words (the_words + 1, nt - 1);
> +#endif
>  	      }
>  	    else if (nt == 3 && strcmp (the_words[0], "mkdirp") == 0)
>  	      {
  

Patch

diff --git a/support/test-container.c b/support/test-container.c
index c837c4d758..7557aac441 100644
--- a/support/test-container.c
+++ b/support/test-container.c
@@ -230,6 +230,7 @@  concat (const char *str, ...)
   return bufs[n];
 }
 
+#ifdef CLONE_NEWNS
 /* Like the above, but put spaces between words.  Caller frees.  */
 static char *
 concat_words (char **words, int num_words)
@@ -255,6 +256,7 @@  concat_words (char **words, int num_words)
 
   return rv;
 }
+#endif
 
 /* Try to mount SRC onto DEST.  */
 static void
@@ -756,7 +758,9 @@  main (int argc, char **argv)
   /* If set, the test runs as root instead of the user running the testsuite.  */
   int be_su = 0;
   int require_pidns = 0;
+#ifdef CLONE_NEWNS
   const char *pidns_comment = NULL;
+#endif
   int do_proc_mounts = 0;
   int UMAP;
   int GMAP;
@@ -1046,8 +1050,10 @@  main (int argc, char **argv)
 	    else if (nt >= 1 && strcmp (the_words[0], "pidns") == 0)
 	      {
 		require_pidns = 1;
+#ifdef CLONE_NEWNS
 		if (nt > 1)
 		  pidns_comment = concat_words (the_words + 1, nt - 1);
+#endif
 	      }
 	    else if (nt == 3 && strcmp (the_words[0], "mkdirp") == 0)
 	      {