diff options
author | harti <harti@FreeBSD.org> | 2003-07-29 13:35:03 +0000 |
---|---|---|
committer | harti <harti@FreeBSD.org> | 2003-07-29 13:35:03 +0000 |
commit | 651b54f4726197de352365675e3c76551409d5d3 (patch) | |
tree | 6127c580673b53233ee74bf74702ed9dffd1e03b /lib | |
parent | 7708c2e2d094277a614ab5b842d23b184a061584 (diff) | |
download | FreeBSD-src-651b54f4726197de352365675e3c76551409d5d3.zip FreeBSD-src-651b54f4726197de352365675e3c76551409d5d3.tar.gz |
Use the appropriate [s]size_t type where a buffer size is meant.
Add const specifiers to constant function arguments.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libatm/atm_addr.c | 24 | ||||
-rw-r--r-- | lib/libatm/cache_key.c | 6 | ||||
-rw-r--r-- | lib/libatm/ioctl_subr.c | 52 | ||||
-rw-r--r-- | lib/libatm/ip_addr.c | 8 | ||||
-rw-r--r-- | lib/libatm/ip_checksum.c | 8 | ||||
-rw-r--r-- | lib/libatm/libatm.h | 30 |
6 files changed, 50 insertions, 78 deletions
diff --git a/lib/libatm/atm_addr.c b/lib/libatm/atm_addr.c index f2cf75d..ed1becb 100644 --- a/lib/libatm/atm_addr.c +++ b/lib/libatm/atm_addr.c @@ -73,10 +73,7 @@ extern char *prog; * */ int -get_hex_atm_addr(in, out, len) - char *in; - u_char *out; - int len; +get_hex_atm_addr(const char *in, u_char *out, int len) { int c_type, c_value, i, out_len, state, val = 0; @@ -219,15 +216,14 @@ get_hex_atm_addr(in, out, len) * */ char * -format_atm_addr(addr) - Atm_addr *addr; +format_atm_addr(const Atm_addr *addr) { int i; char *nsap_format; - Atm_addr_nsap *atm_nsap; - Atm_addr_e164 *atm_e164; - Atm_addr_spans *atm_spans; - Atm_addr_pvc *atm_pvc; + const Atm_addr_nsap *atm_nsap; + const Atm_addr_e164 *atm_e164; + const Atm_addr_spans *atm_spans; + const Atm_addr_pvc *atm_pvc; static char str[256]; union { int w; @@ -249,7 +245,7 @@ format_atm_addr(addr) */ switch (addr->address_format) { case T_ATM_ENDSYS_ADDR: - atm_nsap = (Atm_addr_nsap *)addr->address; + atm_nsap = (const Atm_addr_nsap *)addr->address; switch(atm_nsap->aan_afi) { default: case AFI_DCC: @@ -286,7 +282,7 @@ format_atm_addr(addr) break; case T_ATM_E164_ADDR: - atm_e164 = (Atm_addr_e164 *)addr->address; + atm_e164 = (const Atm_addr_e164 *)addr->address; for(i=0; i<addr->address_length; i++) { sprintf(&str[strlen(str)], "%c", atm_e164->aae_addr[i]); @@ -297,7 +293,7 @@ format_atm_addr(addr) /* * Print SPANS address as two words, xxxx.yyyy */ - atm_spans = (Atm_addr_spans *)addr->address; + atm_spans = (const Atm_addr_spans *)addr->address; u1.c[0] = atm_spans->aas_addr[0]; u1.c[1] = atm_spans->aas_addr[1]; u1.c[2] = atm_spans->aas_addr[2]; @@ -317,7 +313,7 @@ format_atm_addr(addr) /* * Print PVC as VPI, VCI */ - atm_pvc = (Atm_addr_pvc *)addr->address; + atm_pvc = (const Atm_addr_pvc *)addr->address; sprintf(str, "%d, %d", ATM_PVC_GET_VPI(atm_pvc), ATM_PVC_GET_VCI(atm_pvc)); diff --git a/lib/libatm/cache_key.c b/lib/libatm/cache_key.c index da08df2..8e212e6 100644 --- a/lib/libatm/cache_key.c +++ b/lib/libatm/cache_key.c @@ -66,11 +66,7 @@ __FBSDID("$FreeBSD$"); * */ void -scsp_cache_key(ap, ip, ol, op) - Atm_addr *ap; - struct in_addr *ip; - int ol; - char *op; +scsp_cache_key(const Atm_addr *ap, const struct in_addr *ip, int ol, char *op) { int i, len; char buff[32], digest[16]; diff --git a/lib/libatm/ioctl_subr.c b/lib/libatm/ioctl_subr.c index d5cc799..dd5dafb 100644 --- a/lib/libatm/ioctl_subr.c +++ b/lib/libatm/ioctl_subr.c @@ -84,10 +84,8 @@ extern char *prog; * int length of the returned VCC information * */ -int -do_info_ioctl(req, buf_len) - struct atminfreq *req; - int buf_len; +ssize_t +do_info_ioctl(struct atminfreq *req, size_t buf_len) { int rc, s; caddr_t buf; @@ -151,13 +149,11 @@ mem_retry: * int length of the retuned VCC information * */ -int -get_vcc_info(intf, vccp) - char *intf; - struct air_vcc_rsp **vccp; +ssize_t +get_vcc_info(const char *intf, struct air_vcc_rsp **vccp) { - int buf_len = sizeof(struct air_vcc_rsp) * 100; - struct atminfreq air; + size_t buf_len = sizeof(struct air_vcc_rsp) * 100; + struct atminfreq air; /* * Initialize IOCTL request @@ -190,9 +186,7 @@ get_vcc_info(intf, vccp) * */ int -get_subnet_mask(intf, mask) - char *intf; - struct sockaddr_in *mask; +get_subnet_mask(const char *intf, struct sockaddr_in *mask) { int rc, s; struct ifreq req; @@ -247,8 +241,7 @@ get_subnet_mask(intf, mask) * */ int -get_mtu(intf) - char *intf; +get_mtu(const char *intf) { int rc, s; struct ifreq req; @@ -301,8 +294,7 @@ get_mtu(intf) * */ int -verify_nif_name(name) - char *name; +verify_nif_name(const char *name) { int rc, s; struct atminfreq air; @@ -371,12 +363,10 @@ verify_nif_name(name) * int length of returned Config information * */ -int -get_cfg_info ( intf, cfgp ) - char *intf; - struct air_cfg_rsp **cfgp; +ssize_t +get_cfg_info(const char *intf, struct air_cfg_rsp **cfgp) { - int buf_len = sizeof(struct air_cfg_rsp) * 4; + size_t buf_len = sizeof(struct air_cfg_rsp) * 4; struct atminfreq air; /* @@ -409,12 +399,10 @@ get_cfg_info ( intf, cfgp ) * int length of returned Config information * */ -int -get_intf_info ( intf, intp ) - char *intf; - struct air_int_rsp **intp; +ssize_t +get_intf_info(const char *intf, struct air_int_rsp **intp) { - int buf_len = sizeof(struct air_int_rsp) * 4; + size_t buf_len = sizeof(struct air_int_rsp) * 4; struct atminfreq air; /* @@ -448,12 +436,10 @@ get_intf_info ( intf, intp ) * int length of returned Netif information * */ -int -get_netif_info ( intf, netp ) - char *intf; - struct air_netif_rsp **netp; +ssize_t +get_netif_info(const char *intf, struct air_netif_rsp **netp) { - int buf_len = sizeof(struct air_netif_rsp) * 10; + size_t buf_len = sizeof(struct air_netif_rsp) * 10; struct atminfreq air; /* @@ -473,5 +459,3 @@ get_netif_info ( intf, netp ) return ( buf_len ); } - - diff --git a/lib/libatm/ip_addr.c b/lib/libatm/ip_addr.c index 42f734a..46504d7 100644 --- a/lib/libatm/ip_addr.c +++ b/lib/libatm/ip_addr.c @@ -69,8 +69,7 @@ __FBSDID("$FreeBSD$"); * */ struct sockaddr_in * -get_ip_addr(p) - char *p; +get_ip_addr(const char *p) { struct hostent *ip_host; static struct sockaddr_in s; @@ -117,8 +116,7 @@ get_ip_addr(p) * */ const char * -format_ip_addr(addr) - struct in_addr *addr; +format_ip_addr(const struct in_addr *addr) { static char host_name[128]; char *ip_num; @@ -144,7 +142,7 @@ format_ip_addr(addr) /* * Look up name in DNS */ - ip_host = gethostbyaddr((char *)addr, sizeof(addr), AF_INET); + ip_host = gethostbyaddr((const char *)addr, sizeof(addr), AF_INET); if (ip_host && ip_host->h_name && strlen(ip_host->h_name)) { /* diff --git a/lib/libatm/ip_checksum.c b/lib/libatm/ip_checksum.c index 71ef7b4..2881c24 100644 --- a/lib/libatm/ip_checksum.c +++ b/lib/libatm/ip_checksum.c @@ -66,9 +66,7 @@ __FBSDID("$FreeBSD$"); * */ short -ip_checksum(addr, count) - char *addr; - int count; +ip_checksum(const char *addr, int count) { /* Compute Internet Checksum for "count" bytes * beginning at location "addr". @@ -77,14 +75,14 @@ ip_checksum(addr, count) while( count > 1 ) { /* This is the inner loop */ - sum += ntohs(* (unsigned short *)(void *)addr); + sum += ntohs(* (const unsigned short *)(const void *)addr); addr += sizeof(unsigned short); count -= sizeof(unsigned short); } /* Add left-over byte, if any */ if( count > 0 ) - sum += * (unsigned char *) addr; + sum += * (const unsigned char *) addr; /* Fold 32-bit sum to 16 bits */ while (sum>>16) diff --git a/lib/libatm/libatm.h b/lib/libatm/libatm.h index 7014233..1c2088f 100644 --- a/lib/libatm/libatm.h +++ b/lib/libatm/libatm.h @@ -81,29 +81,29 @@ typedef struct harp_timer Harp_timer; */ /* atm_addr.c */ -extern int get_hex_atm_addr(char *, u_char *, int); -extern char *format_atm_addr(Atm_addr *); +extern int get_hex_atm_addr(const char *, u_char *, int); +extern char *format_atm_addr(const Atm_addr *); /* cache_key.c */ -extern void scsp_cache_key(Atm_addr *, - struct in_addr *, int, char *); +extern void scsp_cache_key(const Atm_addr *, + const struct in_addr *, int, char *); /* ioctl_subr.c */ -extern int do_info_ioctl(struct atminfreq *, int); -extern int get_vcc_info(char *, struct air_vcc_rsp **); -extern int get_subnet_mask(char *, struct sockaddr_in *); -extern int get_mtu(char *); -extern int verify_nif_name(char *); -extern int get_cfg_info(char *, struct air_cfg_rsp **); -extern int get_intf_info(char *, struct air_int_rsp **); -extern int get_netif_info(char *, struct air_netif_rsp **); +extern ssize_t do_info_ioctl(struct atminfreq *, size_t); +extern ssize_t get_vcc_info(const char *, struct air_vcc_rsp **); +extern int get_subnet_mask(const char *, struct sockaddr_in *); +extern int get_mtu(const char *); +extern int verify_nif_name(const char *); +extern ssize_t get_cfg_info(const char *, struct air_cfg_rsp **); +extern ssize_t get_intf_info(const char *, struct air_int_rsp **); +extern ssize_t get_netif_info(const char *, struct air_netif_rsp **); /* ip_addr.c */ -extern struct sockaddr_in *get_ip_addr(char *); -extern const char *format_ip_addr(struct in_addr *); +extern struct sockaddr_in *get_ip_addr(const char *); +extern const char *format_ip_addr(const struct in_addr *); /* ip_checksum.c */ -extern short ip_checksum(char *, int); +extern short ip_checksum(const char *, int); /* timer.c */ extern Harp_timer *harp_timer_head; |