diff --git a/gtests/net/packetdrill/netdev.c b/gtests/net/packetdrill/netdev.c
index d895e5bb33c7968e282add1cac7a1ca3be135c41..a8cb5175a554e0d0e2858b43d9e3c4744a28cd66 100644
--- a/gtests/net/packetdrill/netdev.c
+++ b/gtests/net/packetdrill/netdev.c
@@ -84,13 +84,19 @@ static void cleanup_old_device(struct config *config,
 {
 #if defined(__NetBSD__)
 	char *cleanup_command = NULL;
+#ifdef DEBUG
 	int result;
+#endif
 
 	asprintf(&cleanup_command,
 		 "/sbin/ifconfig %s down delete > /dev/null 2>&1",
 		 TUN_DEV);
 	DEBUGP("running: '%s'\n", cleanup_command);
+#ifdef DEBUG
 	result = system(cleanup_command);
+#else
+	system(cleanup_command);
+#endif
 	DEBUGP("result: %d\n", result);
 	free(cleanup_command);
 #endif  /* defined(__NetBSD__) */