Merge AOSP android-9.0.0_r3

Fix conflicts and make it build in 5.1, 6.0, 7.1, 8.1, and 9.0

Change-Id: Ida0a64c29ff27d339b7f42a18d820930964ac6e4
diff --git a/libtar/append.c b/libtar/append.c
index 66e3aa1..8f09de2 100644
--- a/libtar/append.c
+++ b/libtar/append.c
@@ -416,8 +416,7 @@
 tar_append_buffer(TAR *t, void *buf, size_t len)
 {
 	char block[T_BLOCKSIZE];
-	int filefd;
-	int i, j;
+	int i;
 	size_t size = len;
 
 	for (i = size; i > T_BLOCKSIZE; i -= T_BLOCKSIZE)
diff --git a/libtar/basename.c b/libtar/basename.c
index 32108d6..3f4d315 100644
--- a/libtar/basename.c
+++ b/libtar/basename.c
@@ -28,7 +28,7 @@
  */
 
 #ifndef lint
-static char rcsid[] = "$OpenBSD: basename.c,v 1.4 1999/05/30 17:10:30 espie Exp $";
+//static char rcsid[] = "$OpenBSD: basename.c,v 1.4 1999/05/30 17:10:30 espie Exp $";
 #endif /* not lint */
 
 #include <errno.h>
diff --git a/libtar/block.c b/libtar/block.c
index d0adb2b..834c164 100644
--- a/libtar/block.c
+++ b/libtar/block.c
@@ -357,7 +357,8 @@
 				if (*start == '2')
 				{
 					start++;
-					if (start + sizeof(struct ext4_encryption_policy) != '\n')
+					char *newline_check = start + sizeof(struct ext4_encryption_policy);
+					if (*newline_check != '\n')
 						printf("did not find newline char in expected location, continuing anyway...\n");
 					memcpy(t->th_buf.eep, start, sizeof(struct ext4_encryption_policy));
 #ifdef DEBUG
diff --git a/libtar/dirname.c b/libtar/dirname.c
index 4e06067..31dbe13 100644
--- a/libtar/dirname.c
+++ b/libtar/dirname.c
@@ -28,7 +28,7 @@
  */
 
 #ifndef lint
-static char rcsid[] = "$OpenBSD: dirname.c,v 1.4 1999/05/30 17:10:30 espie Exp $";
+//static char rcsid[] = "$OpenBSD: dirname.c,v 1.4 1999/05/30 17:10:30 espie Exp $";
 #endif /* not lint */
 
 #include <errno.h>
diff --git a/libtar/extract.c b/libtar/extract.c
index fcd403a..ea86c23 100644
--- a/libtar/extract.c
+++ b/libtar/extract.c
@@ -12,6 +12,7 @@
 
 #include <internal.h>
 
+#include <inttypes.h>
 #include <stdio.h>
 #include <string.h>
 #include <sys/param.h>
@@ -227,7 +228,7 @@
 	if (mkdirhier(dirname(filename)) == -1)
 		return -1;
 
-	printf("  ==> extracting: %s (file size %lld bytes)\n",
+	printf("  ==> extracting: %s (file size %" PRId64 " bytes)\n",
 			filename, size);
 
 	fdout = open(filename, O_WRONLY | O_CREAT | O_TRUNC
diff --git a/libtar/handle.c b/libtar/handle.c
index 28a7dc2..a26c094 100644
--- a/libtar/handle.c
+++ b/libtar/handle.c
@@ -32,7 +32,7 @@
 
 static int
 tar_init(TAR **t, const char *pathname, tartype_t *type,
-	 int oflags, int mode, int options)
+	 int oflags, int mode __unused, int options)
 {
 	if ((oflags & O_ACCMODE) == O_RDWR)
 	{