From: Guy Harris Date: Thu, 18 Apr 2019 02:53:00 +0000 (-0700) Subject: Clean up types to squelch narrowing warnings. X-Git-Tag: tcpdump-4.99-bp~830 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/bef667db65b15c89ec6f1cf325b76acd3c0b8748 Clean up types to squelch narrowing warnings. --- diff --git a/netdissect.h b/netdissect.h index c5b4ea04..822dd9c7 100644 --- a/netdissect.h +++ b/netdissect.h @@ -713,12 +713,12 @@ extern uint16_t in_cksum(const struct cksum_vec *, int); extern uint16_t in_cksum_shouldbe(uint16_t, uint16_t); /* IP protocol demuxing routines */ -extern void ip_print_demux(netdissect_options *, const u_char *, u_int, u_int, int, u_int, u_int, const u_char *); +extern void ip_print_demux(netdissect_options *, const u_char *, u_int, u_int, int, u_int, uint8_t, const u_char *); -extern uint16_t nextproto4_cksum(netdissect_options *, const struct ip *, const uint8_t *, u_int, u_int, u_int); +extern uint16_t nextproto4_cksum(netdissect_options *, const struct ip *, const uint8_t *, u_int, u_int, uint8_t); /* in print-ip6.c */ -extern uint16_t nextproto6_cksum(netdissect_options *, const struct ip6_hdr *, const uint8_t *, u_int, u_int, u_int); +extern uint16_t nextproto6_cksum(netdissect_options *, const struct ip6_hdr *, const uint8_t *, u_int, u_int, uint8_t); /* Utilities */ extern void nd_print_trunc(netdissect_options *); diff --git a/print-babel.c b/print-babel.c index 29865dd2..00dcd14c 100644 --- a/print-babel.c +++ b/print-babel.c @@ -364,7 +364,7 @@ babel_print_v2(netdissect_options *ndo, i = 0; while(i < bodylen) { const u_char *message; - u_int type, len; + uint8_t type, len; message = cp + 4 + i; diff --git a/print-bgp.c b/print-bgp.c index 7b398581..a58041b7 100644 --- a/print-bgp.c +++ b/print-bgp.c @@ -1540,7 +1540,7 @@ check_add_path(netdissect_options *ndo, const u_char *pptr, u_int length, static int bgp_attr_print(netdissect_options *ndo, - u_int atype, const u_char *pptr, u_int len) + uint8_t atype, const u_char *pptr, u_int len) { u_int i; uint16_t af; @@ -2776,7 +2776,8 @@ bgp_update_print(netdissect_options *ndo, if (len) { /* do something more useful!*/ while (len) { - u_int aflags, atype, alenlen, alen; + uint8_t aflags, atype, alenlen; + uint16_t alen; ND_TCHECK_2(p); if (length < 2) diff --git a/print-decnet.c b/print-decnet.c index fcb85225..2a19fd1c 100644 --- a/print-decnet.c +++ b/print-decnet.c @@ -502,7 +502,8 @@ decnet_print(netdissect_options *ndo, { const union routehdr *rhp; u_int mflags; - u_int dst, src, hops; + uint16_t dst, src; + u_int hops; u_int nsplen, pktlen; const u_char *nspp; diff --git a/print-forces.c b/print-forces.c index 65d6e77f..e05b5f7a 100644 --- a/print-forces.c +++ b/print-forces.c @@ -1641,7 +1641,7 @@ forces_type_print(netdissect_options *ndo, /*XXX: 15 top level tlvs will probably be fine You are nuts if you send more ;-> */ while (rlen != 0) { - u_int type, tlvl; + uint16_t type, tlvl; ND_TCHECK_SIZE(tltlv); type = GET_BE_U_2(tltlv->type); diff --git a/print-icmp.c b/print-icmp.c index 2b8c1ff7..0f0e7a10 100644 --- a/print-icmp.c +++ b/print-icmp.c @@ -343,7 +343,8 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char * uint32_t raw_label; const u_char *snapend_save; const struct icmp_mpls_ext_object_header_t *icmp_mpls_ext_object_header; - u_int hlen, dport, mtu, obj_tlen, obj_class_num, obj_ctype; + u_int hlen, mtu, obj_tlen, obj_class_num, obj_ctype; + uint16_t dport; char buf[MAXHOSTNAMELEN + 100]; struct cksum_vec vec[1]; diff --git a/print-icmp6.c b/print-icmp6.c index c5ce7ea5..9b6468f1 100644 --- a/print-icmp6.c +++ b/print-icmp6.c @@ -1031,7 +1031,7 @@ icmp6_print(netdissect_options *ndo, const struct ip6_hdr *ip; const struct ip6_hdr *oip; const struct udphdr *ouh; - u_int dport; + uint16_t dport; const u_char *ep; u_int prot; diff --git a/print-ip-demux.c b/print-ip-demux.c index 2dae30d2..4cab6acc 100644 --- a/print-ip-demux.c +++ b/print-ip-demux.c @@ -39,8 +39,8 @@ void ip_print_demux(netdissect_options *ndo, const u_char *bp, - u_int length, u_int ver, int fragmented, u_int ttl_hl, u_int nh, - const u_char *iph) + u_int length, u_int ver, int fragmented, u_int ttl_hl, + uint8_t nh, const u_char *iph) { int advance; const char *p_name; diff --git a/print-ip.c b/print-ip.c index a701fede..ddc917d5 100644 --- a/print-ip.c +++ b/print-ip.c @@ -141,13 +141,13 @@ trunc: uint16_t nextproto4_cksum(netdissect_options *ndo, const struct ip *ip, const uint8_t *data, - u_int len, u_int covlen, u_int next_proto) + u_int len, u_int covlen, uint8_t next_proto) { struct phdr { uint32_t src; uint32_t dst; - u_char mbz; - u_char proto; + uint8_t mbz; + uint8_t proto; uint16_t len; } ph; struct cksum_vec vec[2]; diff --git a/print-ip6.c b/print-ip6.c index 9f8b4dbf..f8d23490 100644 --- a/print-ip6.c +++ b/print-ip6.c @@ -174,7 +174,7 @@ trunc: uint16_t nextproto6_cksum(netdissect_options *ndo, const struct ip6_hdr *ip6, const uint8_t *data, - u_int len, u_int covlen, u_int next_proto) + u_int len, u_int covlen, uint8_t next_proto) { struct { struct in6_addr ph_src; diff --git a/print-isoclns.c b/print-isoclns.c index fe2f2255..5ccd0b34 100644 --- a/print-isoclns.c +++ b/print-isoclns.c @@ -2108,7 +2108,7 @@ trunc: * it is called from various MT-TLVs (222,229,235,237) */ -static u_int +static uint8_t isis_print_mtid(netdissect_options *ndo, const uint8_t *tptr, const char *ident) { @@ -2275,7 +2275,8 @@ isis_print(netdissect_options *ndo, uint8_t version, pdu_version, fixed_len; uint8_t pdu_type, pdu_max_area, max_area, pdu_id_length, id_length, tlv_type, tlv_len, tlen, alen, lan_alen, prefix_len; - u_int ext_is_len, ext_ip_len, mt_len; + u_int ext_is_len, ext_ip_len; + uint8_t mt_len; uint8_t isis_subtlv_idrp; const uint8_t *optr, *pptr, *tptr; u_int packet_len; diff --git a/print-juniper.c b/print-juniper.c index 009897da..ba6c94a4 100644 --- a/print-juniper.c +++ b/print-juniper.c @@ -425,7 +425,7 @@ struct juniper_l2info_t { uint32_t caplen; uint32_t pictype; uint8_t direction; - uint8_t header_len; + u_int header_len; uint8_t cookie_len; uint8_t cookie_type; uint8_t cookie[8]; diff --git a/print-ldp.c b/print-ldp.c index 87805d24..653ea37c 100644 --- a/print-ldp.c +++ b/print-ldp.c @@ -233,7 +233,7 @@ static int ldp_pdu_print(netdissect_options *, const u_char *); #define TLV_TCHECK(minlen) \ ND_TCHECK_LEN(tptr, minlen); if (tlv_tlen < minlen) goto badtlv; -static int +static u_int ldp_tlv_print(netdissect_options *ndo, const u_char *tptr, u_short msg_tlen) @@ -567,7 +567,8 @@ ldp_pdu_print(netdissect_options *ndo, const struct ldp_msg_header *ldp_msg_header; const u_char *tptr,*msg_tptr; u_short tlen; - u_short pdu_len,msg_len,msg_type,msg_tlen; + u_short pdu_len,msg_len,msg_type; + u_int msg_tlen; int hexdump,processed; ldp_com_header = (const struct ldp_common_header *)pptr; diff --git a/print-lldp.c b/print-lldp.c index 054a9617..a16e0841 100644 --- a/print-lldp.c +++ b/print-lldp.c @@ -1166,7 +1166,8 @@ lldp_private_dcbx_print(netdissect_options *ndo, uint8_t tval; uint16_t tlv; uint32_t i, pgval, uval; - u_int tlen, tlv_type, tlv_len; + u_int tlen, tlv_type; + uint16_t tlv_len; const u_char *tptr, *mptr; if (len < 4) { diff --git a/print-openflow-1.0.c b/print-openflow-1.0.c index 12051992..d7ac8b24 100644 --- a/print-openflow-1.0.c +++ b/print-openflow-1.0.c @@ -1351,7 +1351,7 @@ of10_match_print(netdissect_options *ndo, uint32_t wildcards; uint16_t dl_type; uint8_t nw_proto; - u_char nw_bits; + u_int nw_bits; const char *field_name; /* wildcards */ diff --git a/print-rsvp.c b/print-rsvp.c index 21b422f6..ed937376 100644 --- a/print-rsvp.c +++ b/print-rsvp.c @@ -673,8 +673,8 @@ rsvp_obj_print(netdissect_options *ndo, const struct rsvp_obj_frr_t *rsvp_obj_frr; } obj_ptr; - u_short rsvp_obj_len,rsvp_obj_ctype,rsvp_obj_class_num,obj_tlen; - u_int intserv_serv_tlen; + u_short rsvp_obj_len,rsvp_obj_ctype,rsvp_obj_class_num; + u_int obj_tlen,intserv_serv_tlen; int hexdump; u_int processed,padbytes,error_code,error_value,i,sigcheck; union { diff --git a/print-sctp.c b/print-sctp.c index e0c22076..9384a93d 100644 --- a/print-sctp.c +++ b/print-sctp.c @@ -562,7 +562,7 @@ sctp_print(netdissect_options *ndo, const struct sctpDataPart *dataHdrPtr; uint8_t chunkFlg; uint32_t ppid; - u_int payload_size; + uint16_t payload_size; chunkFlg = GET_U_1(chunkDescPtr->chunkFlg); if ((chunkFlg & SCTP_DATA_UNORDERED) == SCTP_DATA_UNORDERED) diff --git a/print-udp.c b/print-udp.c index 4878b7b4..646d4142 100644 --- a/print-udp.c +++ b/print-udp.c @@ -347,9 +347,9 @@ udpipaddr_print(netdissect_options *ndo, const struct ip *ip, int sport, int dpo } else { ND_PRINT("%s.%s > %s.%s: ", ip6addr_string(ndo, ip6->ip6_src), - udpport_string(ndo, sport), + udpport_string(ndo, (uint16_t)sport), ip6addr_string(ndo, ip6->ip6_dst), - udpport_string(ndo, dport)); + udpport_string(ndo, (uint16_t)dport)); } } else { if (sport != -1) { @@ -367,15 +367,15 @@ udpipaddr_print(netdissect_options *ndo, const struct ip *ip, int sport, int dpo } else { ND_PRINT("%s.%s > %s.%s: ", ipaddr_string(ndo, ip->ip_src), - udpport_string(ndo, sport), + udpport_string(ndo, (uint16_t)sport), ipaddr_string(ndo, ip->ip_dst), - udpport_string(ndo, dport)); + udpport_string(ndo, (uint16_t)dport)); } } else { if (sport != -1) { ND_PRINT("%s > %s: ", - udpport_string(ndo, sport), - udpport_string(ndo, dport)); + udpport_string(ndo, (uint16_t)sport), + udpport_string(ndo, (uint16_t)dport)); } } }