Add a enum for decoding to tprint_iov() and tprint_iov_upto()

Introduce a new type iov_decode which will be used instead of the integer
"decode" as a parameter.

* defs.h (iov_decode): New enum.
(tprint_iov, tprint_iov_upto): Change type of "decode_iov" to enum iov_decode.
* aio.c (print_iocb): Change type of "decode_iov" to enum iov_decode in
tprint_iov() call.
* keyctl.c (keyctl_instantiate_key_iov): Likewise.
* process.c (ptrace): Likewise.
* process_vm.c (process_vm_readv, process_vm_writev): Likewise.
* io.c (writev, do_pwritev, vmsplice): Likewise.
(print_iovec): Replace the condition with a switch.
(tprint_iov_upto): Change type of "decode_iov" to enum iov_decode.
(readv, do_preadv): Change type of "decode_iov" to enum iov_decode in
tprint_iov_upto() call.
* scsi.c (print_sg_io_v3_req, print_sg_io_v3_res, print_sg_io_v4_req,
print_sg_io_v4_res): Likewise.
* net.c (do_msghdr): Adapt call of tprint_iov_upto().
diff --git a/aio.c b/aio.c
index e02af7d..29562d2 100644
--- a/aio.c
+++ b/aio.c
@@ -140,7 +140,9 @@
 		if (iocb_is_valid(cb)) {
 			tprints(", iovec=");
 			tprint_iov(tcp, cb->aio_nbytes, cb->aio_buf,
-				   cb->aio_lio_opcode == 8);
+				   cb->aio_lio_opcode == 8
+				   ? IOV_DECODE_STR
+				   : IOV_DECODE_ADDR);
 		} else {
 			tprintf(", buf=%#" PRIx64 ", nbytes=%" PRIu64,
 				(uint64_t) cb->aio_buf,
diff --git a/defs.h b/defs.h
index 8672f96..99447e6 100644
--- a/defs.h
+++ b/defs.h
@@ -447,6 +447,11 @@
 };
 extern enum sock_proto get_proto_by_name(const char *);
 
+enum iov_decode {
+	IOV_DECODE_ADDR,
+	IOV_DECODE_STR
+};
+
 typedef enum {
 	CFLAG_NONE = 0,
 	CFLAG_ONLY_STATS,
@@ -665,8 +670,9 @@
 #define tprintsigmask_addr(prefix, mask) \
 	tprints(sprintsigmask_n((prefix), (mask), sizeof(mask)))
 extern void printsignal(int);
-extern void tprint_iov(struct tcb *, unsigned long, unsigned long, int decode_iov);
-extern void tprint_iov_upto(struct tcb *, unsigned long, unsigned long, int decode_iov, unsigned long);
+extern void tprint_iov(struct tcb *, unsigned long, unsigned long, enum iov_decode);
+extern void tprint_iov_upto(struct tcb *, unsigned long, unsigned long,
+			    enum iov_decode, unsigned long);
 extern void tprint_open_modes(unsigned int);
 extern const char *sprint_open_modes(unsigned int);
 extern void print_seccomp_filter(struct tcb *, unsigned long);
diff --git a/io.c b/io.c
index 3025486..da8b9d2 100644
--- a/io.c
+++ b/io.c
@@ -58,7 +58,7 @@
 }
 
 struct print_iovec_config {
-	int decode_iov;
+	enum iov_decode decode_iov;
 	unsigned long data_size;
 };
 
@@ -66,7 +66,7 @@
 print_iovec(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
 {
 	const unsigned long *iov;
-	unsigned long iov_buf[2];
+	unsigned long iov_buf[2], len;
 	struct print_iovec_config *c = data;
 
         if (elem_size < sizeof(iov_buf)) {
@@ -79,14 +79,18 @@
 
 	tprints("{");
 
-	if (c->decode_iov) {
-		unsigned long len = iov[1];
-		if (len > c->data_size)
-			len = c->data_size;
-		c->data_size -= len;
-		printstr(tcp, iov[0], len);
-	} else {
-		printaddr(iov[0]);
+	len = iov[1];
+
+	switch (c->decode_iov) {
+		case IOV_DECODE_STR:
+			if (len > c->data_size)
+				len = c->data_size;
+			c->data_size -= len;
+			printstr(tcp, iov[0], len);
+			break;
+		default:
+			printaddr(iov[0]);
+			break;
 	}
 
 	tprintf(", %lu}", iov[1]);
@@ -100,7 +104,7 @@
  */
 void
 tprint_iov_upto(struct tcb *tcp, unsigned long len, unsigned long addr,
-		int decode_iov, unsigned long data_size)
+		enum iov_decode decode_iov, unsigned long data_size)
 {
 	unsigned long iov[2];
 	struct print_iovec_config config =
@@ -111,7 +115,8 @@
 }
 
 void
-tprint_iov(struct tcb *tcp, unsigned long len, unsigned long addr, int decode_iov)
+tprint_iov(struct tcb *tcp, unsigned long len, unsigned long addr,
+	   enum iov_decode decode_iov)
 {
 	tprint_iov_upto(tcp, len, addr, decode_iov, (unsigned long) -1L);
 }
@@ -122,8 +127,8 @@
 		printfd(tcp, tcp->u_arg[0]);
 		tprints(", ");
 	} else {
-		tprint_iov_upto(tcp, tcp->u_arg[2], tcp->u_arg[1], 1,
-				tcp->u_rval);
+		tprint_iov_upto(tcp, tcp->u_arg[2], tcp->u_arg[1],
+				IOV_DECODE_STR, tcp->u_rval);
 		tprintf(", %lu", tcp->u_arg[2]);
 	}
 	return 0;
@@ -133,7 +138,7 @@
 {
 	printfd(tcp, tcp->u_arg[0]);
 	tprints(", ");
-	tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
+	tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], IOV_DECODE_STR);
 	tprintf(", %lu", tcp->u_arg[2]);
 
 	return RVAL_DECODED;
@@ -224,7 +229,7 @@
 		printfd(tcp, tcp->u_arg[0]);
 		tprints(", ");
 	} else {
-		tprint_iov_upto(tcp, tcp->u_arg[2], tcp->u_arg[1], 1,
+		tprint_iov_upto(tcp, tcp->u_arg[2], tcp->u_arg[1], IOV_DECODE_STR,
 				tcp->u_rval);
 		tprintf(", %lu, ", tcp->u_arg[2]);
 		print_lld_from_low_high_val(tcp, 3);
@@ -251,7 +256,7 @@
 {
 	printfd(tcp, tcp->u_arg[0]);
 	tprints(", ");
-	tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
+	tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], IOV_DECODE_STR);
 	tprintf(", %lu, ", tcp->u_arg[2]);
 	print_lld_from_low_high_val(tcp, 3);
 	if (flags_arg >= 0) {
@@ -318,7 +323,7 @@
 	printfd(tcp, tcp->u_arg[0]);
 	tprints(", ");
 	/* const struct iovec *iov, unsigned long nr_segs */
-	tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
+	tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], IOV_DECODE_STR);
 	tprintf(", %lu, ", tcp->u_arg[2]);
 	/* unsigned int flags */
 	printflags(splice_flags, tcp->u_arg[3], "SPLICE_F_???");
diff --git a/keyctl.c b/keyctl.c
index 50d6fb4..456649e 100644
--- a/keyctl.c
+++ b/keyctl.c
@@ -156,7 +156,7 @@
 {
 	print_keyring_serial_number(id1);
 	tprints(", ");
-	tprint_iov(tcp, len, addr, 1);
+	tprint_iov(tcp, len, addr, IOV_DECODE_STR);
 	tprintf(", %lu, ", len);
 	print_keyring_serial_number(id2);
 }
diff --git a/net.c b/net.c
index 51c3961..a55fb64 100644
--- a/net.c
+++ b/net.c
@@ -582,8 +582,9 @@
 	printsock(tcp, (long)msg->msg_name, msg->msg_namelen);
 
 	tprintf(", msg_iov(%lu)=", (unsigned long)msg->msg_iovlen);
+
 	tprint_iov_upto(tcp, (unsigned long)msg->msg_iovlen,
-		   (unsigned long)msg->msg_iov, 1, data_size);
+			(unsigned long)msg->msg_iov, IOV_DECODE_STR, data_size);
 
 #ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL
 	tprintf(", msg_controllen=%lu", (unsigned long)msg->msg_controllen);
diff --git a/process.c b/process.c
index 3aecf08..32dcfe2 100644
--- a/process.c
+++ b/process.c
@@ -201,7 +201,7 @@
 			print_sigset_addr_len(tcp, data, addr);
 			break;
 		case PTRACE_SETREGSET:
-			tprint_iov(tcp, /*len:*/ 1, data, /*as string:*/ 0);
+			tprint_iov(tcp, /*len:*/ 1, data, IOV_DECODE_ADDR);
 			break;
 #ifndef IA64
 		case PTRACE_PEEKDATA:
@@ -238,7 +238,7 @@
 			printnum_ulong(tcp, data);
 			break;
 		case PTRACE_GETREGSET:
-			tprint_iov(tcp, /*len:*/ 1, data, /*as string:*/ 0);
+			tprint_iov(tcp, /*len:*/ 1, data, IOV_DECODE_ADDR);
 			break;
 		case PTRACE_GETSIGINFO:
 			printsiginfo_at(tcp, data);
diff --git a/process_vm.c b/process_vm.c
index 82e1e16..0a9dcd2 100644
--- a/process_vm.c
+++ b/process_vm.c
@@ -38,7 +38,8 @@
 		if (syserror(tcp)) {
 			printaddr(tcp->u_arg[1]);
 		} else {
-			tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
+			tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1],
+				   IOV_DECODE_STR);
 		}
 		/* arg 3: local iovcnt */
 		tprintf(", %lu, ", tcp->u_arg[2]);
@@ -46,7 +47,8 @@
 		if (syserror(tcp)) {
 			printaddr(tcp->u_arg[3]);
 		} else {
-			tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
+			tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3],
+				   IOV_DECODE_ADDR);
 		}
 		/* arg 5: remote iovcnt */
 		/* arg 6: flags */
@@ -60,11 +62,11 @@
 	/* arg 1: pid */
 	tprintf("%ld, ", tcp->u_arg[0]);
 	/* arg 2: local iov */
-	tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], 1);
+	tprint_iov(tcp, tcp->u_arg[2], tcp->u_arg[1], IOV_DECODE_STR);
 	/* arg 3: local iovcnt */
 	tprintf(", %lu, ", tcp->u_arg[2]);
 	/* arg 4: remote iov */
-	tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], 0);
+	tprint_iov(tcp, tcp->u_arg[4], tcp->u_arg[3], IOV_DECODE_ADDR);
 	/* arg 5: remote iovcnt */
 	/* arg 6: flags */
 	tprintf(", %lu, %lu", tcp->u_arg[4], tcp->u_arg[5]);
diff --git a/scsi.c b/scsi.c
index 83ff8fe..dc51dd5 100644
--- a/scsi.c
+++ b/scsi.c
@@ -84,7 +84,8 @@
 		tprintf(", data[%u]=", sg_io.dxfer_len);
 		if (sg_io.iovec_count)
 			tprint_iov_upto(tcp, sg_io.iovec_count,
-					(unsigned long) sg_io.dxferp, 1,
+					(unsigned long) sg_io.dxferp,
+					IOV_DECODE_STR,
 					sg_io.dxfer_len);
 		else
 			print_sg_io_buffer(tcp, (unsigned long) sg_io.dxferp,
@@ -112,7 +113,8 @@
 		tprintf(", data[%u]=", din_len);
 		if (sg_io.iovec_count)
 			tprint_iov_upto(tcp, sg_io.iovec_count,
-					(unsigned long) sg_io.dxferp, 1,
+					(unsigned long) sg_io.dxferp,
+					IOV_DECODE_STR,
 					din_len);
 		else
 			print_sg_io_buffer(tcp, (unsigned long) sg_io.dxferp,
@@ -163,7 +165,7 @@
 	tprintf(", dout[%u]=", sg_io.dout_xfer_len);
 	if (sg_io.dout_iovec_count)
 		tprint_iov_upto(tcp, sg_io.dout_iovec_count, sg_io.dout_xferp,
-				1, sg_io.dout_xfer_len);
+				IOV_DECODE_STR, sg_io.dout_xfer_len);
 	else
 		print_sg_io_buffer(tcp, sg_io.dout_xferp, sg_io.dout_xfer_len);
 	return 1;
@@ -188,7 +190,7 @@
 	tprintf(", din[%u]=", din_len);
 	if (sg_io.din_iovec_count)
 		tprint_iov_upto(tcp, sg_io.din_iovec_count, sg_io.din_xferp,
-				1, din_len);
+				IOV_DECODE_STR, din_len);
 	else
 		print_sg_io_buffer(tcp, sg_io.din_xferp, din_len);
 	tprintf(", driver_status=%u", sg_io.driver_status);