* Copyright (c) 2012-2013 Denys Vlasenko <vda.linux@googlemail.com>
* Copyright (c) 2014 Masatake YAMATO <yamato@redhat.com>
* Copyright (c) 2010-2016 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2016-2018 The strace developers.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#include "defs.h"
#include "msghdr.h"
+#include "xstring.h"
#include <limits.h>
-static int
-fetch_struct_mmsghdr_or_printaddr(struct tcb *tcp, const long addr,
+static bool
+fetch_struct_mmsghdr_for_print(struct tcb *const tcp,
+ const kernel_ulong_t addr,
const unsigned int len, void *const mh)
{
- if ((entering(tcp) || !syserror(tcp))
- && fetch_struct_mmsghdr(tcp, addr, mh)) {
- return 0;
- } else {
- printaddr(addr);
- return -1;
- }
+ return (entering(tcp) || !syserror(tcp)) &&
+ fetch_struct_mmsghdr(tcp, addr, mh);
}
struct print_struct_mmsghdr_config {
tprints("{msg_hdr=");
print_struct_msghdr(tcp, &mmsg->msg_hdr, c->p_user_msg_namelen,
- c->use_msg_len ? mmsg->msg_len : -1UL);
+ c->use_msg_len ? mmsg->msg_len : (kernel_ulong_t) -1);
if (c->msg_len_vlen) {
tprintf(", msg_len=%u", mmsg->msg_len);
--c->msg_len_vlen;
};
static void
-save_mmsgvec_namelen(struct tcb *tcp, unsigned long addr,
+save_mmsgvec_namelen(struct tcb *const tcp, kernel_ulong_t addr,
unsigned int len, const char *const timeout)
{
if (len > IOV_MAX)
}
static void
-decode_mmsgvec(struct tcb *tcp, const unsigned long addr,
+decode_mmsgvec(struct tcb *const tcp, const kernel_ulong_t addr,
const unsigned int vlen, const unsigned int msg_len_vlen,
const bool use_msg_len)
{
}
print_array(tcp, addr, vlen, &mmsg, sizeof_struct_mmsghdr(),
- fetch_struct_mmsghdr_or_printaddr,
+ fetch_struct_mmsghdr_for_print,
print_struct_mmsghdr, &c);
}
void
-dumpiov_in_mmsghdr(struct tcb *tcp, long addr)
+dumpiov_in_mmsghdr(struct tcb *const tcp, kernel_ulong_t addr)
{
unsigned int len = tcp->u_rval;
unsigned int i, fetched;
fetched = fetch_struct_mmsghdr(tcp, addr, &mmsg);
if (!fetched)
break;
- tprintf(" = %lu buffers in vector %u\n",
- (unsigned long) mmsg.msg_hdr.msg_iovlen, i);
+ tprintf(" = %" PRI_klu " buffers in vector %u\n",
+ (kernel_ulong_t) mmsg.msg_hdr.msg_iovlen, i);
dumpiov_upto(tcp, mmsg.msg_hdr.msg_iovlen,
- (long) mmsg.msg_hdr.msg_iov, mmsg.msg_len);
+ ptr_to_kulong(mmsg.msg_hdr.msg_iov),
+ mmsg.msg_len);
}
}
return 0;
/* timeout on exit */
static char str[sizeof("left") + TIMESPEC_TEXT_BUFSIZE];
- snprintf(str, sizeof(str), "left %s",
- sprint_timespec(tcp, tcp->u_arg[4]));
+ xsprintf(str, "left %s", sprint_timespec(tcp, tcp->u_arg[4]));
tcp->auxstr = str;
return RVAL_STR;
}