Date: Sat, 01 Mar 2003 18:45:51 +0100 From: Jens Rehsack <rehsack@liwing.de> To: Jens Rehsack <rehsack@liwing.de> Cc: current@FreeBSD.ORG Subject: Re: PATCH: type errors in src-tree Message-ID: <3E60F1CF.2030400@liwing.de> References: <3E5EA13E.9020208@liwing.de>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------040307000007060305040603 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sorry for resending (3rd time), but I've found a small typo in the patch of sbin/atm/ilmid/ilmid.c Jens --------------040307000007060305040603 Content-Type: text/plain; name="patch-sbin_atm_ilmid_ilmid_c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch-sbin_atm_ilmid_ilmid_c" --- sbin/atm/ilmid/ilmid.c.orig Wed Jan 1 18:48:45 2003 +++ sbin/atm/ilmid/ilmid.c Sat Mar 1 13:29:05 2003 @@ -162,7 +162,7 @@ union { int ival; /* INTEGER/TIMESTAMP */ Objid oval; /* OBJID */ - long aval; /* IPADDR */ + uint32_t aval; /* IPADDR */ char sval[STRLEN]; /* OCTET */ } var; Variable *next; @@ -173,10 +173,10 @@ * which doesn't have the last three fields is the TRAP type. */ struct snmp_header { - int pdulen; - int version; + uint32_t pdulen; + uint32_t version; char community[64]; - int pdutype; + uint32_t pdutype; /* GET/GETNEXT/GETRESP/SET */ int reqid; @@ -185,11 +185,11 @@ /* TRAP */ Objid enterprise; - int ipaddr; + uint32_t ipaddr; int generic_trap; int specific_trap; - int varlen; + uint32_t varlen; Variable *head, *tail; }; @@ -279,7 +279,7 @@ * Temporary buffer for building response packets. Should help ensure * that we aren't accidently overwriting some other memory. */ -u_char Resp_Buf[1024]; +char Resp_Buf[1024]; /* * Copy the reponse into a buffer we can modify without @@ -292,7 +292,7 @@ * TRAP generic trap types */ char *Traps[] = { "coldStart", "warmStart", "linkDown", "linkUp", - "authenticationFailure", "egpNeighborLoss", + "authenticationFailure", "egpNeighborLoss", "enterpriseSpecific" }; @@ -320,6 +320,9 @@ */ Objid addressEntry[MAX_UNITS + 1]; +static const char *ilmi_ident_str = "ILMI"; +static const size_t ilmi_ident_str_len = strlen("ILMI"); + /* * When this daemon started */ @@ -335,7 +338,7 @@ #define LOG_FILE "/var/log/ilmid" FILE *Log; /* File descriptor for log messages */ -void set_reqid( u_char *, int ); +void set_reqid( caddr_t, uint32_t ); void Increment_DL( int ); void Decrement_DL( int ); @@ -376,7 +379,7 @@ /* * Utility to pretty print buffer as hex dumps - * + * * Arguments: * bp - buffer pointer * len - length to pretty print @@ -387,10 +390,10 @@ */ void hexdump ( bp, len ) - u_char *bp; - int len; + caddr_t bp; + uint32_t len; { - int i, j; + uint32_t i, j; /* * Print as 4 groups of four bytes. Each byte is separated @@ -443,7 +446,7 @@ * bufp - pointer to buffer pointer * plen - pointer to PDU length or NULL if not a concern * - * Returns: + * Returns: * bufp - updated buffer pointer * plen - (possibly) adjusted pdu length * <len> - decoded length @@ -451,21 +454,21 @@ */ int asn_get_pdu_len ( bufp, plen ) - u_char **bufp; - int *plen; + caddr_t *bufp; + uint32_t *plen; { - u_char *bp = *bufp; - int len = 0; - int i, b; + caddr_t bp = *bufp; + uint32_t len = 0; + uint32_t i, b; b = *bp++; if ( plen ) - (*plen)--; - if ( b & 0x80 ) { - for ( i = 0; i < (b & ~0x80); i++ ) { + --(*plen); + if ( b & 0x80 ) { + for ( i = 0; i < (b & ~0x80); ++i ) { len = len * 256 + *bp++; if ( plen ) - (*plen)--; + --(*plen); } } else len = b; @@ -492,12 +495,12 @@ */ int asn_get_encoded ( bufp, len ) - u_char **bufp; - int *len; + caddr_t *bufp; + uint32_t *len; { - u_char *bp = *bufp; - int val = 0; - int l = *len; + caddr_t bp = *bufp; + int val = 0; /* FIXME: signed? sure? */ + uint32_t l = *len; /* * Keep going while high bit is set @@ -507,7 +510,7 @@ * Each byte can represent 7 bits */ val = ( val << 7 ) + ( *bp & ~0x80 ); - l--; + --l; } while ( *bp++ & 0x80 ); *bufp = bp; /* update buffer pointer */ @@ -526,28 +529,28 @@ * plen - pointer to PDU length or NULL if not a concern * * Returns: - * bufp - updated buffer pointer + * bufp - updated buffer pointer * plen - (possibly) updated PDU length * <val> - value of encoded integer * */ int asn_get_int ( bufp, plen ) - u_char **bufp; - int *plen; + caddr_t *bufp; + uint32_t *plen; { - int i; - int len; - int v = 0; - u_char *bp = *bufp; + uint32_t i; + uint32_t len; + int v = 0; + caddr_t bp = *bufp; len = *bp++; if ( plen ) - (*plen)--; - for ( i = 0; i < len; i++ ) { + --(*plen); + for ( i = 0; i < len; ++i ) { v = (v * 256) + *bp++; if ( plen ) - (*plen)--; + --(*plen); } *bufp = bp; return ( v ); @@ -567,16 +570,16 @@ */ void asn_set_int ( bufp, val ) - u_char **bufp; - int val; + caddr_t *bufp; + uint32_t val; { union { - int i; - u_char c[4]; + uint32_t i; + u_char c[sizeof(uint32_t)]; } u; - int len = sizeof(int); - int i = 0; - u_char *bp = *bufp; + uint32_t len = sizeof(uint32_t); + uint32_t i = 0; + caddr_t bp = *bufp; /* Check for special case where val == 0 */ if ( val == 0 ) { @@ -588,16 +591,16 @@ u.i = htonl ( val ); - while ( u.c[i] == 0 && i++ < sizeof(int) ) - len--; + while ( u.c[i] == 0 && ++i < sizeof(u.i) ) /* 'i++ < x' increases x even if increase break bounds */ + --len; if ( u.c[i] > 0x7f ) { - i--; - len++; + --i; + ++len; } - *bp++ = len; - bcopy ( (caddr_t)&u.c[sizeof(int)-len], bp, len ); + *bp++ = (char)len; + bcopy ( (caddr_t)&u.c[sizeof(u.i)-len], bp, len ); bp += len; *bufp = bp; @@ -618,7 +621,7 @@ print_objid ( objid ) Objid *objid; { - int i; + uint32_t i, cmp = objid->oid[0]; /* * First oid coded as 40 * X + Y @@ -628,7 +631,7 @@ fprintf ( Log, ".%d.%d", objid->oid[1] / 40, objid->oid[1] % 40 ); } - for ( i = 2; i <= objid->oid[0]; i++ ) + for ( i = 2; i <= cmp; ++i ) if ( Log ) fprintf ( Log, ".%d", objid->oid[i] ); if ( Log ) @@ -653,23 +656,23 @@ */ void asn_get_objid ( bufp, objid, plen ) - u_char **bufp; - Objid *objid; - int *plen; -{ - int len; - u_char *bp = *bufp; - int *ip = (int *)objid + 1; /* First byte will contain length */ - int oidlen = 0; + caddr_t *bufp; + Objid *objid; + uint32_t *plen; +{ + uint32_t len; + caddr_t bp = *bufp; + int *ip = (int *)objid + 1; /* First byte will contain length */ + uint32_t oidlen = 0; len = *bp++; if ( plen ) - (*plen)--; + --(*plen); while ( len ) { *ip++ = asn_get_encoded ( &bp, &len ); if ( plen ) - (*plen)--; - oidlen++; + --(*plen); + ++oidlen; } objid->oid[0] = oidlen; *bufp = bp; @@ -683,28 +686,28 @@ */ int asn_put_objid ( bufp, objid ) - u_char **bufp; - Objid *objid; + caddr_t *bufp; + Objid *objid; { - int len = 0; - u_char *bp = *bufp; - u_char *cpp; - int i; + uint32_t len = 0; + caddr_t bp = *bufp; + caddr_t cpp; + uint32_t i, oidlen = objid->oid[0]; cpp = bp; *bp++ = objid->oid[0]; - len++; - for ( i = 1; i <= objid->oid[0]; i++ ) { + ++len; + for ( i = 1; i <= oidlen; ++i ) { /* FIXME: objid->oid[0] can be greater than 128 which is sizeof(objid->oid) */ u_int c = objid->oid[i]; while ( c > 127 ) { *bp++ = ( ( c >> 7 ) & 0x7f ) | 0x80; - len++; + ++len; c &= 0x7f; /* XXX - assumption of two bytes */ - (*cpp)++; + ++(*cpp); } *bp++ = c; - len++; + ++len; } *bufp = bp; @@ -728,27 +731,27 @@ * octet - encoded Octet String * plen - (possibly) adjusted PDU length * - */ + */ void asn_get_octet ( bufp, octet, plen ) - u_char **bufp; - char *octet; - int *plen; -{ - u_char *bp = *bufp; - int i = 0; - int len = 0; + caddr_t *bufp; + caddr_t octet; + uint32_t *plen; +{ + caddr_t bp = *bufp; + uint32_t i = 0; + uint32_t len = 0; /* * &i is really a dummy value here as we don't keep track * of the ongoing buffer length */ - len = asn_get_encoded ( &bp, &i, plen ); + len = (uint32_t)asn_get_encoded ( &bp, &i, plen ); - for ( i = 0; i < len; i++ ) { + for ( i = 0; i < len; ++i ) { *octet++ = *bp++; if ( plen ) - (*plen)--; + --(*plen); } *bufp = bp; @@ -831,22 +834,22 @@ Snmp_Header *h; caddr_t *bp; { - int len = h->varlen; - int sublen; + uint32_t len = h->varlen; + uint32_t sublen; Variable *var; caddr_t bufp = *bp; while ( len > 0 ) { if ( *bufp++ == ASN_SEQUENCE ) { - len--; + --len; /* Create new Variable instance */ - if ( ( var = (Variable *)malloc(sizeof(Variable)) ) == NULL ) + if ( ( var = malloc(sizeof(*var)) ) == NULL ) { *bp = bufp; return; } - bzero(var, sizeof(Variable)); + bzero(var, sizeof(*var)); /* Link to tail */ if ( h->tail ) h->tail->next = var; @@ -872,8 +875,8 @@ var->var.ival = asn_get_int ( &bufp, &len ); break; case ASN_NULL: - bufp++; - len--; + ++bufp; + --len; break; case ASN_OBJID: asn_get_objid ( &bufp, &var->var.oval, &len ); @@ -915,23 +918,25 @@ */ Snmp_Header * asn_get_header ( bufp ) - u_char **bufp; + caddr_t *bufp; { Snmp_Header *h; - u_char *bp = *bufp; - int len = 0; - int dummy = 0; + caddr_t bp = *bufp; + uint32_t len = 0; + /* + uint32_t dummy = 0; + */ /* * Allocate memory to hold the SNMP header */ - if ( ( h = (Snmp_Header *)malloc(sizeof(Snmp_Header)) ) == NULL ) + if ( ( h = malloc(sizeof(*h)) ) == NULL ) /* void * matches any pointer type */ return ( (Snmp_Header *)NULL ); /* * Ensure that we wipe the slate clean */ - bzero(h, sizeof(Snmp_Header)); + bzero(h, sizeof(*h)); /* * PDU has to start as SEQUENCE OF @@ -970,7 +975,7 @@ */ if ( h->pdutype != PDU_TYPE_TRAP ) { /* TRAP uses different format */ - (void) asn_get_pdu_len ( &bp, &dummy ); + (void) asn_get_pdu_len ( &bp, NULL ); /* &dummy -> NULL */ /* Request ID */ if ( *bp++ != ASN_INTEGER ) { @@ -1027,15 +1032,15 @@ */ int oid_cmp ( oid1, oid2 ) - Objid *oid1, *oid2; + Objid *oid1, *oid2; { - int i; - int len; + uint32_t i; + uint32_t len; /* * Compare lengths */ - if ( !(oid1->oid[0] == oid2->oid[0] ) ) + if ( !(oid1->oid[0] == oid2->oid[0] ) ) /* FIXME: how about if( oid1->oid[0] != oid2->oid[0] ) */ /* Different lengths */ return ( 1 ); @@ -1070,9 +1075,9 @@ int oid_ncmp ( oid1, oid2, len ) Objid *oid1, *oid2; - int len; + uint32_t len; { - int i; + uint32_t i; /* * value by value compare @@ -1102,7 +1107,7 @@ find_var ( var ) Variable *var; { - int i; + int i; for ( i = 0; i < NUM_OIDS; i++ ) if ( oid_cmp ( &var->oid, &Objids[i] ) == 0 ) { @@ -1114,7 +1119,7 @@ } /* - * Return the time process has been running as a number of ticks + * Return the time process has been running as a number of ticks * * Arguments: * none @@ -1172,14 +1177,14 @@ Snmp_Header *hdr; int type; { - u_char *bp = Resp_Buf; - u_char *vpp; - u_char *ppp; + caddr_t bp = Resp_Buf; + caddr_t vpp; + caddr_t ppp; int erridx = 0; int varidx = 1; - int varlen = 0; - int pdulen = 0; - int traplen = 0; + uint32_t varlen = 0; + uint32_t pdulen = 0; + uint32_t traplen = 0; Variable *var; /* @@ -1188,14 +1193,14 @@ bzero ( Resp_Buf, sizeof(Resp_Buf) ); /* [0] is reserved for overall length */ - bp++; + ++bp; /* Start with SEQUENCE OF */ *bp++ = ASN_SEQUENCE; /* - assume we can code length in two octets */ *bp++ = 0x82; - bp++; - bp++; + ++bp; + ++bp; /* Version */ *bp++ = ASN_INTEGER; asn_set_int ( &bp, hdr->version ); @@ -1208,7 +1213,7 @@ *bp++ = type; ppp = bp; /* Length of OID data - assume it'll fit in one octet */ - bp++; + ++bp; if ( type != PDU_TYPE_TRAP ) { /* Sequence ID */ @@ -1250,7 +1255,7 @@ /* Fill in IP address */ *bp++ = ASN_IPADDR; *bp++ = sizeof ( hdr->ipaddr ); - bcopy ( (caddr_t)&hdr->ipaddr, bp, sizeof(hdr->ipaddr) ); + bcopy ( &hdr->ipaddr, bp, sizeof(hdr->ipaddr) ); bp += sizeof(hdr->ipaddr); /* Fill in generic and specific trap types */ @@ -1262,7 +1267,7 @@ /* Fill in time-stamp - assume 0 for now */ *bp++ = ASN_TIMESTAMP; asn_set_int ( &bp, 0 ); - + /* encoded length */ traplen = ( bp - ppp - 1 ); @@ -1275,40 +1280,40 @@ /* - assume we can code length in two octets */ vpp = bp; varlen = 0; - bp++; - bp++; + ++bp; + ++bp; /* Install Variables */ var = hdr->head; varidx = 1; while ( var ) { - u_char *bpp; - int len = 0; + caddr_t bpp; + uint32_t len = 0; /* SEQUENCE OF */ *bp++ = ASN_SEQUENCE; *bp++ = 0x82; /* - assume we can code length in two octets */ bpp = bp; - bp++; - bp++; + ++bp; + ++bp; /* OBJID */ *bp++ = ASN_OBJID; - len++; + ++len; len += asn_put_objid ( &bp, &var->oid ); if ( erridx && varidx >= erridx ) { /* Code this variable as NULL */ *bp++ = ASN_NULL; - len++; - bp++; - len++; + ++len; + ++bp; + ++len; } else { - u_char *lpp; + caddr_t lpp; /* Variable type */ *bp++ = var->type; - len++; + ++len; lpp = bp; switch ( var->type ) { case ASN_INTEGER: @@ -1317,7 +1322,7 @@ break; case ASN_OCTET: *bp++ = var->var.sval[0]; - len++; + ++len; bcopy ( (caddr_t)&var->var.sval[1], bp, var->var.sval[0] ); len += var->var.sval[0]; @@ -1325,7 +1330,7 @@ break; case ASN_NULL: *bp++ = 0x00; - len++; + ++len; break; case ASN_OBJID: len += asn_put_objid ( &bp, &var->var.oval ); @@ -1333,11 +1338,11 @@ case ASN_SEQUENCE: break; case ASN_IPADDR: - *bp++ = 4; - len++; - bcopy ( (caddr_t)&var->var.aval, bp, 4 ); - len += 4; - bp += 4; + *bp++ = sizeof(var->var.aval); + ++len; + bcopy ( &var->var.aval, bp, sizeof(var->var.aval) ); + len += sizeof(var->var.aval); + bp += sizeof(var->var.aval); break; case ASN_TIMESTAMP: asn_set_int ( &bp, var->var.ival ); @@ -1349,7 +1354,7 @@ } /* Accumulate total Variable sequence length */ - varlen += (len + 4); + varlen += (len + 4); /* FIXME: why 4? is it sizeof(var->var.aval) */ /* Fill in length of this sequence */ bpp[1] = len & 0xff; @@ -1413,14 +1418,14 @@ */ void set_reqid ( resp, reqid ) - u_char *resp; - int reqid; + caddr_t resp; + uint32_t reqid; { - u_char *bp = (u_char *)&resp[18]; + caddr_t bp = resp+18; union { - int i; - u_char c[4]; - } u; + uint32_t i; + char c[sizeof(uint32_t)]; + } u; u.i = htonl(reqid); @@ -1433,7 +1438,7 @@ } /* - * Send a generic response packet + * Send a generic response packet - FIXME: documentation doesn't match declaration * * Arguments: * sd - socket to send the reply on @@ -1448,12 +1453,12 @@ send_resp ( intf, Hdr, resp ) int intf; Snmp_Header *Hdr; - u_char *resp; + caddr_t resp; { int n; - if ( ilmi_fd[intf] > 0 ) { - n = write ( ilmi_fd[intf], (caddr_t)&resp[1], resp[0] ); + if ( ilmi_fd[intf] > 0 ) { /* FIXME: does ilmi_fd[intf] exists? out of range? */ + n = write ( ilmi_fd[intf], resp+1, resp[0] ); if ( Log && Debug_Level > 1 ) { write_timestamp(); fprintf ( Log, "===== Sent %d of %d bytes (%d) =====\n", n, resp[0], ilmi_fd[intf] ); @@ -1477,33 +1482,34 @@ Snmp_Header *hdr; Variable *var; - hdr = (Snmp_Header *)malloc(sizeof(Snmp_Header)); + hdr = malloc(sizeof(*hdr)); if (hdr == NULL) { - fprintf(stderr, "malloc() failed in %s()\n", __func__); + fprintf(stderr, "malloc() failed in %s() line %d\n", __func__, __LINE__); exit(1); } - bzero(hdr, sizeof(Snmp_Header)); + bzero(hdr, sizeof(*hdr)); + /* FIXME: bzero has done that hdr->pdulen = 0; + */ hdr->version = SNMP_VERSION_1 - 1; - snprintf ( hdr->community, sizeof(hdr->community), "ILMI" ); + snprintf ( hdr->community, ilmi_ident_str_len, ilmi_ident_str ); - hdr->ipaddr = 0x0; /* 0.0.0.0 */ + /* FIXME: bzero: hdr->ipaddr = 0x0; */ /* 0.0.0.0 */ hdr->generic_trap = TRAP_COLDSTART; - hdr->specific_trap = 0; - bcopy ( (caddr_t)&Objids[ENTERPRISE_OBJID], (caddr_t)&hdr->enterprise, + /* FIXME: bzero: hdr->specific_trap = 0; */ + bcopy ( &Objids[ENTERPRISE_OBJID], &hdr->enterprise, sizeof(Objid) ); - hdr->head = (Variable *)malloc(sizeof(Variable)); - if (hdr == NULL) { - fprintf(stderr, "malloc() failed in %s()\n", __func__); + hdr->head = malloc(sizeof(*hdr->head)); + if (hdr->head == NULL) { + fprintf(stderr, "malloc() failed in %s() line %d\n", __func__, __LINE__); exit(1); } - bzero(hdr->head, sizeof(Variable)); + bzero(hdr->head, sizeof(*hdr->head)); var = hdr->head; - bcopy ( (caddr_t)&Objids[UPTIME_OBJID], (caddr_t)&var->oid, - sizeof(Objid) ); + bcopy ( &Objids[UPTIME_OBJID], &var->oid, sizeof(var->oid) ); var->type = ASN_NULL; return ( hdr ); @@ -1518,40 +1524,40 @@ { Snmp_Header *hdr; - hdr = (Snmp_Header *)malloc(sizeof(Snmp_Header)); + hdr = malloc(sizeof(*hdr)); if (hdr == NULL) { fprintf(stderr, "malloc() failed in %s()\n", __func__); exit(1); } - bzero(hdr, sizeof(Snmp_Header)); + bzero(hdr, sizeof(*hdr)); - hdr->pdulen = 0; + /* FIXME: bzero: hdr->pdulen = 0; */ hdr->version = SNMP_VERSION_1 - 1; - snprintf ( hdr->community, sizeof(hdr->community), "ILMI" ); + snprintf ( hdr->community, ilmi_ident_str_len, ilmi_ident_str ); return ( hdr ); } -/* +/* * Initialize information on what physical adapters HARP knows about * * Query the HARP subsystem about configuration and physical interface * information for any currently registered ATM adapters. Store the information * as arrays for easier indexing by SNMP port/index numbers. - * + * * Arguments: * none * * Returns: - * none Information from HARP available - * + * none Information from HARP available + * */ -void -init_ilmi() +void +init_ilmi() { - struct air_cfg_rsp *cfg_info = NULL; - struct air_int_rsp *intf_info = NULL; - int buf_len; + struct air_cfg_rsp *cfg_info = NULL; + struct air_int_rsp *intf_info = NULL; + int buf_len; /* * Get configuration info - what's available with 'atm sh config' @@ -1562,7 +1568,7 @@ */ if ( buf_len <= 0 ) { bzero ( Cfg, sizeof(Cfg) ); - bzero( Intf, sizeof(Intf) ); + bzero ( Intf, sizeof(Intf) ); NUnits = 0; return; } @@ -1570,11 +1576,11 @@ /* * Move to local storage */ - bcopy ( cfg_info, (caddr_t)Cfg, buf_len ); + bcopy ( cfg_info, Cfg, buf_len ); /* * Compute how many units information was returned for */ - NUnits = buf_len / sizeof(struct air_cfg_rsp); + NUnits = buf_len / sizeof(*cfg_info); /* Housecleaning */ free ( cfg_info ); cfg_info = NULL; @@ -1593,7 +1599,7 @@ /* * Move to local storage */ - bcopy ( intf_info, (caddr_t)Intf, buf_len ); + bcopy ( intf_info, Intf, buf_len ); /* Housecleaning */ free ( intf_info ); intf_info = NULL; @@ -1620,28 +1626,28 @@ void ilmi_open () { - struct sockaddr_atm satm; - struct t_atm_aal5 aal5; - struct t_atm_traffic traffic; - struct t_atm_bearer bearer; - struct t_atm_qos qos; + struct sockaddr_atm satm; + struct t_atm_aal5 aal5; + struct t_atm_traffic traffic; + struct t_atm_bearer bearer; + struct t_atm_qos qos; struct t_atm_app_name appname; - Atm_addr subaddr; - char nifname[IFNAMSIZ]; - int optlen; - int unit = 0; + Atm_addr subaddr; + char nifname[IFNAMSIZ]; + socklen_t optlen; + int unit = 0; u_char sig_proto; init_ilmi(); - for ( unit = 0; unit < NUnits; unit++ ) { + for ( unit = 0; unit < NUnits; ++unit ) { /* * ILMI only makes sense for UNI signalling protocols */ sig_proto = Intf[unit].anp_sig_proto; if ( sig_proto != ATM_SIG_UNI30 && sig_proto != ATM_SIG_UNI31 && - sig_proto != ATM_SIG_UNI40 ) + sig_proto != ATM_SIG_UNI40 ) continue; if ( ilmi_fd[unit] == -1 ) { @@ -1688,7 +1694,7 @@ /* * Set up destination SAP */ - bzero ( (caddr_t) &satm, sizeof(satm) ); + bzero ( &satm, sizeof(satm) ); satm.satm_family = AF_ATM; #if (defined(BSD) && (BSD >= 199103)) satm.satm_len = sizeof(satm); @@ -1702,7 +1708,7 @@ 0 ); ATM_PVC_SET_VCI((Atm_addr_pvc *)satm.satm_addr.t_atm_sap_addr.address, 16 ); - + satm.satm_addr.t_atm_sap_layer2.SVE_tag = T_ATM_PRESENT; satm.satm_addr.t_atm_sap_layer2.ID_type = T_ATM_SIMPLE_ID; satm.satm_addr.t_atm_sap_layer2.ID.simple_ID = T_ATM_BLLI2_I8802; @@ -1828,11 +1834,11 @@ */ void get_local_ip ( s, aval ) - int s; - long *aval; + int s; + uint32_t *aval; { char intf_name[IFNAMSIZ]; - int namelen = IFNAMSIZ; + socklen_t namelen = IFNAMSIZ; struct air_netif_rsp *net_info = NULL; struct sockaddr_in *sin; @@ -1855,7 +1861,7 @@ /* * Fill in answer */ - bcopy ( (caddr_t)&sin->sin_addr.s_addr, aval, 4 ); + bcopy ( &sin->sin_addr.s_addr, aval, sizeof(*aval) ); free ( net_info ); @@ -1901,7 +1907,7 @@ * Pull prefix out of received Objid * save in set_prefix IOCTL and addressEntry table */ - for ( i = 0; i < oid->oid[13]; i++ ) { + for ( i = 0; i < oid->oid[13]; ++i ) { asr.asr_prf_pref[i] = oid->oid[i + 14]; } @@ -1909,7 +1915,7 @@ * Pass new prefix to the HARP kernel */ fd = socket ( AF_ATM, SOCK_DGRAM, 0 ); - if ( fd < 0 ) + if ( fd < 0 ) return; if ( ioctl ( fd, AIOCSET, (caddr_t)&asr ) < 0 ) { if ( errno != EALREADY ) { @@ -1957,17 +1963,17 @@ PDU_Header = build_generic_header(); - PDU_Header->head = (Variable *)malloc(sizeof(Variable)); + PDU_Header->head = malloc(sizeof(*PDU_Header->head)); if (PDU_Header->head == NULL) { - fprintf(stderr, "malloc() failed in %s()\n", __func__); + fprintf(stderr, "malloc() failed in %s() line %d\n", __func__, __LINE__); exit(1); } - bzero(PDU_Header->head, sizeof(Variable)); + bzero(PDU_Header->head, sizeof(*PDU_Header->head)); var = PDU_Header->head; /* Copy generic addressEntry OBJID */ - bcopy ( (caddr_t)&Objids[ADDRESS_OBJID], (caddr_t)&var->oid, - sizeof(Objid) ); + bcopy ( &Objids[ADDRESS_OBJID], &var->oid, + sizeof(var->oid) ); /* Set specific instance */ i = var->oid.oid[0] + 1; /* Get length */ var->oid.oid[i++] = 1; @@ -1991,20 +1997,20 @@ send_resp ( intf, PDU_Header, Resp_Buf ); } -/* +/* * Utility to strip off any leading path information from a filename - * + * * Arguments: * path pathname to strip - * + * * Returns: * fname striped filename - * - */ + * + */ char * basename ( path ) - char *path; -{ + char *path; /* FIXME: caddr_t? */ +{ char *fname; if ( ( fname = (char *)strrchr ( path, '/' ) ) != NULL ) @@ -2036,7 +2042,7 @@ if ( foregnd ) { Log = stderr; } else { - if ( ( Log = fopen ( LOG_FILE, "a" ) ) == NULL ) + if ( ( Log = fopen ( LOG_FILE, "a" ) ) == NULL ) Log = NULL; } if ( Log ) { @@ -2098,9 +2104,9 @@ switch ( idx ) { case SYS_OBJID: var->type = ASN_OBJID; - bcopy ( (caddr_t)&Objids[MY_OBJID], - (caddr_t)&var->var.oval, - sizeof(Objid) ); + bcopy ( &Objids[MY_OBJID], + &var->var.oval, + sizeof(var->var.oval) ); break; case UPTIME_OBJID: var->type = ASN_TIMESTAMP; @@ -2152,9 +2158,9 @@ break; case ATMF_SYSID: var->type = ASN_OCTET; - var->var.sval[0] = 6; - bcopy ( (caddr_t)&Cfg[intf].acp_macaddr, - (caddr_t)&var->var.sval[1], 6 ); + var->var.sval[0] = sizeof(Cfg[intf].acp_macaddr); + bcopy ( &Cfg[intf].acp_macaddr, + &var->var.sval[1], sizeof(Cfg[intf].acp_macaddr) ); break; default: /* NO_SUCH */ @@ -2177,7 +2183,7 @@ { struct timeval tvp; fd_set rfd; - u_char buf[1024]; + char buf[1024]; Variable *var; int intf; int maxfd = 0; @@ -2238,7 +2244,7 @@ * ILMI_COLDSTART. */ /* atm_timeout() */ - + /* Enter new state */ ilmi_state[intf] = ILMI_INIT; /* fall into ILMI_INIT */ @@ -2252,37 +2258,37 @@ */ PDU_Header = build_generic_header(); - PDU_Header->head = (Variable *)malloc(sizeof(Variable)); + PDU_Header->head = malloc(sizeof(*PDU_Header->head)); if (PDU_Header->head == NULL) { - fprintf(stderr, "malloc() failed in %s()\n", __func__); + fprintf(stderr, "malloc() failed in %s() line %d\n", __func__, __LINE__); exit(1); } - bzero(PDU_Header->head, sizeof(Variable)); + bzero(PDU_Header->head, sizeof(*PDU_Header->head)); var = PDU_Header->head; - bcopy ( (caddr_t)&Objids[ADDRESS_OBJID], (caddr_t)&var->oid, - sizeof(Objid) ); + bcopy ( &Objids[ADDRESS_OBJID], &var->oid, + sizeof(var->oid) ); var->type = ASN_NULL; var->next = NULL; - + /* * Send GETNEXT request looking for empty ATM Address Table */ PDU_Header->reqid = Req_ID++; build_pdu ( PDU_Header, PDU_TYPE_GETNEXT ); send_resp ( intf, PDU_Header, Resp_Buf ); - + /* * Start a timeout while looking for SET message. If we don't receive * a SET, then go back to COLD_START state. */ /* atm_timeout() */ break; - + case ILMI_RUNNING: /* Normal SNMP processing */ break; - + default: break; } @@ -2295,8 +2301,8 @@ * Check for received messages */ if ( ilmi_fd[intf] > 0 && FD_ISSET ( ilmi_fd[intf], & rfd ) ) { - - n = read ( ilmi_fd[intf], (caddr_t)&buf[1], sizeof(buf) - 1 ); + + n = read ( ilmi_fd[intf], &buf[1], sizeof(buf) - 1 ); if ( n == -1 && ( errno == ECONNRESET || errno == EBADF ) ) { ilmi_state[intf] = ILMI_COLDSTART; close ( ilmi_fd[intf] ); @@ -2305,12 +2311,12 @@ if ( Log && Debug_Level > 1 ) fprintf ( Log, "***** state %d ***** read %d bytes from %d (%d) ***** %s *****\n", ilmi_state[intf], n, intf, ilmi_fd[intf], PDU_Types[buf[14] - 0xA0] ); { if ( Debug_Level > 2 ) - hexdump ( (caddr_t)&buf[1], n ); + hexdump ( &buf[1], n ); } bpp = (caddr_t)&buf[1]; if ( ( Hdr = asn_get_header ( &bpp ) ) == NULL ) continue; - + /* What we do with this messages depends upon the state we're in */ switch ( ilmi_state[intf] ) { case ILMI_COLDSTART: @@ -2325,9 +2331,9 @@ * Should be because the remote side is attempting * to verify that our table is empty */ - if ( oid_ncmp ( (caddr_t)&Hdr->head->oid, - (caddr_t)&Objids[ADDRESS_OBJID], - Objids[ADDRESS_OBJID].oid[0] ) == 0 ) { + if ( oid_ncmp ( &Hdr->head->oid, + &Objids[ADDRESS_OBJID], + Objids[ADDRESS_OBJID].oid[0] ) == 0 ) { if ( addressEntry[intf].oid[0] ) { /* XXX - FIXME */ /* Our table is not empty - return address */ @@ -2381,12 +2387,12 @@ break; case PDU_TYPE_SET: /* Look for SET_PREFIX Objid */ - if ( oid_ncmp ( (caddr_t)&Hdr->head->oid, - (caddr_t)&Objids[SETPFX_OBJID], - Objids[SETPFX_OBJID].oid[0] ) == 0 ) { + if ( oid_ncmp ( &Hdr->head->oid, + &Objids[SETPFX_OBJID], + Objids[SETPFX_OBJID].oid[0] ) == 0 ) { set_prefix ( &Hdr->head->oid, Hdr, intf ); /* Reply to SET before sending our ADDRESS */ - build_pdu(Hdr, PDU_TYPE_GETRESP); + build_pdu( Hdr, PDU_TYPE_GETRESP ); send_resp( intf, Hdr, Resp_Buf ); set_address ( Hdr, intf ); } else { @@ -2422,9 +2428,9 @@ break; case PDU_TYPE_SET: /* Look for SET_PREFIX Objid */ - if ( oid_ncmp ( (caddr_t)&Hdr->head->oid, - (caddr_t)&Objids[SETPFX_OBJID], - Objids[SETPFX_OBJID].oid[0] ) == 0 ) { + if ( oid_ncmp ( &Hdr->head->oid, + &Objids[SETPFX_OBJID], + Objids[SETPFX_OBJID].oid[0] ) == 0 ) { set_prefix ( &Hdr->head->oid, Hdr, intf ); /* Reply to SET before sending our ADDRESS */ build_pdu(Hdr, PDU_TYPE_GETRESP); --------------040307000007060305040603-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3E60F1CF.2030400>