summaryrefslogtreecommitdiffstats
path: root/sys/netatm
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2003-07-29 13:32:10 +0000
committerharti <harti@FreeBSD.org>2003-07-29 13:32:10 +0000
commite57d86c1ec38c63f22ddae8025c1dbc035586faa (patch)
tree676fa306ffbf8bb59c756cf9a9bb95f16ae21cd4 /sys/netatm
parent0b9b67134272377bf22b1b9f1092a5da3d74f251 (diff)
downloadFreeBSD-src-e57d86c1ec38c63f22ddae8025c1dbc035586faa.zip
FreeBSD-src-e57d86c1ec38c63f22ddae8025c1dbc035586faa.tar.gz
Make the ioctl() interface cleaner with regard to types: use size_t
instead of int where the variable has to hold buffer lengths, use u_int for things like number of network interfaces which in principle can never be negative.
Diffstat (limited to 'sys/netatm')
-rw-r--r--sys/netatm/atm_if.c19
-rw-r--r--sys/netatm/atm_ioctl.h22
-rw-r--r--sys/netatm/atm_usrreq.c2
-rw-r--r--sys/netatm/atm_vc.h12
-rw-r--r--sys/netatm/ipatm/ipatm_usrreq.c3
-rw-r--r--sys/netatm/sigpvc/sigpvc_if.c12
-rw-r--r--sys/netatm/spans/spans_arp.c3
-rw-r--r--sys/netatm/spans/spans_if.c3
-rw-r--r--sys/netatm/uni/uniarp.c19
-rw-r--r--sys/netatm/uni/uniarp_cache.c2
-rw-r--r--sys/netatm/uni/unisig_if.c3
11 files changed, 54 insertions, 46 deletions
diff --git a/sys/netatm/atm_if.c b/sys/netatm/atm_if.c
index 7010d13..ea2d2ce 100644
--- a/sys/netatm/atm_if.c
+++ b/sys/netatm/atm_if.c
@@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$");
*/
static int atm_physif_ioctl(int, caddr_t, caddr_t);
static int atm_if_ioctl(struct ifnet *, u_long, caddr_t);
-static int atm_ifparse(char *, char *, int, int *);
+static int atm_ifparse(const char *, char *, size_t, int *);
/*
* Local variables
@@ -304,7 +304,9 @@ atm_physif_ioctl(code, data, arg)
struct air_int_rsp apr;
struct air_netif_rsp anr;
struct air_cfg_rsp acr;
- int count, len, buf_len = aip->air_buf_len;
+ u_int count;
+ size_t len;
+ size_t buf_len = aip->air_buf_len;
int err = 0;
char ifname[2*IFNAMSIZ];
struct ifaddr *ifa;
@@ -1020,14 +1022,12 @@ atm_if_ioctl(ifp, cmd, data)
*
*/
static int
-atm_ifparse(name, namep, size, unitp)
- char *name;
- char *namep;
- int size;
- int *unitp;
+atm_ifparse(const char *name, char *namep, size_t size, int *unitp)
{
- char *cp, *np;
- int len = 0, unit = 0;
+ const char *cp;
+ char *np;
+ size_t len = 0;
+ int unit = 0;
/*
* Separate supplied string into name and unit parts.
@@ -1135,4 +1135,3 @@ atm_nifname(name)
}
return (NULL);
}
-
diff --git a/sys/netatm/atm_ioctl.h b/sys/netatm/atm_ioctl.h
index d23be60..43bc86f 100644
--- a/sys/netatm/atm_ioctl.h
+++ b/sys/netatm/atm_ioctl.h
@@ -73,7 +73,7 @@ struct atmsetreq {
Atm_addr asru_arp_addr; /* ARP srvr address */
Atm_addr asru_arp_subaddr;/* ARP srvr subaddr */
caddr_t asru_arp_pbuf; /* Prefix buffer addr */
- int asru_arp_plen; /* Prefix buffer len */
+ size_t asru_arp_plen; /* Prefix buffer len */
} asru_asrvr;
/* MAC address */
struct {
@@ -84,7 +84,7 @@ struct atmsetreq {
struct {
char asru_nif_intf[IFNAMSIZ];/* Interface name */
char asru_nif_pref[IFNAMSIZ];/* I/f prefix name */
- int asru_nif_cnt; /* Number of i/fs */
+ u_int asru_nif_cnt; /* Number of i/fs */
} asru_nif;
/* NSAP prefix */
struct {
@@ -198,7 +198,7 @@ struct atmdelreq {
struct atminfreq {
int air_opcode; /* Sub-operation */
caddr_t air_buf_addr; /* Buffer for returned info */
- int air_buf_len; /* Buffer length */
+ size_t air_buf_len; /* Buffer length */
union {
/* Vendor info */
char airu_vinfo_intf[IFNAMSIZ];/* Interface name */
@@ -247,7 +247,7 @@ struct atminfreq {
*/
struct air_vinfo_rsp {
char avsp_intf[IFNAMSIZ]; /* Interface name */
- int avsp_len; /* Length of returned
+ size_t avsp_len; /* Length of returned
Vendor Info block */
/* Vendor info ... */
};
@@ -311,7 +311,7 @@ struct air_int_rsp {
u_char anp_sig_proto; /* Signalling protocol */
u_char anp_sig_state; /* Signalling protocol state */
char anp_nif_pref[IFNAMSIZ]; /* Netif prefix */
- int anp_nif_cnt; /* No. of netifs */
+ u_int anp_nif_cnt; /* No. of netifs */
};
/*
@@ -341,12 +341,12 @@ struct air_vcc_rsp {
char avp_owners[(T_ATM_APP_NAME_LEN+1)*O_CNT];/* VCC users */
Atm_addr avp_daddr; /* Address of far end */
Atm_addr avp_dsubaddr; /* Subaddress of far end */
- long avp_ipdus; /* PDUs received from VCC */
- long avp_opdus; /* PDUs sent to VCC */
- long avp_ibytes; /* Bytes received from VCC */
- long avp_obytes; /* Bytes sent to VCC */
- long avp_ierrors; /* Errors receiving from VCC */
- long avp_oerrors; /* Errors sending to VCC */
+ u_long avp_ipdus; /* PDUs received from VCC */
+ u_long avp_opdus; /* PDUs sent to VCC */
+ u_long avp_ibytes; /* Bytes received from VCC */
+ u_long avp_obytes; /* Bytes sent to VCC */
+ u_long avp_ierrors; /* Errors receiving from VCC */
+ u_long avp_oerrors; /* Errors sending to VCC */
time_t avp_tstamp; /* State transition timestamp */
};
diff --git a/sys/netatm/atm_usrreq.c b/sys/netatm/atm_usrreq.c
index 5a96ca6..ffb9a94 100644
--- a/sys/netatm/atm_usrreq.c
+++ b/sys/netatm/atm_usrreq.c
@@ -382,7 +382,7 @@ atm_dgram_control(so, cmd, data, ifp, td)
* Validate interface count - logical interfaces
* are differentiated by the atm address selector.
*/
- if ((asp->asr_nif_cnt <= 0) || (asp->asr_nif_cnt > 256))
+ if (asp->asr_nif_cnt == 0 || asp->asr_nif_cnt > 256)
ATM_RETERR(EINVAL);
/*
diff --git a/sys/netatm/atm_vc.h b/sys/netatm/atm_vc.h
index 8ee4253..c4f66a5 100644
--- a/sys/netatm/atm_vc.h
+++ b/sys/netatm/atm_vc.h
@@ -58,12 +58,12 @@ struct vccb {
u_short vc_vpi; /* Virtual Path Identifier */
u_short vc_vci; /* Virtual Channel Identifier */
Atm_connvc *vc_connvc; /* CM connection VCC instance */
- long vc_ipdus; /* PDUs received from VCC */
- long vc_opdus; /* PDUs sent to VCC */
- long vc_ibytes; /* Bytes received from VCC */
- long vc_obytes; /* Bytes sent to VCC */
- long vc_ierrors; /* Errors receiving from VCC */
- long vc_oerrors; /* Errors sending to VCC */
+ u_long vc_ipdus; /* PDUs received from VCC */
+ u_long vc_opdus; /* PDUs sent to VCC */
+ u_long vc_ibytes; /* Bytes received from VCC */
+ u_long vc_obytes; /* Bytes sent to VCC */
+ u_long vc_ierrors; /* Errors receiving from VCC */
+ u_long vc_oerrors; /* Errors sending to VCC */
time_t vc_tstamp; /* State transition timestamp */
};
#endif /* _KERNEL */
diff --git a/sys/netatm/ipatm/ipatm_usrreq.c b/sys/netatm/ipatm/ipatm_usrreq.c
index b98ae26..b22c2b6 100644
--- a/sys/netatm/ipatm/ipatm_usrreq.c
+++ b/sys/netatm/ipatm/ipatm_usrreq.c
@@ -90,7 +90,8 @@ ipatm_ioctl(code, data, arg1)
struct ipatmpvc pv;
caddr_t cp;
struct in_addr ip;
- int space, err = 0;
+ int err = 0;
+ size_t space;
struct t_atm_traffic *traf;
diff --git a/sys/netatm/sigpvc/sigpvc_if.c b/sys/netatm/sigpvc/sigpvc_if.c
index dbcc215..8fab9b7 100644
--- a/sys/netatm/sigpvc/sigpvc_if.c
+++ b/sys/netatm/sigpvc/sigpvc_if.c
@@ -555,9 +555,11 @@ sigpvc_ioctl(code, data, arg1)
Atm_connection *cop;
caddr_t cp;
u_int vpi, vci;
- int i, space, err = 0;
-
+ int err;
+ size_t space;
+ size_t tlen;
+ err = 0;
switch (code) {
case AIOCS_DEL_PVC:
@@ -633,10 +635,10 @@ sigpvc_ioctl(code, data, arg1)
else
avr.avp_encaps = 0;
bzero(avr.avp_owners, sizeof(avr.avp_owners));
- for (i = 0; cop && i < sizeof(avr.avp_owners);
+ for (tlen = 0; cop && tlen < sizeof(avr.avp_owners);
cop = cop->co_next,
- i += T_ATM_APP_NAME_LEN+1) {
- strncpy(&avr.avp_owners[i],
+ tlen += T_ATM_APP_NAME_LEN + 1) {
+ strncpy(&avr.avp_owners[tlen],
cop->co_endpt->ep_getname(cop->co_toku),
T_ATM_APP_NAME_LEN);
}
diff --git a/sys/netatm/spans/spans_arp.c b/sys/netatm/spans/spans_arp.c
index 9e8666c..06b73fe 100644
--- a/sys/netatm/spans/spans_arp.c
+++ b/sys/netatm/spans/spans_arp.c
@@ -927,7 +927,8 @@ spansarp_ioctl(code, data, arg1)
struct ipvcc *ivp, *inext;
struct in_addr ip;
u_long dst;
- int err = 0, i, buf_len;
+ int err = 0, i;
+ size_t buf_len;
caddr_t buf_addr;
diff --git a/sys/netatm/spans/spans_if.c b/sys/netatm/spans/spans_if.c
index b0ae569..c4f071e 100644
--- a/sys/netatm/spans/spans_if.c
+++ b/sys/netatm/spans/spans_if.c
@@ -906,7 +906,8 @@ spans_ioctl(code, data, arg1)
struct spans_vccb *svp;
struct air_vcc_rsp rsp;
Atm_connection *cop;
- int buf_len, err = 0, i, vpi, vci;
+ int err = 0, i, vpi, vci;
+ size_t buf_len;
caddr_t buf_addr;
diff --git a/sys/netatm/uni/uniarp.c b/sys/netatm/uni/uniarp.c
index 721e4a9..b593199 100644
--- a/sys/netatm/uni/uniarp.c
+++ b/sys/netatm/uni/uniarp.c
@@ -864,7 +864,9 @@ uniarp_ioctl(code, data, arg1)
struct in_addr ip;
Atm_addr atmsub;
u_long dst;
- int err = 0, i, buf_len;
+ int err = 0;
+ size_t buf_len, tlen;
+ u_int i;
caddr_t buf_addr;
switch (code) {
@@ -962,7 +964,7 @@ uniarp_ioctl(code, data, arg1)
*/
if (asp->asr_arp_addr.address_format == T_ATM_ABSENT) {
i = asp->asr_arp_plen / sizeof(struct uniarp_prf);
- if (i <= 0) {
+ if (i == 0) {
err = EINVAL;
break;
}
@@ -1215,16 +1217,17 @@ updbuf:
* Copy the prefix list into the user's buffer
*/
if (uip->uip_nprefix) {
- i = uip->uip_nprefix
- * sizeof(struct uniarp_prf);
- if (buf_len < i) {
+ tlen = uip->uip_nprefix *
+ sizeof(struct uniarp_prf);
+ if (buf_len < tlen) {
err = ENOSPC;
break;
}
- if ((err = copyout(uip->uip_prefix, buf_addr, i)) != 0)
+ err = copyout(uip->uip_prefix, buf_addr, tlen);
+ if (err != 0)
break;
- buf_addr += i;
- buf_len -= i;
+ buf_addr += tlen;
+ buf_len -= tlen;
}
}
diff --git a/sys/netatm/uni/uniarp_cache.c b/sys/netatm/uni/uniarp_cache.c
index 10b7118..3aba40a 100644
--- a/sys/netatm/uni/uniarp_cache.c
+++ b/sys/netatm/uni/uniarp_cache.c
@@ -406,7 +406,7 @@ uniarp_validate_ip(uip, ip, origin)
u_int origin;
{
struct uniarp_prf *upp;
- int i;
+ u_int i;
/*
diff --git a/sys/netatm/uni/unisig_if.c b/sys/netatm/uni/unisig_if.c
index 9853b8a..30846e1 100644
--- a/sys/netatm/uni/unisig_if.c
+++ b/sys/netatm/uni/unisig_if.c
@@ -822,7 +822,8 @@ unisig_ioctl(code, data, arg1)
struct atm_pif *pip;
Atm_connection *cop;
u_int vpi, vci;
- int err = 0, buf_len, i;
+ int err = 0, i;
+ size_t buf_len;
caddr_t buf_addr;
ATM_DEBUG1("unisig_ioctl: code=%d\n", code);
OpenPOWER on IntegriCloud