summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Ovsienko <denis@ovsienko.info>2020-08-24 21:53:58 +0100
committerDenis Ovsienko <denis@ovsienko.info>2020-08-24 21:53:58 +0100
commit5c2027db88176ff4073d552a887429a3c9d3acee (patch)
tree28c3d2d57d760fb007924de11d96161b82272931
parentd5bb7824e1092793a2961f0ed6f984f193ac6cbb (diff)
downloadtcpdump-5c2027db88176ff4073d552a887429a3c9d3acee.tar.gz
Rename min() and max() to ND_MIN() and ND_MAX(). [skip ci]
As discussed on tcpdump-workers, it was a place for a potential clash with non-macros.
-rw-r--r--netdissect.h8
-rw-r--r--print-decnet.c6
-rw-r--r--print-mptcp.c2
-rw-r--r--print-olsr.c2
-rw-r--r--print-rx.c4
-rw-r--r--print-smb.c34
-rw-r--r--print-zeromq.c12
-rw-r--r--smbutil.c2
8 files changed, 33 insertions, 37 deletions
diff --git a/netdissect.h b/netdissect.h
index 546d38b0..b774ae63 100644
--- a/netdissect.h
+++ b/netdissect.h
@@ -288,12 +288,8 @@ extern void nd_pop_all_packet_info(netdissect_options *);
#define PT_SOMEIP 19 /* Autosar SOME/IP Protocol */
#define PT_DOMAIN 20 /* Domain Name System (DNS) */
-#ifndef min
-#define min(a,b) ((a)>(b)?(b):(a))
-#endif
-#ifndef max
-#define max(a,b) ((b)>(a)?(b):(a))
-#endif
+#define ND_MIN(a,b) ((a)>(b)?(b):(a))
+#define ND_MAX(a,b) ((b)>(a)?(b):(a))
/* For source or destination ports tests (UDP, TCP, ...) */
#define IS_SRC_OR_DST_PORT(p) (sport == (p) || dport == (p))
diff --git a/print-decnet.c b/print-decnet.c
index 047916d3..3266c931 100644
--- a/print-decnet.c
+++ b/print-decnet.c
@@ -530,7 +530,7 @@ decnet_print(netdissect_options *ndo,
if (mflags & RMF_FVER) {
ND_PRINT("future-version-decnet");
- ND_DEFAULTPRINT(ap, min(length, caplen));
+ ND_DEFAULTPRINT(ap, ND_MIN(length, caplen));
return;
}
@@ -566,7 +566,7 @@ decnet_print(netdissect_options *ndo,
break;
default:
ND_PRINT("unknown message flags under mask");
- ND_DEFAULTPRINT((const u_char *)ap, min(length, caplen));
+ ND_DEFAULTPRINT((const u_char *)ap, ND_MIN(length, caplen));
return;
}
@@ -711,7 +711,7 @@ print_decnet_ctlmsg(netdissect_options *ndo,
default:
ND_PRINT("unknown control message");
- ND_DEFAULTPRINT((const u_char *)rhp, min(length, caplen));
+ ND_DEFAULTPRINT((const u_char *)rhp, ND_MIN(length, caplen));
ret = 1;
break;
}
diff --git a/print-mptcp.c b/print-mptcp.c
index c2d61e15..cf01d9c9 100644
--- a/print-mptcp.c
+++ b/print-mptcp.c
@@ -464,7 +464,7 @@ mptcp_print(netdissect_options *ndo,
opt = (const struct mptcp_option *) cp;
ND_TCHECK_SIZE(opt);
- subtype = min(MPTCP_OPT_SUBTYPE(opt->sub_etc), MPTCP_SUB_FCLOSE + 1);
+ subtype = ND_MIN(MPTCP_OPT_SUBTYPE(opt->sub_etc), MPTCP_SUB_FCLOSE + 1);
ND_PRINT(" %s", mptcp_options[subtype].name);
return mptcp_options[subtype].print(ndo, cp, len, flags);
diff --git a/print-olsr.c b/print-olsr.c
index e640ee18..d6e40927 100644
--- a/print-olsr.c
+++ b/print-olsr.c
@@ -340,7 +340,7 @@ olsr_print(netdissect_options *ndo,
ND_TCHECK_LEN(tptr, sizeof(struct olsr_common));
ptr.common = (const struct olsr_common *)tptr;
- length = min(length, GET_BE_U_2(ptr.common->packet_len));
+ length = ND_MIN(length, GET_BE_U_2(ptr.common->packet_len));
ND_PRINT("OLSRv%i, seq 0x%04x, length %u",
(is_ipv6 == 0) ? 4 : 6,
diff --git a/print-rx.c b/print-rx.c
index 6c4ce858..a503d3d4 100644
--- a/print-rx.c
+++ b/print-rx.c
@@ -959,7 +959,7 @@ fs_print(netdissect_options *ndo,
i = GET_BE_U_4(bp);
bp += sizeof(uint32_t);
ND_TCHECK_LEN(bp, i);
- i = min(AFSOPAQUEMAX, i);
+ i = ND_MIN(AFSOPAQUEMAX, i);
strncpy(a, (const char *) bp, i);
a[i] = '\0';
acl_print(ndo, (u_char *) a, (u_char *) a + i);
@@ -1095,7 +1095,7 @@ fs_reply_print(netdissect_options *ndo,
i = GET_BE_U_4(bp);
bp += sizeof(uint32_t);
ND_TCHECK_LEN(bp, i);
- i = min(AFSOPAQUEMAX, i);
+ i = ND_MIN(AFSOPAQUEMAX, i);
strncpy(a, (const char *) bp, i);
a[i] = '\0';
acl_print(ndo, (u_char *) a, (u_char *) a + i);
diff --git a/print-smb.c b/print-smb.c
index 77d9f814..1e53eed0 100644
--- a/print-smb.c
+++ b/print-smb.c
@@ -365,7 +365,7 @@ print_trans(netdissect_options *ndo,
}
smb_fdata(ndo, words + 1, f1,
- min(words + 1 + 2 * GET_U_1(words), maxbuf),
+ ND_MIN(words + 1 + 2 * GET_U_1(words), maxbuf),
unicodestr);
ND_TCHECK_2(data1);
@@ -391,9 +391,9 @@ print_trans(netdissect_options *ndo,
#undef PIPE_LANMAN_STR
if (paramlen)
- smb_fdata(ndo, param, f3, min(param + paramlen, maxbuf), unicodestr);
+ smb_fdata(ndo, param, f3, ND_MIN(param + paramlen, maxbuf), unicodestr);
if (datalen)
- smb_fdata(ndo, data, f4, min(data + datalen, maxbuf), unicodestr);
+ smb_fdata(ndo, data, f4, ND_MIN(data + datalen, maxbuf), unicodestr);
}
return;
trunc:
@@ -422,21 +422,21 @@ print_negprot(netdissect_options *ndo,
}
if (f1)
- smb_fdata(ndo, words + 1, f1, min(words + 1 + wct * 2, maxbuf),
+ smb_fdata(ndo, words + 1, f1, ND_MIN(words + 1 + wct * 2, maxbuf),
unicodestr);
else
- smb_data_print(ndo, words + 1, min(wct * 2, ND_BYTES_BETWEEN(maxbuf, words + 1)));
+ smb_data_print(ndo, words + 1, ND_MIN(wct * 2, ND_BYTES_BETWEEN(maxbuf, words + 1)));
ND_TCHECK_2(data);
bcc = GET_LE_U_2(data);
ND_PRINT("smb_bcc=%u\n", bcc);
if (bcc > 0) {
if (f2)
- smb_fdata(ndo, data + 2, f2, min(data + 2 + GET_LE_U_2(data),
+ smb_fdata(ndo, data + 2, f2, ND_MIN(data + 2 + GET_LE_U_2(data),
maxbuf), unicodestr);
else
smb_data_print(ndo, data + 2,
- min(GET_LE_U_2(data), ND_BYTES_BETWEEN(maxbuf, data + 2)));
+ ND_MIN(GET_LE_U_2(data), ND_BYTES_BETWEEN(maxbuf, data + 2)));
}
return;
trunc:
@@ -467,21 +467,21 @@ print_sesssetup(netdissect_options *ndo,
}
if (f1)
- smb_fdata(ndo, words + 1, f1, min(words + 1 + wct * 2, maxbuf),
+ smb_fdata(ndo, words + 1, f1, ND_MIN(words + 1 + wct * 2, maxbuf),
unicodestr);
else
- smb_data_print(ndo, words + 1, min(wct * 2, ND_BYTES_BETWEEN(maxbuf, words + 1)));
+ smb_data_print(ndo, words + 1, ND_MIN(wct * 2, ND_BYTES_BETWEEN(maxbuf, words + 1)));
ND_TCHECK_2(data);
bcc = GET_LE_U_2(data);
ND_PRINT("smb_bcc=%u\n", bcc);
if (bcc > 0) {
if (f2)
- smb_fdata(ndo, data + 2, f2, min(data + 2 + GET_LE_U_2(data),
+ smb_fdata(ndo, data + 2, f2, ND_MIN(data + 2 + GET_LE_U_2(data),
maxbuf), unicodestr);
else
smb_data_print(ndo, data + 2,
- min(GET_LE_U_2(data), ND_BYTES_BETWEEN(maxbuf, data + 2)));
+ ND_MIN(GET_LE_U_2(data), ND_BYTES_BETWEEN(maxbuf, data + 2)));
}
return;
trunc:
@@ -509,7 +509,7 @@ print_lockingandx(netdissect_options *ndo,
f1 = "Com2=[w]\nOff2=[u]\n";
}
- maxwords = min(words + 1 + wct * 2, maxbuf);
+ maxwords = ND_MIN(words + 1 + wct * 2, maxbuf);
if (wct)
smb_fdata(ndo, words + 1, f1, maxwords, unicodestr);
@@ -518,11 +518,11 @@ print_lockingandx(netdissect_options *ndo,
ND_PRINT("smb_bcc=%u\n", bcc);
if (bcc > 0) {
if (f2)
- smb_fdata(ndo, data + 2, f2, min(data + 2 + GET_LE_U_2(data),
+ smb_fdata(ndo, data + 2, f2, ND_MIN(data + 2 + GET_LE_U_2(data),
maxbuf), unicodestr);
else
smb_data_print(ndo, data + 2,
- min(GET_LE_U_2(data), ND_BYTES_BETWEEN(maxbuf, data + 2)));
+ ND_MIN(GET_LE_U_2(data), ND_BYTES_BETWEEN(maxbuf, data + 2)));
}
return;
trunc:
@@ -864,7 +864,7 @@ print_smb(netdissect_options *ndo,
ND_TCHECK_1(words);
wct = GET_U_1(words);
data = words + 1 + wct * 2;
- maxwords = min(data, maxbuf);
+ maxwords = ND_MIN(data, maxbuf);
if (request) {
f1 = fn->descript.req_f1;
@@ -902,7 +902,7 @@ print_smb(netdissect_options *ndo,
} else {
if (bcc > 0) {
ND_PRINT("smb_buf[]=\n");
- smb_data_print(ndo, data + 2, min(bcc, ND_BYTES_BETWEEN(maxbuf, data + 2)));
+ smb_data_print(ndo, data + 2, ND_MIN(bcc, ND_BYTES_BETWEEN(maxbuf, data + 2)));
}
}
}
@@ -1237,7 +1237,7 @@ nbt_udp137_print(netdissect_options *ndo,
} else {
if (p >= maxbuf)
goto out;
- smb_data_print(ndo, p, min(rdlen, length - ND_BYTES_BETWEEN(p, data)));
+ smb_data_print(ndo, p, ND_MIN(rdlen, length - ND_BYTES_BETWEEN(p, data)));
p += rdlen;
}
}
diff --git a/print-zeromq.c b/print-zeromq.c
index 31d69968..cfab5878 100644
--- a/print-zeromq.c
+++ b/print-zeromq.c
@@ -103,7 +103,7 @@ zmtp1_print_frame(netdissect_options *ndo, const u_char *cp, const u_char *ep)
ND_PRINT(", flags 0x%02x", flags);
if (ndo->ndo_vflag) {
- uint64_t body_len_printed = min(body_len_captured, body_len_declared);
+ uint64_t body_len_printed = ND_MIN(body_len_captured, body_len_declared);
ND_PRINT(" (%s|%s|%s|%s|%s|%s|%s|%s)",
flags & 0x80 ? "MBZ" : "-",
@@ -116,7 +116,7 @@ zmtp1_print_frame(netdissect_options *ndo, const u_char *cp, const u_char *ep)
flags & 0x01 ? "MORE" : "-");
if (ndo->ndo_vflag == 1)
- body_len_printed = min(VBYTES + 1, body_len_printed);
+ body_len_printed = ND_MIN(VBYTES + 1, body_len_printed);
if (body_len_printed > 1) {
ND_PRINT(", first %" PRIu64 " byte(s) of body:", body_len_printed - 1);
hex_and_ascii_print(ndo, "\n\t ", cp + header_len + 1, body_len_printed - 1);
@@ -141,7 +141,7 @@ trunc:
void
zmtp1_print(netdissect_options *ndo, const u_char *cp, u_int len)
{
- const u_char *ep = min(ndo->ndo_snapend, cp + len);
+ const u_char *ep = ND_MIN(ndo->ndo_snapend, cp + len);
ndo->ndo_protocol = "zmtp1";
ND_PRINT(": ZMTP/1.0");
@@ -190,10 +190,10 @@ zmtp1_print_intermediate_part(netdissect_options *ndo, const u_char *cp, const u
if (frame_offset > remaining_len)
ND_PRINT(" (%u captured)", remaining_len);
if (ndo->ndo_vflag) {
- u_int len_printed = min(frame_offset, remaining_len);
+ u_int len_printed = ND_MIN(frame_offset, remaining_len);
if (ndo->ndo_vflag == 1)
- len_printed = min(VBYTES, len_printed);
+ len_printed = ND_MIN(VBYTES, len_printed);
if (len_printed > 1) {
ND_PRINT(", first %u byte(s):", len_printed);
hex_and_ascii_print(ndo, "\n\t ", cp, len_printed);
@@ -210,7 +210,7 @@ trunc:
void
zmtp1_datagram_print(netdissect_options *ndo, const u_char *cp, const u_int len)
{
- const u_char *ep = min(ndo->ndo_snapend, cp + len);
+ const u_char *ep = ND_MIN(ndo->ndo_snapend, cp + len);
ndo->ndo_protocol = "zmtp1";
cp = zmtp1_print_intermediate_part(ndo, cp, len);
diff --git a/smbutil.c b/smbutil.c
index a8203bf6..23c59ab2 100644
--- a/smbutil.c
+++ b/smbutil.c
@@ -320,7 +320,7 @@ smb_data_print(netdissect_options *ndo, const u_char *buf, u_int len)
while (n--)
ND_PRINT(" ");
- n = min(8, i % 16);
+ n = ND_MIN(8, i % 16);
print_asc(ndo, buf + i - (i % 16), n);
ND_PRINT(" ");
n = (i % 16) - n;