Replace u_int8_t, u_int16_t, u_int32_t, u_int64_t by standard int types
cover Replace u_int8_t, u_int16_t, u_int32_t, u_int64_t by standard int types
There is no need to have a second set of integral types. Replace them by the standard types from stdint.h.
[PATCH 1/4] block: Replace u_int8_t, u_int16_t, u_int32_t, u_int64_t by standard int types [PATCH 2/4] tests: Replace u_int8_t, u_int16_t, u_int32_t, u_int64_t by standard int types [PATCH 3/4] slirp: Replace u_int8_t, u_int16_t, u_int32_t, u_int64_t by standard int types [PATCH 4/4] slirp: Remove declarations which are no longer needed
PATCH 1/4 block: Replace u_int8_t, u_int16_t, u_int32_t, u_int64_t by standard int types
There is no need to have a second set of integral types. Replace them by the standard types from stdint.h.
--- block/raw-posix.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
block/raw-posix.c +1 -1
@@ -216,7 +216,7 @@ static int raw_open(BlockDriverState *bs, const char *filename, int flags) }#endif #ifdef CONFIG_COCOA -u_int32_t blockSize =512 ; +uint32_t blockSize =512 ;if ( !ioctl ( fd,DKIOCGETBLOCKSIZE , &blockSize ) && blockSize > bufsize) { bufsize = blockSize; }
Signature · 1 line
1.7.1
PATCH 2/4 tests: Replace u_int8_t, u_int16_t, u_int32_t, u_int64_t by standard int types
In reply to Stefan WeilThere is no need to have a second set of integral types. Replace them by the standard types from stdint.h.
--- tests/sha1.c | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-)
tests/sha1.c +12 -12
@@ -23,7 +23,7 @@ A million repetitions of "a"#include <stdio.h> #include <string.h> -#include <sys/types.h> /* for u_int*_t */ +#include <stdint.h> /* ================ sha1.h ================ */ /*
@@ -33,14 +33,14 @@ By Steve Reid <[email protected]>*/ typedef struct { -u_int32_t state[5 ]; -u_int32_t count[2 ]; +uint32_t state[5 ]; +uint32_t count[2 ];unsigned char buffer[64 ]; }SHA1_CTX ; -void SHA1Transform (u_int32_t state[5 ],const unsigned char buffer[64 ]); +void SHA1Transform (uint32_t state[5 ],const unsigned char buffer[64 ]);void SHA1Init (SHA1_CTX * context); -void SHA1Update (SHA1_CTX * context,const unsigned char * data,u_int32_t len); +void SHA1Update (SHA1_CTX * context,const unsigned char * data,uint32_t len);void SHA1Final (unsigned char digest[20 ],SHA1_CTX * context);/* ================ end of sha1.h ================ */ #include <endian.h>
@@ -70,12 +70,12 @@ void SHA1Final(unsigned char digest[20], SHA1_CTX* context);/* Hash a single 512-bit block. This is the core of the algorithm. */ -void SHA1Transform (u_int32_t state[5 ],const unsigned char buffer[64 ]) +void SHA1Transform (uint32_t state[5 ],const unsigned char buffer[64 ]) { -u_int32_t a, b, c, d, e; +uint32_t a, b, c, d, e;typedef union {unsigned char c[64 ]; -u_int32_t l[16 ]; +uint32_t l[16 ]; }CHAR64LONG16 ;#ifdef SHA1HANDSOFF CHAR64LONG16 block[1 ];/* use array to appear as a pointer */
@@ -145,10 +145,10 @@ void SHA1Init(SHA1_CTX* context)/* Run your data through this. */ -void SHA1Update (SHA1_CTX * context,const unsigned char * data,u_int32_t len) +void SHA1Update (SHA1_CTX * context,const unsigned char * data,uint32_t len) { -u_int32_t i; -u_int32_t j; +uint32_t i; +uint32_t j; j = context->count[0 ];if ((context->count[0 ] += len <<3 ) < j)
@@ -186,7 +186,7 @@ unsigned char c;for (i =0 ; i <2 ; i++) { -u_int32_t t = context->count[i]; +uint32_t t = context->count[i];int j;for (j =0 ; j <4 ; t >>=8 , j++)
Signature · 1 line
1.7.1
PATCH 3/4 slirp: Replace u_int8_t, u_int16_t, u_int32_t, u_int64_t by standard int types
In reply to Stefan WeilThere is no need to have a second set of integral types. Replace them by the standard types from stdint.h.
--- slirp/cksum.c | 20 ++++++++++---------- slirp/ip.h | 40 ++++++++++++++++++++-------------------- slirp/ip_icmp.h | 2 +- slirp/ip_input.c | 2 +- slirp/ip_output.c | 22 +++++++++++----------- slirp/main.h | 2 +- slirp/misc.h | 20 ++++++++++---------- slirp/slirp.h | 6 +++--- slirp/slirp_config.h | 6 ------ slirp/socket.c | 2 +- slirp/socket.h | 10 +++++----- slirp/tcp.h | 14 +++++++------- slirp/tcp_input.c | 4 ++-- slirp/tcp_output.c | 10 +++++----- slirp/tcp_subr.c | 12 ++++++------ slirp/tcp_var.h | 14 +++++++------- slirp/tftp.c | 8 ++++---- slirp/tftp.h | 14 +++++++------- slirp/udp.c | 8 ++++---- slirp/udp.h | 10 +++++----- 20 files changed, 110 insertions(+), 116 deletions(-)
slirp/cksum.c +10 -10
@@ -47,23 +47,23 @@int cksum (struct mbuf *m,int len) { - registeru_int16_t *w; + registeruint16_t *w; registerint sum =0 ; registerint mlen =0 ;int byte_swapped =0 ;union { -u_int8_t c[2 ]; -u_int16_t s; +uint8_t c[2 ]; +uint16_t s; } s_util;union { -u_int16_t s[2 ]; -u_int32_t l; +uint16_t s[2 ]; +uint32_t l; } l_util;if (m->m_len ==0 ) goto cont; - w = mtod(m, u_int16_t *); + w = mtod(m, uint16_t *); mlen = m->m_len;
@@ -78,8 +78,8 @@ int cksum(struct mbuf *m, int len)if ((1 & (long ) w) && (mlen >0 )) {REDUCE ; sum <<=8 ; - s_util.c[0 ] = *(u_int8_t *)w; - w = (u_int16_t *)((int8_t *)w +1 ); + s_util.c[0 ] = *(uint8_t *)w; + w = (uint16_t *)((int8_t *)w +1 ); mlen--; byte_swapped =1 ; }
@@ -111,14 +111,14 @@ int cksum(struct mbuf *m, int len)REDUCE ; sum <<=8 ;if (mlen ==-1 ) { - s_util.c[1 ] = *(u_int8_t *)w; + s_util.c[1 ] = *(uint8_t *)w; sum += s_util.s; mlen =0 ; }else mlen =-1 ; }else if (mlen ==-1 ) - s_util.c[0 ] = *(u_int8_t *)w; + s_util.c[0 ] = *(uint8_t *)w; cont: #ifdef DEBUG
slirp/ip.h +20 -20
@@ -51,17 +51,17 @@# define NTOHL (d) ((d) = ntohl((d)))# endif # ifndef NTOHS -# define NTOHS (d) ((d) = ntohs((u_int16_t)(d))) +# define NTOHS (d) ((d) = ntohs((uint16_t)(d)))# endif # ifndef HTONL # define HTONL (d) ((d) = htonl((d)))# endif # ifndef HTONS -# define HTONS (d) ((d) = htons((u_int16_t)(d))) +# define HTONS (d) ((d) = htons((uint16_t)(d)))# endif #endif -typedef u_int32_t n_long ;/* long as received from the net */ +typedef uint32_t n_long ;/* long as received from the net */ /* * Definitions for internet protocol version 4.
@@ -80,16 +80,16 @@ struct ip { u_int ip_hl:4, /* header length */ ip_v:4; /* version */#endif -u_int8_t ip_tos;/* type of service */ -u_int16_t ip_len;/* total length */ -u_int16_t ip_id;/* identification */ -u_int16_t ip_off;/* fragment offset field */ +uint8_t ip_tos;/* type of service */ +uint16_t ip_len;/* total length */ +uint16_t ip_id;/* identification */ +uint16_t ip_off;/* fragment offset field */ #define IP_DF 0x4000/* don't fragment flag */ #define IP_MF 0x2000/* more fragments flag */ #define IP_OFFMASK 0x1fff/* mask for fragmenting bits */ -u_int8_t ip_ttl;/* time to live */ -u_int8_t ip_p;/* protocol */ -u_int16_t ip_sum;/* checksum */ +uint8_t ip_ttl;/* time to live */ +uint8_t ip_p;/* protocol */ +uint16_t ip_sum;/* checksum */ struct in_addr ip_src,ip_dst;/* source and dest address */ } __attribute__((packed));
@@ -136,9 +136,9 @@ struct ip {* Time stamp option structure. */ struct ip_timestamp { -u_int8_t ipt_code;/* IPOPT_TS */ -u_int8_t ipt_len;/* size of structure (variable) */ -u_int8_t ipt_ptr;/* index of current entry */ +uint8_t ipt_code;/* IPOPT_TS */ +uint8_t ipt_len;/* size of structure (variable) */ +uint8_t ipt_ptr;/* index of current entry */ #ifdef HOST_WORDS_BIGENDIAN u_int ipt_oflw:4 ,/* overflow counter */ ipt_flg:4 ;/* flags, see below */
@@ -198,9 +198,9 @@ struct qlink {*/ struct ipovly {struct mbuf_ptr ih_mbuf;/* backpointer to mbuf */ -u_int8_t ih_x1;/* (unused) */ -u_int8_t ih_pr;/* protocol */ -u_int16_t ih_len;/* protocol length */ +uint8_t ih_x1;/* (unused) */ +uint8_t ih_pr;/* protocol */ +uint16_t ih_len;/* protocol length */ struct in_addr ih_src;/* source internet address */ struct in_addr ih_dst;/* destination internet address */ } __attribute__((packed));
@@ -215,9 +215,9 @@ struct ipovly {struct ipq {struct qlink frag_link;/* to ip headers of fragments */ struct qlink ip_link;/* to other reass headers */ -u_int8_t ipq_ttl;/* time for reass q to live */ -u_int8_t ipq_p;/* protocol of this fragment */ -u_int16_t ipq_id;/* sequence id for reassembly */ +uint8_t ipq_ttl;/* time for reass q to live */ +uint8_t ipq_p;/* protocol of this fragment */ +uint16_t ipq_id;/* sequence id for reassembly */ struct in_addr ipq_src,ipq_dst; } __attribute__((packed));
@@ -235,7 +235,7 @@ struct ipasfrag {#define ipf_tos ipf_ip.ip_tos#define ipf_len ipf_ip.ip_len#define ipf_next ipf_link.next -#define ipf_prev ipf_link.prev +#define ipf_prev ipf_link.prev/* * Structure stored in mbuf in inpcb.ip_options
slirp/ip_icmp.h +1 -1
@@ -38,7 +38,7 @@* Per RFC 792, September 1981. */ -typedef u_int32_t n_time ; +typedef uint32_t n_time ;/* * Structure of an icmp header.
slirp/ip_input.c +1 -1
@@ -477,7 +477,7 @@ ip_dooptions(m) registerstruct in_ifaddr *ia;int opt, optlen, cnt, off, code, type, forward =0 ;struct in_addr *sin, dst; -typedef u_int32_t n_time ; +typedef uint32_t n_time ;n_time ntime; dst = ip->ip_dst;
slirp/ip_output.c +11 -11
@@ -75,9 +75,9 @@ ip_output(struct socket *so, struct mbuf *m0)/* * If small enough for interface, can just send directly. */ -if ((u_int16_t )ip->ip_len <=IF_MTU ) { - ip->ip_len =htons ((u_int16_t )ip->ip_len); - ip->ip_off =htons ((u_int16_t )ip->ip_off); +if ((uint16_t )ip->ip_len <=IF_MTU ) { + ip->ip_len =htons ((uint16_t )ip->ip_len); + ip->ip_off =htons ((uint16_t )ip->ip_off); ip->ip_sum =0 ; ip->ip_sum =cksum (m, hlen);
@@ -110,7 +110,7 @@ ip_output(struct socket *so, struct mbuf *m0)*/ m0 = m; mhlen =sizeof (struct ip ); -for (off = hlen + len; off < (u_int16_t )ip->ip_len; off += len) { +for (off = hlen + len; off < (uint16_t )ip->ip_len; off += len) { registerstruct ip *mhip; m =m_get (slirp);if (m ==NULL ) {
@@ -125,18 +125,18 @@ ip_output(struct socket *so, struct mbuf *m0) mhip->ip_off = ((off - hlen) >>3 ) + (ip->ip_off & ~IP_MF );if (ip->ip_off &IP_MF ) mhip->ip_off |=IP_MF ; -if (off + len >= (u_int16_t )ip->ip_len) - len = (u_int16_t )ip->ip_len - off; +if (off + len >= (uint16_t )ip->ip_len) + len = (uint16_t )ip->ip_len - off;else mhip->ip_off |=IP_MF ; - mhip->ip_len =htons ((u_int16_t)(len + mhlen)); + mhip->ip_len =htons ((uint16_t )(len + mhlen));if (m_copy (m, m0, off, len) <0 ) { error =-1 ; goto sendorfree; } - mhip->ip_off =htons ((u_int16_t )mhip->ip_off); + mhip->ip_off =htons ((uint16_t )mhip->ip_off); mhip->ip_sum =0 ; mhip->ip_sum =cksum (m, mhlen); *mnext = m;
@@ -147,9 +147,9 @@ ip_output(struct socket *so, struct mbuf *m0)* and updating header, then send each fragment (in order). */ m = m0; -m_adj (m, hlen + firstlen - (u_int16_t )ip->ip_len); - ip->ip_len =htons ((u_int16_t )m->m_len); - ip->ip_off =htons ((u_int16_t)(ip->ip_off |IP_MF )); +m_adj (m, hlen + firstlen - (uint16_t )ip->ip_len); + ip->ip_len =htons ((uint16_t )m->m_len); + ip->ip_off =htons ((uint16_t )(ip->ip_off |IP_MF )); ip->ip_sum =0 ; ip->ip_sum =cksum (m, hlen); sendorfree:
slirp/main.h +1 -1
@@ -14,7 +14,7 @@extern int slirp_socket;extern int slirp_socket_unit;extern int slirp_socket_port; -extern u_int32_t slirp_socket_addr; +extern uint32_t slirp_socket_addr;extern char *slirp_socket_passwd;extern int ctty_closed;
slirp/misc.h +10 -10
@@ -37,24 +37,24 @@ void do_wait(int);#define EMU_NOCONNECT 0x10/* Don't connect */ struct tos_t { -u_int16_t lport; -u_int16_t fport; -u_int8_t tos; -u_int8_t emu; +uint16_t lport; +uint16_t fport; +uint8_t tos; +uint8_t emu; };struct emu_t { -u_int16_t lport; -u_int16_t fport; -u_int8_t tos; -u_int8_t emu; -struct emu_t *next; +uint16_t lport; +uint16_t fport; +uint8_t tos; +uint8_t emu; +struct emu_t *next; };extern int x_port, x_server, x_display;int show_x (char *,struct socket *); -void redir_x (u_int32_t ,int ,int ,int ); +void redir_x (uint32_t ,int ,int ,int );void slirp_insque (void *,void *);void slirp_remque (void *);int add_exec (struct ex_list **,int ,char *,struct in_addr ,int );
slirp/slirp.h +3 -3
@@ -233,7 +233,7 @@ struct Slirp {/* ip states */ struct ipq ipq;/* ip reass. queue */ -u_int16_t ip_id;/* ip packet ctr, for ids */ +uint16_t ip_id;/* ip packet ctr, for ids */ /* bootp/dhcp states */ BOOTPClient bootp_clients[NB_BOOTP_CLIENTS ];
@@ -243,7 +243,7 @@ struct Slirp {struct socket tcb;struct socket *tcp_last_so;tcp_seq tcp_iss;/* tcp initial send seq # */ -u_int32_t tcp_now;/* for RFC 1323 timestamps */ +uint32_t tcp_now;/* for RFC 1323 timestamps */ /* udp states */ struct socket udb;
@@ -339,7 +339,7 @@ void tcp_sockclosed(struct tcpcb *);int tcp_fconnect (struct socket *);void tcp_connect (struct socket *);int tcp_attach (struct socket *); -u_int8_t tcp_tos (struct socket *); +uint8_t tcp_tos (struct socket *);int tcp_emu (struct socket *,struct mbuf *);int tcp_ctl (struct socket *);struct tcpcb *tcp_drop (struct tcpcb *tp,int err);
slirp/slirp_config.h +0 -6
@@ -133,12 +133,6 @@/* Define if your compiler doesn't like prototypes */ #undef NO_PROTOTYPES -/* Define if you don't have u_int32_t etc. typedef'd */ -#undef NEED_TYPEDEFS -#ifdef __sun__ -#define NEED_TYPEDEFS -#endif -/* Define to sizeof(char) */ #define SIZEOF_CHAR 1
slirp/socket.c +1 -1
@@ -580,7 +580,7 @@ sosendto(struct socket *so, struct mbuf *m)* Listen for incoming TCP connections */ struct socket * -tcp_listen (Slirp *slirp,u_int32_t haddr,u_int hport,u_int32_t laddr, +tcp_listen (Slirp *slirp,uint32_t haddr,u_int hport,uint32_t laddr,u_int lport,int flags) {struct sockaddr_in addr;
slirp/socket.h +5 -5
@@ -31,11 +31,11 @@ struct socket {int so_urgc;struct in_addr so_faddr;/* foreign host table entry */ struct in_addr so_laddr;/* local host table entry */ -u_int16_t so_fport;/* foreign port */ -u_int16_t so_lport;/* local port */ +uint16_t so_fport;/* foreign port */ +uint16_t so_lport;/* local port */ -u_int8_t so_iptos;/* Type of service */ -u_int8_t so_emu;/* Is the socket emulated? */ +uint8_t so_iptos;/* Type of service */ +uint8_t so_emu;/* Is the socket emulated? */ u_char so_type;/* Type of socket, UDP or TCP */ int so_state;/* internal state flags SS_*, below */
@@ -83,7 +83,7 @@ int sosendoob(struct socket *);int sowrite (struct socket *);void sorecvfrom (struct socket *);int sosendto (struct socket *,struct mbuf *); -struct socket *tcp_listen (Slirp *,u_int32_t ,u_int ,u_int32_t ,u_int , +struct socket *tcp_listen (Slirp *,uint32_t ,u_int ,uint32_t ,u_int ,int );void soisfconnecting (registerstruct socket *);void soisfconnected (registerstruct socket *);
slirp/tcp.h +7 -7
@@ -33,7 +33,7 @@#ifndef _TCP_H_#define _TCP_H_ -typedef u_int32_t tcp_seq ; +typedef uint32_t tcp_seq ;#define PR_SLOWHZ 2/* 2 slow timeouts per second (approx) */ #define PR_FASTHZ 5/* 5 fast timeouts per second (not important) */
@@ -46,8 +46,8 @@ typedef u_int32_t tcp_seq;* Per RFC 793, September, 1981. */ struct tcphdr { -u_int16_t th_sport;/* source port */ -u_int16_t th_dport;/* destination port */ +uint16_t th_sport;/* source port */ +uint16_t th_dport;/* destination port */ tcp_seq th_seq;/* sequence number */ tcp_seq th_ack;/* acknowledgement number */ #ifdef HOST_WORDS_BIGENDIAN
@@ -57,16 +57,16 @@ struct tcphdr { u_int th_x2:4, /* (unused) */ th_off:4; /* data offset */#endif -u_int8_t th_flags; +uint8_t th_flags;#define TH_FIN 0x01#define TH_SYN 0x02#define TH_RST 0x04#define TH_PUSH 0x08#define TH_ACK 0x10#define TH_URG 0x20 -u_int16_t th_win;/* window */ -u_int16_t th_sum;/* checksum */ -u_int16_t th_urp;/* urgent pointer */ +uint16_t th_win;/* window */ +uint16_t th_sum;/* checksum */ +uint16_t th_urp;/* urgent pointer */ };#include "tcp_var.h"
slirp/tcp_input.c +2 -2
@@ -280,7 +280,7 @@ tcp_input(struct mbuf *m, int iphlen, struct socket *inso)tcpiphdr2qlink (ti)->next =tcpiphdr2qlink (ti)->prev =NULL ;memset (&ti->ti_i.ih_mbuf,0 ,sizeof (struct mbuf_ptr )); ti->ti_x1 =0 ; - ti->ti_len =htons ((u_int16_t )tlen); + ti->ti_len =htons ((uint16_t )tlen); len =sizeof (struct ip ) + tlen;if (cksum (m, len)) { goto drop;
@@ -1289,7 +1289,7 @@ drop:static void tcp_dooptions (struct tcpcb *tp,u_char *cp,int cnt,struct tcpiphdr *ti) { -u_int16_t mss; +uint16_t mss;int opt, optlen;DEBUG_CALL ("tcp_dooptions" );
slirp/tcp_output.c +5 -5
@@ -263,11 +263,11 @@ send:if (flags &TH_SYN ) { tp->snd_nxt = tp->iss;if ((tp->t_flags &TF_NOOPT ) ==0 ) { -u_int16_t mss; +uint16_t mss; opt[0 ] =TCPOPT_MAXSEG ; opt[1 ] =4 ; - mss =htons ((u_int16_t )tcp_mss (tp,0 )); + mss =htons ((uint16_t )tcp_mss (tp,0 ));memcpy ((caddr_t)(opt +2 ), (caddr_t)&mss,sizeof (mss)); optlen =4 ; }
@@ -364,10 +364,10 @@ send: win = (long )TCP_MAXWIN << tp->rcv_scale;if (win < (long )(tp->rcv_adv - tp->rcv_nxt)) win = (long )(tp->rcv_adv - tp->rcv_nxt); - ti->ti_win =htons ((u_int16_t) (win>>tp->rcv_scale)); + ti->ti_win =htons ((uint16_t ) (win>>tp->rcv_scale));if (SEQ_GT (tp->snd_up, tp->snd_una)) { - ti->ti_urp =htons ((u_int16_t)(tp->snd_up -ntohl (ti->ti_seq))); + ti->ti_urp =htons ((uint16_t )(tp->snd_up -ntohl (ti->ti_seq))); ti->ti_flags |=TH_URG ; }else /*
@@ -383,7 +383,7 @@ send:* checksum extended header and data. */ if (len + optlen) - ti->ti_len =htons ((u_int16_t)(sizeof (struct tcphdr ) + + ti->ti_len =htons ((uint16_t )(sizeof (struct tcphdr ) + optlen + len)); ti->ti_sum =cksum (m, (int )(hdrlen + len));
slirp/tcp_subr.c +6 -6
@@ -134,8 +134,8 @@ tcp_respond(struct tcpcb *tp, struct tcpiphdr *ti, struct mbuf *m, m->m_len =sizeof (struct tcpiphdr ); tlen =0 ;#define xchg (a,b,type) { type t; t=a; a=b; b=t; } -xchg (ti->ti_dst.s_addr, ti->ti_src.s_addr, u_int32_t); -xchg (ti->ti_dport, ti->ti_sport, u_int16_t); +xchg (ti->ti_dst.s_addr, ti->ti_src.s_addr, uint32_t); +xchg (ti->ti_dport, ti->ti_sport, uint16_t);#undef xchg } ti->ti_len =htons ((u_short)(sizeof (struct tcphdr ) + tlen));
@@ -150,9 +150,9 @@ tcp_respond(struct tcpcb *tp, struct tcpiphdr *ti, struct mbuf *m, ti->ti_off =sizeof (struct tcphdr ) >>2 ; ti->ti_flags = flags;if (tp) - ti->ti_win =htons ((u_int16_t) (win >> tp->rcv_scale)); + ti->ti_win =htons ((uint16_t ) (win >> tp->rcv_scale));else - ti->ti_win =htons ((u_int16_t )win); + ti->ti_win =htons ((uint16_t )win); ti->ti_urp =0 ; ti->ti_sum =0 ; ti->ti_sum =cksum (m, tlen);
@@ -491,7 +491,7 @@ static struct emu_t *tcpemu = NULL;/* * Return TOS according to the above table */ -u_int8_t +uint8_t tcp_tos (struct socket *so) {int i =0 ;
@@ -548,7 +548,7 @@ tcp_emu(struct socket *so, struct mbuf *m)Slirp *slirp = so->slirp;u_int n1, n2, n3, n4, n5, n6;char buff[257 ]; -u_int32_t laddr; +uint32_t laddr;u_int lport;char *bptr;
slirp/tcp_var.h +7 -7
@@ -75,9 +75,9 @@ struct tcpcb {tcp_seq snd_wl1;/* window update seg seq number */ tcp_seq snd_wl2;/* window update seg ack number */ tcp_seq iss;/* initial send sequence number */ -u_int32_t snd_wnd;/* send window */ +uint32_t snd_wnd;/* send window */ /* receive sequence variables */ -u_int32_t rcv_wnd;/* receive window */ +uint32_t rcv_wnd;/* receive window */ tcp_seq rcv_nxt;/* receive next */ tcp_seq rcv_up;/* receive urgent pointer */ tcp_seq irs;/* initial receive sequence number */
@@ -91,8 +91,8 @@ struct tcpcb {* used to recognize retransmits */ /* congestion control (for slow start, source quench, retransmit after loss) */ -u_int32_t snd_cwnd;/* congestion-controlled window */ -u_int32_t snd_ssthresh;/* snd_cwnd size threshold for +uint32_t snd_cwnd;/* congestion-controlled window */ +uint32_t snd_ssthresh;/* snd_cwnd size threshold for * for slow start exponential to * linear switch */
@@ -106,7 +106,7 @@ struct tcpcb {short t_srtt;/* smoothed round-trip time */ short t_rttvar;/* variance in round-trip time */ u_short t_rttmin;/* minimum rtt allowed */ -u_int32_t max_sndwnd;/* largest window peer has offered */ +uint32_t max_sndwnd;/* largest window peer has offered */ /* out-of-band data */ char t_oobflags;/* have some */
@@ -120,8 +120,8 @@ struct tcpcb {u_char rcv_scale;/* window scaling for recv window */ u_char request_r_scale;/* pending window scaling */ u_char requested_s_scale; -u_int32_t ts_recent;/* timestamp echo data */ -u_int32_t ts_recent_age;/* when last updated */ +uint32_t ts_recent;/* timestamp echo data */ +uint32_t ts_recent_age;/* when last updated */ tcp_seq last_ack_sent; };
slirp/tftp.c +4 -4
@@ -92,8 +92,8 @@ static int tftp_session_find(Slirp *slirp, struct tftp_t *tp)return -1 ; } -static int tftp_read_data (struct tftp_session *spt,u_int16_t block_nr, -u_int8_t *buf,int len) +static int tftp_read_data (struct tftp_session *spt,uint16_t block_nr, +uint8_t *buf,int len) {int fd;int bytes_read =0 ;
@@ -155,7 +155,7 @@ static int tftp_send_oack(struct tftp_session *spt, }static void tftp_send_error (struct tftp_session *spt, -u_int16_t errorcode,const char *msg, +uint16_t errorcode,const char *msg,struct tftp_t *recv_tp) {struct sockaddr_in saddr, daddr;
@@ -194,7 +194,7 @@ out: }static int tftp_send_data (struct tftp_session *spt, -u_int16_t block_nr, +uint16_t block_nr,struct tftp_t *recv_tp) {struct sockaddr_in saddr, daddr;
slirp/tftp.h +7 -7
@@ -16,17 +16,17 @@struct tftp_t {struct ip ip;struct udphdr udp; -u_int16_t tp_op; +uint16_t tp_op;union {struct { -u_int16_t tp_block_nr; -u_int8_t tp_buf[512 ]; +uint16_t tp_block_nr; +uint8_t tp_buf[512 ]; } tp_data;struct { -u_int16_t tp_error_code; -u_int8_t tp_msg[512 ]; +uint16_t tp_error_code; +uint8_t tp_msg[512 ]; } tp_error; -u_int8_t tp_buf[512 +2 ]; +uint8_t tp_buf[512 +2 ]; } x; };
@@ -35,7 +35,7 @@ struct tftp_session {char *filename;struct in_addr client_ip; -u_int16_t client_port; +uint16_t client_port;int timestamp; };
slirp/udp.c +4 -4
@@ -41,7 +41,7 @@#include <slirp.h> #include "ip_icmp.h" -static u_int8_t udp_tos (struct socket *so); +static uint8_t udp_tos (struct socket *so);void udp_init (Slirp *slirp)
@@ -88,7 +88,7 @@ udp_input(register struct mbuf *m, int iphlen)* Make mbuf data length reflect UDP length. * If not enough data to reflect UDP length, drop. */ - len =ntohs ((u_int16_t )uh->uh_ulen); + len =ntohs ((uint16_t )uh->uh_ulen);if (ip->ip_len != len) {if (len > ip->ip_len) {
@@ -321,7 +321,7 @@ static const struct tos_t udptos[] = { {0, 0, 0, 0} }; -static u_int8_t +static uint8_t udp_tos (struct socket *so) {int i =0 ;
@@ -339,7 +339,7 @@ udp_tos(struct socket *so) }struct socket * -udp_listen (Slirp *slirp,u_int32_t haddr,u_int hport,u_int32_t laddr, +udp_listen (Slirp *slirp,uint32_t haddr,u_int hport,uint32_t laddr,u_int lport,int flags) {struct sockaddr_in addr;
slirp/udp.h +5 -5
@@ -41,10 +41,10 @@* Per RFC 768, September, 1981. */ struct udphdr { -u_int16_t uh_sport;/* source port */ -u_int16_t uh_dport;/* destination port */ -int16_t uh_ulen;/* udp length */ -u_int16_t uh_sum;/* udp checksum */ +uint16_t uh_sport;/* source port */ +uint16_t uh_dport;/* destination port */ +int16_t uh_ulen;/* udp length */ +uint16_t uh_sum;/* udp checksum */ };/*
@@ -78,7 +78,7 @@ void udp_input(register struct mbuf *, int);int udp_output (struct socket *,struct mbuf *,struct sockaddr_in *);int udp_attach (struct socket *);void udp_detach (struct socket *); -struct socket *udp_listen (Slirp *,u_int32_t ,u_int ,u_int32_t ,u_int , +struct socket *udp_listen (Slirp *,uint32_t ,u_int ,uint32_t ,u_int ,int ); int udp_output2(struct socket *so, struct mbuf *m, struct sockaddr_in *saddr, struct sockaddr_in *daddr,
Signature · 1 line
1.7.1
PATCH 4/4 slirp: Remove declarations which are no longer needed
In reply to Stefan WeilThe previous patches replaced u_int8_t, u_int16_t, u_int32_t, u_int64_t by standard int types from stdint.h,
so we can now remove their declarations which are no longer needed.
--- slirp/slirp.h | 33 --------------------------------- 1 files changed, 0 insertions(+), 33 deletions(-)
slirp/slirp.h +0 -33
@@ -7,10 +7,6 @@#ifdef _WIN32# include <inttypes.h> -typedef uint8_t u_int8_t ; -typedef uint16_t u_int16_t ; -typedef uint32_t u_int32_t ; -typedef uint64_t u_int64_t ;typedef char *caddr_t ;# include <windows.h>
@@ -38,35 +34,6 @@ typedef char *caddr_t;#include <sys/time.h> -#ifdef NEED_TYPEDEFS -typedef char int8_t ; -typedef unsigned char u_int8_t ; - -# if SIZEOF_SHORT ==2 -typedef short int16_t ; -typedef unsigned short u_int16_t ; -# else -# if SIZEOF_INT ==2 -typedef int int16_t ; -typedef unsigned int u_int16_t ; -# else -#error Cannot find a type with sizeof() == 2 -# endif -# endif - -# if SIZEOF_SHORT ==4 -typedef short int32_t ; -typedef unsigned short u_int32_t ; -# else -# if SIZEOF_INT ==4 -typedef int int32_t ; -typedef unsigned int u_int32_t ; -# else -#error Cannot find a type with sizeof() == 4 -# endif -# endif -#endif /* NEED_TYPEDEFS */ -#ifdef HAVE_UNISTD_H # include <unistd.h> #endif
Signature · 1 line
1.7.1
Quoted 8 lines · Stefan Weil
There is no need to have a second set of integral types. Replace them by the standard types from
stdint.h.[PATCH 1/4] block: Replace
u_int8_t,u_int16_t,u_int32_t,u_int64_tby standard int types [PATCH 2/4] tests: Replaceu_int8_t,u_int16_t,u_int32_t,u_int64_tby standard int types [PATCH 3/4] slirp: Replaceu_int8_t,u_int16_t,u_int32_t,u_int64_tby standard int types [PATCH 4/4] slirp: Remove declarations which are no longer needed
Thanks, all applied.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net