]> granicus.if.org Git - strace/commitdiff
Use MIN where appropriate
authorEugene Syromyatnikov <evgsyr@gmail.com>
Mon, 7 May 2018 06:15:19 +0000 (08:15 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 9 May 2018 22:01:45 +0000 (22:01 +0000)
* netlink.c (decode_nlmsghdr_with_payload): Use MIN.
* netlink_packet_diag.c (print_packet_diag_mclist): Likewise.
* nlattr.c (decode_nlattr_with_data): Likewise.
* rtnl_route.c (decode_rta_multipath): Likewise.

netlink.c
netlink_packet_diag.c
nlattr.c
rtnl_route.c

index 4fbb4fbc6c2d6da208f556889c0d8d00be04428e..bcf4bc11a6588bd6d528ab3529f9663dd988cd46 100644 (file)
--- a/netlink.c
+++ b/netlink.c
@@ -607,8 +607,7 @@ decode_nlmsghdr_with_payload(struct tcb *const tcp,
                             const kernel_ulong_t addr,
                             const kernel_ulong_t len)
 {
-       const unsigned int nlmsg_len =
-               nlmsghdr->nlmsg_len > len ? len : nlmsghdr->nlmsg_len;
+       const unsigned int nlmsg_len = MIN(nlmsghdr->nlmsg_len, len);
 
        if (nlmsg_len > NLMSG_HDRLEN)
                tprints("{");
index db688a9f917150f099c962fb7f22a50aaf42ec04..877ebc43e4735e1e6693c36ed01e092297a0fdb5 100644 (file)
@@ -96,8 +96,7 @@ print_packet_diag_mclist(struct tcb *const tcp, void *const elem_buf,
                         const size_t elem_size, void *const opaque_data)
 {
        struct packet_diag_mclist *dml = elem_buf;
-       uint16_t alen = dml->pdmc_alen > sizeof(dml->pdmc_addr) ?
-               sizeof(dml->pdmc_addr) : dml->pdmc_alen;
+       uint16_t alen = MIN(dml->pdmc_alen, sizeof(dml->pdmc_addr));
 
        PRINT_FIELD_IFINDEX("{", *dml, pdmc_index);
        PRINT_FIELD_U(", ", *dml, pdmc_count);
index 8eede64b6ba8e19f840e358496f4f51c35b68c01..d05f7b44867c64348fcfbf79d7e42a5cbf258867 100644 (file)
--- a/nlattr.c
+++ b/nlattr.c
@@ -83,7 +83,7 @@ decode_nlattr_with_data(struct tcb *const tcp,
                        const unsigned int size,
                        const void *const opaque_data)
 {
-       const unsigned int nla_len = nla->nla_len > len ? len : nla->nla_len;
+       const unsigned int nla_len = MIN(nla->nla_len, len);
 
        if (nla_len > NLA_HDRLEN)
                tprints("{");
index 93205c9b1bb50e5c271cba80e8cbb0d63536a6fd..1cc93392a2608c5602596bc7cc26ec18043fe7e3 100644 (file)
@@ -255,8 +255,7 @@ decode_rta_multipath(struct tcb *const tcp,
                PRINT_FIELD_IFINDEX(", ", nh, rtnh_ifindex);
                tprints("}");
 
-               const unsigned short rtnh_len =
-                       len < nh.rtnh_len ? len : nh.rtnh_len;
+               const unsigned short rtnh_len = MIN(len, nh.rtnh_len);
                const size_t offset = RTNH_ALIGN(sizeof(nh));
                if (rtnh_len > offset) {
                        tprints(", ");