Use the appropriate [s]size_t type where a buffer size is meant.
Add const specifiers to constant function arguments.
This commit is contained in:
parent
bfbb5daa0f
commit
21b40f3c1b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=118162
@ -73,10 +73,7 @@ extern char *prog;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
get_hex_atm_addr(in, out, len)
|
get_hex_atm_addr(const char *in, u_char *out, int len)
|
||||||
char *in;
|
|
||||||
u_char *out;
|
|
||||||
int len;
|
|
||||||
{
|
{
|
||||||
int c_type, c_value, i, out_len, state, val = 0;
|
int c_type, c_value, i, out_len, state, val = 0;
|
||||||
|
|
||||||
@ -219,15 +216,14 @@ get_hex_atm_addr(in, out, len)
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
format_atm_addr(addr)
|
format_atm_addr(const Atm_addr *addr)
|
||||||
Atm_addr *addr;
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *nsap_format;
|
char *nsap_format;
|
||||||
Atm_addr_nsap *atm_nsap;
|
const Atm_addr_nsap *atm_nsap;
|
||||||
Atm_addr_e164 *atm_e164;
|
const Atm_addr_e164 *atm_e164;
|
||||||
Atm_addr_spans *atm_spans;
|
const Atm_addr_spans *atm_spans;
|
||||||
Atm_addr_pvc *atm_pvc;
|
const Atm_addr_pvc *atm_pvc;
|
||||||
static char str[256];
|
static char str[256];
|
||||||
union {
|
union {
|
||||||
int w;
|
int w;
|
||||||
@ -249,7 +245,7 @@ format_atm_addr(addr)
|
|||||||
*/
|
*/
|
||||||
switch (addr->address_format) {
|
switch (addr->address_format) {
|
||||||
case T_ATM_ENDSYS_ADDR:
|
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) {
|
switch(atm_nsap->aan_afi) {
|
||||||
default:
|
default:
|
||||||
case AFI_DCC:
|
case AFI_DCC:
|
||||||
@ -286,7 +282,7 @@ format_atm_addr(addr)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case T_ATM_E164_ADDR:
|
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++) {
|
for(i=0; i<addr->address_length; i++) {
|
||||||
sprintf(&str[strlen(str)], "%c",
|
sprintf(&str[strlen(str)], "%c",
|
||||||
atm_e164->aae_addr[i]);
|
atm_e164->aae_addr[i]);
|
||||||
@ -297,7 +293,7 @@ format_atm_addr(addr)
|
|||||||
/*
|
/*
|
||||||
* Print SPANS address as two words, xxxx.yyyy
|
* 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[0] = atm_spans->aas_addr[0];
|
||||||
u1.c[1] = atm_spans->aas_addr[1];
|
u1.c[1] = atm_spans->aas_addr[1];
|
||||||
u1.c[2] = atm_spans->aas_addr[2];
|
u1.c[2] = atm_spans->aas_addr[2];
|
||||||
@ -317,7 +313,7 @@ format_atm_addr(addr)
|
|||||||
/*
|
/*
|
||||||
* Print PVC as VPI, VCI
|
* Print PVC as VPI, VCI
|
||||||
*/
|
*/
|
||||||
atm_pvc = (Atm_addr_pvc *)addr->address;
|
atm_pvc = (const Atm_addr_pvc *)addr->address;
|
||||||
sprintf(str, "%d, %d",
|
sprintf(str, "%d, %d",
|
||||||
ATM_PVC_GET_VPI(atm_pvc),
|
ATM_PVC_GET_VPI(atm_pvc),
|
||||||
ATM_PVC_GET_VCI(atm_pvc));
|
ATM_PVC_GET_VCI(atm_pvc));
|
||||||
|
@ -66,11 +66,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
scsp_cache_key(ap, ip, ol, op)
|
scsp_cache_key(const Atm_addr *ap, const struct in_addr *ip, int ol, char *op)
|
||||||
Atm_addr *ap;
|
|
||||||
struct in_addr *ip;
|
|
||||||
int ol;
|
|
||||||
char *op;
|
|
||||||
{
|
{
|
||||||
int i, len;
|
int i, len;
|
||||||
char buff[32], digest[16];
|
char buff[32], digest[16];
|
||||||
|
@ -84,10 +84,8 @@ extern char *prog;
|
|||||||
* int length of the returned VCC information
|
* int length of the returned VCC information
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int
|
ssize_t
|
||||||
do_info_ioctl(req, buf_len)
|
do_info_ioctl(struct atminfreq *req, size_t buf_len)
|
||||||
struct atminfreq *req;
|
|
||||||
int buf_len;
|
|
||||||
{
|
{
|
||||||
int rc, s;
|
int rc, s;
|
||||||
caddr_t buf;
|
caddr_t buf;
|
||||||
@ -151,13 +149,11 @@ do_info_ioctl(req, buf_len)
|
|||||||
* int length of the retuned VCC information
|
* int length of the retuned VCC information
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int
|
ssize_t
|
||||||
get_vcc_info(intf, vccp)
|
get_vcc_info(const char *intf, struct air_vcc_rsp **vccp)
|
||||||
char *intf;
|
|
||||||
struct air_vcc_rsp **vccp;
|
|
||||||
{
|
{
|
||||||
int buf_len = sizeof(struct air_vcc_rsp) * 100;
|
size_t buf_len = sizeof(struct air_vcc_rsp) * 100;
|
||||||
struct atminfreq air;
|
struct atminfreq air;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize IOCTL request
|
* Initialize IOCTL request
|
||||||
@ -190,9 +186,7 @@ get_vcc_info(intf, vccp)
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
get_subnet_mask(intf, mask)
|
get_subnet_mask(const char *intf, struct sockaddr_in *mask)
|
||||||
char *intf;
|
|
||||||
struct sockaddr_in *mask;
|
|
||||||
{
|
{
|
||||||
int rc, s;
|
int rc, s;
|
||||||
struct ifreq req;
|
struct ifreq req;
|
||||||
@ -247,8 +241,7 @@ get_subnet_mask(intf, mask)
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
get_mtu(intf)
|
get_mtu(const char *intf)
|
||||||
char *intf;
|
|
||||||
{
|
{
|
||||||
int rc, s;
|
int rc, s;
|
||||||
struct ifreq req;
|
struct ifreq req;
|
||||||
@ -301,8 +294,7 @@ get_mtu(intf)
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
verify_nif_name(name)
|
verify_nif_name(const char *name)
|
||||||
char *name;
|
|
||||||
{
|
{
|
||||||
int rc, s;
|
int rc, s;
|
||||||
struct atminfreq air;
|
struct atminfreq air;
|
||||||
@ -371,12 +363,10 @@ verify_nif_name(name)
|
|||||||
* int length of returned Config information
|
* int length of returned Config information
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int
|
ssize_t
|
||||||
get_cfg_info ( intf, cfgp )
|
get_cfg_info(const char *intf, struct air_cfg_rsp **cfgp)
|
||||||
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;
|
struct atminfreq air;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -409,12 +399,10 @@ get_cfg_info ( intf, cfgp )
|
|||||||
* int length of returned Config information
|
* int length of returned Config information
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int
|
ssize_t
|
||||||
get_intf_info ( intf, intp )
|
get_intf_info(const char *intf, struct air_int_rsp **intp)
|
||||||
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;
|
struct atminfreq air;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -448,12 +436,10 @@ get_intf_info ( intf, intp )
|
|||||||
* int length of returned Netif information
|
* int length of returned Netif information
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int
|
ssize_t
|
||||||
get_netif_info ( intf, netp )
|
get_netif_info(const char *intf, struct air_netif_rsp **netp)
|
||||||
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;
|
struct atminfreq air;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -473,5 +459,3 @@ get_netif_info ( intf, netp )
|
|||||||
return ( buf_len );
|
return ( buf_len );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,8 +69,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
struct sockaddr_in *
|
struct sockaddr_in *
|
||||||
get_ip_addr(p)
|
get_ip_addr(const char *p)
|
||||||
char *p;
|
|
||||||
{
|
{
|
||||||
struct hostent *ip_host;
|
struct hostent *ip_host;
|
||||||
static struct sockaddr_in s;
|
static struct sockaddr_in s;
|
||||||
@ -117,8 +116,7 @@ get_ip_addr(p)
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const char *
|
const char *
|
||||||
format_ip_addr(addr)
|
format_ip_addr(const struct in_addr *addr)
|
||||||
struct in_addr *addr;
|
|
||||||
{
|
{
|
||||||
static char host_name[128];
|
static char host_name[128];
|
||||||
char *ip_num;
|
char *ip_num;
|
||||||
@ -144,7 +142,7 @@ format_ip_addr(addr)
|
|||||||
/*
|
/*
|
||||||
* Look up name in DNS
|
* 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 &&
|
if (ip_host && ip_host->h_name &&
|
||||||
strlen(ip_host->h_name)) {
|
strlen(ip_host->h_name)) {
|
||||||
/*
|
/*
|
||||||
|
@ -66,9 +66,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
short
|
short
|
||||||
ip_checksum(addr, count)
|
ip_checksum(const char *addr, int count)
|
||||||
char *addr;
|
|
||||||
int count;
|
|
||||||
{
|
{
|
||||||
/* Compute Internet Checksum for "count" bytes
|
/* Compute Internet Checksum for "count" bytes
|
||||||
* beginning at location "addr".
|
* beginning at location "addr".
|
||||||
@ -77,14 +75,14 @@ ip_checksum(addr, count)
|
|||||||
|
|
||||||
while( count > 1 ) {
|
while( count > 1 ) {
|
||||||
/* This is the inner loop */
|
/* This is the inner loop */
|
||||||
sum += ntohs(* (unsigned short *)(void *)addr);
|
sum += ntohs(* (const unsigned short *)(const void *)addr);
|
||||||
addr += sizeof(unsigned short);
|
addr += sizeof(unsigned short);
|
||||||
count -= sizeof(unsigned short);
|
count -= sizeof(unsigned short);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add left-over byte, if any */
|
/* Add left-over byte, if any */
|
||||||
if( count > 0 )
|
if( count > 0 )
|
||||||
sum += * (unsigned char *) addr;
|
sum += * (const unsigned char *) addr;
|
||||||
|
|
||||||
/* Fold 32-bit sum to 16 bits */
|
/* Fold 32-bit sum to 16 bits */
|
||||||
while (sum>>16)
|
while (sum>>16)
|
||||||
|
@ -81,29 +81,29 @@ typedef struct harp_timer Harp_timer;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* atm_addr.c */
|
/* atm_addr.c */
|
||||||
extern int get_hex_atm_addr(char *, u_char *, int);
|
extern int get_hex_atm_addr(const char *, u_char *, int);
|
||||||
extern char *format_atm_addr(Atm_addr *);
|
extern char *format_atm_addr(const Atm_addr *);
|
||||||
|
|
||||||
/* cache_key.c */
|
/* cache_key.c */
|
||||||
extern void scsp_cache_key(Atm_addr *,
|
extern void scsp_cache_key(const Atm_addr *,
|
||||||
struct in_addr *, int, char *);
|
const struct in_addr *, int, char *);
|
||||||
|
|
||||||
/* ioctl_subr.c */
|
/* ioctl_subr.c */
|
||||||
extern int do_info_ioctl(struct atminfreq *, int);
|
extern ssize_t do_info_ioctl(struct atminfreq *, size_t);
|
||||||
extern int get_vcc_info(char *, struct air_vcc_rsp **);
|
extern ssize_t get_vcc_info(const char *, struct air_vcc_rsp **);
|
||||||
extern int get_subnet_mask(char *, struct sockaddr_in *);
|
extern int get_subnet_mask(const char *, struct sockaddr_in *);
|
||||||
extern int get_mtu(char *);
|
extern int get_mtu(const char *);
|
||||||
extern int verify_nif_name(char *);
|
extern int verify_nif_name(const char *);
|
||||||
extern int get_cfg_info(char *, struct air_cfg_rsp **);
|
extern ssize_t get_cfg_info(const char *, struct air_cfg_rsp **);
|
||||||
extern int get_intf_info(char *, struct air_int_rsp **);
|
extern ssize_t get_intf_info(const char *, struct air_int_rsp **);
|
||||||
extern int get_netif_info(char *, struct air_netif_rsp **);
|
extern ssize_t get_netif_info(const char *, struct air_netif_rsp **);
|
||||||
|
|
||||||
/* ip_addr.c */
|
/* ip_addr.c */
|
||||||
extern struct sockaddr_in *get_ip_addr(char *);
|
extern struct sockaddr_in *get_ip_addr(const char *);
|
||||||
extern const char *format_ip_addr(struct in_addr *);
|
extern const char *format_ip_addr(const struct in_addr *);
|
||||||
|
|
||||||
/* ip_checksum.c */
|
/* ip_checksum.c */
|
||||||
extern short ip_checksum(char *, int);
|
extern short ip_checksum(const char *, int);
|
||||||
|
|
||||||
/* timer.c */
|
/* timer.c */
|
||||||
extern Harp_timer *harp_timer_head;
|
extern Harp_timer *harp_timer_head;
|
||||||
|
Loading…
Reference in New Issue
Block a user