]> granicus.if.org Git - strace/commitdiff
Use xzalloc(sz) instead of xcalloc(1, sz)
authorEugene Syromyatnikov <evgsyr@gmail.com>
Fri, 22 Feb 2019 17:41:31 +0000 (18:41 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 22 May 2019 11:05:13 +0000 (11:05 +0000)
* bpf.c (BEGIN_BPF_CMD_DECODER(BPF_OBJ_GET_INFO_BY_FD)): Use xzalloc
instead of xcalloc of one-item-sized array.
* kvm.c (vcpu_alloc): Likewise.
* perf.c (fetch_perf_event_attr): Likewise.
* syscall.c (ptrace_get_scno): Likewise.

bpf.c
kvm.c
perf.c
syscall.c

diff --git a/bpf.c b/bpf.c
index 1eeb0e440a7f417df81444f4e1e85e2a595eea55..420b44026eb832e83465e3e0f980302e2c01250d 100644 (file)
--- a/bpf.c
+++ b/bpf.c
@@ -780,7 +780,7 @@ BEGIN_BPF_CMD_DECODER(BPF_OBJ_GET_INFO_BY_FD)
        struct obj_get_info_saved *saved;
 
        if (entering(tcp)) {
-               saved = xcalloc(1, sizeof(*saved));
+               saved = xzalloc(sizeof(*saved));
                saved->info_len = attr.info_len;
                set_tcb_priv_data(tcp, saved, free);
 
diff --git a/kvm.c b/kvm.c
index 5271322f9798d4ca1a52a25ffc6df7f5a05580c8..984a75e86b3f9bd908e7b74060eb7dedb61d2ed6 100644 (file)
--- a/kvm.c
+++ b/kvm.c
@@ -44,7 +44,7 @@ vcpu_find(struct tcb *const tcp, int fd)
 static struct vcpu_info *
 vcpu_alloc(struct tcb *const tcp, int fd, int cpuid)
 {
-       struct vcpu_info *vcpu_info = xcalloc(1, sizeof(*vcpu_info));
+       struct vcpu_info *vcpu_info = xzalloc(sizeof(*vcpu_info));
 
        vcpu_info->fd = fd;
        vcpu_info->cpuid = cpuid;
diff --git a/perf.c b/perf.c
index d3a98166002fbaaa3c5492099e32af3d60db319f..f989dfcc83ef6a716abedaf0c0c210168418b2bd 100644 (file)
--- a/perf.c
+++ b/perf.c
@@ -74,7 +74,7 @@ fetch_perf_event_attr(struct tcb *const tcp, const kernel_ulong_t addr)
        /* Size should be multiple of 8, but kernel doesn't check for it */
        /* size &= ~7; */
 
-       attr = xcalloc(1, sizeof(*attr));
+       attr = xzalloc(sizeof(*attr));
 
        if (umoven_or_printaddr(tcp, addr, size, attr)) {
                free(attr);
index cec662ab0300de2ca80ed124789a6090ee883eaa..bae7343c3b590ca07cd4b6070ae26c89465e6781 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -1304,7 +1304,7 @@ get_scno(struct tcb *tcp)
                tcp->s_ent = &sysent[tcp->scno];
                tcp->qual_flg = qual_flags(tcp->scno);
        } else {
-               struct sysent_buf *s = xcalloc(1, sizeof(*s));
+               struct sysent_buf *s = xzalloc(sizeof(*s));
 
                s->tcp = tcp;
                s->ent = stub_sysent;