Use MIN where appropriate

* 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.
This commit is contained in:
Eugene Syromyatnikov 2018-05-07 08:15:19 +02:00 committed by Dmitry V. Levin
parent 3f59353ab3
commit afc49df0b0
4 changed files with 4 additions and 7 deletions

View File

@ -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("{");

View 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);

View File

@ -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("{");

View 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(", ");