]> granicus.if.org Git - strace/blob - fetch_struct_msghdr.c
Fix preprocessor indentation
[strace] / fetch_struct_msghdr.c
1 /*
2  * Copyright (c) 2016-2018 Dmitry V. Levin <ldv@altlinux.org>
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: LGPL-2.1-or-later
6  */
7
8 #include "defs.h"
9
10 #include DEF_MPERS_TYPE(struct_msghdr)
11
12 #include "msghdr.h"
13 typedef struct msghdr struct_msghdr;
14
15 #include MPERS_DEFS
16
17 /*
18  * On success, return the number of fetched bytes.
19  * On error, return 0;
20  *
21  * This function cannot use umove_or_printaddr because
22  * it is called by dumpio and therefore cannot print anything.
23  */
24
25 MPERS_PRINTER_DECL(int, fetch_struct_msghdr,
26                    struct tcb *const tcp, const kernel_ulong_t addr,
27                    void *const p)
28 {
29         struct msghdr *const p_native = p;
30         struct_msghdr v_compat;
31
32         if (sizeof(*p_native) == sizeof(v_compat))
33                 return umove(tcp, addr, p_native) ? 0 : sizeof(*p_native);
34
35         if (umove(tcp, addr, &v_compat))
36                 return 0;
37
38         p_native->msg_name = (void *) (unsigned long)
39          v_compat.msg_name;
40
41         p_native->msg_namelen =
42          v_compat.msg_namelen;
43
44         p_native->msg_iov = (void *) (unsigned long)
45          v_compat.msg_iov;
46
47         p_native->msg_iovlen =
48          v_compat.msg_iovlen;
49
50         p_native->msg_control = (void *) (unsigned long)
51          v_compat.msg_control;
52
53         p_native->msg_controllen =
54          v_compat.msg_controllen;
55
56         p_native->msg_flags =
57          v_compat.msg_flags;
58
59         return sizeof(v_compat);
60 }