diff mbox

Avoid fall-through in test-container if execlp fails

Message ID alpine.DEB.2.21.1902122304350.6435@digraph.polyomino.org.uk
State Committed
Headers show

Commit Message

Joseph Myers Feb. 12, 2019, 11:05 p.m. UTC
One of the implicit-fallthrough warnings from compiling glibc with
-Wextra appears to indicate an actual bug: the test-container code
could fall through inappropriately if execlp returns (which only
occurs on error).  This patch adds appropriate error handling in this
case to avoid that fall-through.

Tested for x86_64.

2019-02-12  Joseph Myers  <joseph@codesourcery.com>

	* support/test-container.c (recursive_remove): Use FAIL_EXIT1 if
	execlp returns.

Comments

Florian Weimer Feb. 13, 2019, 8:19 a.m. UTC | #1
* Joseph Myers:

> diff --git a/support/test-container.c b/support/test-container.c
> index a24b24c03b..ed911e33f9 100644
> --- a/support/test-container.c
> +++ b/support/test-container.c
> @@ -361,6 +361,7 @@ recursive_remove (char *path)
>    case 0:
>      /* Child.  */
>      execlp ("rm", "rm", "-rf", path, NULL);
> +    FAIL_EXIT1 ("exec rm: %m");
>    default:
>      /* Parent.  */
>      waitpid (child, &status, 0);

Looks good to me.
diff mbox

Patch

diff --git a/support/test-container.c b/support/test-container.c
index a24b24c03b..ed911e33f9 100644
--- a/support/test-container.c
+++ b/support/test-container.c
@@ -361,6 +361,7 @@  recursive_remove (char *path)
   case 0:
     /* Child.  */
     execlp ("rm", "rm", "-rf", path, NULL);
+    FAIL_EXIT1 ("exec rm: %m");
   default:
     /* Parent.  */
     waitpid (child, &status, 0);