From: hno <> Date: Mon, 14 Oct 2002 05:48:23 +0000 (+0000) Subject: Blunt search/replace and typecasting to get rid of some silly C->C++ errors X-Git-Tag: SQUID_3_0_PRE1~671 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dfb22746f7751269845dddcd600f4d7e54722f8d;p=thirdparty%2Fsquid.git Blunt search/replace and typecasting to get rid of some silly C->C++ errors in delay_pools and ARP acl code. --- diff --git a/src/acl.cc b/src/acl.cc index 0bb0e1aac9..1a40b829f8 100644 --- a/src/acl.cc +++ b/src/acl.cc @@ -1,5 +1,5 @@ /* - * $Id: acl.cc,v 1.289 2002/10/13 20:34:57 robertc Exp $ + * $Id: acl.cc,v 1.290 2002/10/13 23:48:23 hno Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -2616,7 +2616,7 @@ static acl_arp_data * aclParseArpData(const char *t) { LOCAL_ARRAY(char, eth, 256); - acl_arp_data *q = xcalloc(1, sizeof(acl_arp_data)); + acl_arp_data *q = (acl_arp_data *)xcalloc(1, sizeof(acl_arp_data)); debug(28, 5) ("aclParseArpData: %s\n", t); if (sscanf(t, "%[0-9a-fA-F:]", eth) != 1) { debug(28, 0) ("aclParseArpData: Bad ethernet address: '%s'\n", t); @@ -2641,7 +2641,7 @@ static void aclParseArpList(void *curlist) { char *t = NULL; - splayNode **Top = curlist; + splayNode **Top = (splayNode **)curlist; acl_arp_data *q = NULL; while ((t = strtokFile())) { if ((q = aclParseArpData(t)) == NULL) @@ -2663,7 +2663,7 @@ aclMatchArp(void *dataptr, struct in_addr c) struct ifconf ifc; struct ifreq *ifr; int offset; - splayNode **Top = dataptr; + splayNode **Top = (splayNode **)dataptr; /* * The linux kernel 2.2 maintains per interface ARP caches and * thus requires an interface name when doing ARP queries. @@ -2701,13 +2701,13 @@ aclMatchArp(void *dataptr, struct in_addr c) } /* lookup list of interface names */ ifc.ifc_len = sizeof(ifbuffer); - ifc.ifc_buf = ifbuffer; + ifc.ifc_buf = (char *)ifbuffer; if (ioctl(HttpSockets[0], SIOCGIFCONF, &ifc) < 0) { debug(28, 1) ("Attempt to retrieve interface list failed: %s\n", xstrerror()); return 0; } - if (ifc.ifc_len > sizeof(ifbuffer)) { + if (ifc.ifc_len > (int)sizeof(ifbuffer)) { debug(28, 1) ("Interface list too long - %d\n", ifc.ifc_len); return 0; } @@ -2821,8 +2821,8 @@ static int aclArpCompare(const void *a, const void *b) { #if defined(_SQUID_LINUX_) - const unsigned short *d1 = a; - const unsigned short *d2 = b; + const unsigned short *d1 = (const unsigned short *)a; + const unsigned short *d2 = (const unsigned short *)b; if (d1[0] != d2[0]) return (d1[0] > d2[0]) ? 1 : -1; if (d1[1] != d2[1]) @@ -2830,8 +2830,8 @@ aclArpCompare(const void *a, const void *b) if (d1[2] != d2[2]) return (d1[2] > d2[2]) ? 1 : -1; #elif defined(_SQUID_SOLARIS_) - const unsigned char *d1 = a; - const unsigned char *d2 = b; + const unsigned char *d1 = (const unsigned char *)a; + const unsigned char *d2 = (const unsigned char *)b; if (d1[0] != d2[0]) return (d1[0] > d2[0]) ? 1 : -1; if (d1[1] != d2[1]) @@ -2902,22 +2902,19 @@ checkARP(u_long ip, char *eth) static void aclDumpArpListWalkee(void *node, void *state) { - acl_arp_data *arp = node; - wordlist **W = state; + acl_arp_data *arp = (acl_arp_data *)node; static char buf[24]; - while (*W != NULL) - W = &(*W)->next; snprintf(buf, sizeof(buf), "%02x:%02x:%02x:%02x:%02x:%02x", arp->eth[0], arp->eth[1], arp->eth[2], arp->eth[3], arp->eth[4], arp->eth[5]); - wordlistAdd(state, buf); + wordlistAdd((wordlist **)state, buf); } static wordlist * aclDumpArpList(void *data) { wordlist *w = NULL; - splay_walk(data, aclDumpArpListWalkee, &w); + splay_walk((splayNode *)data, aclDumpArpListWalkee, &w); return w; } diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 9f5dbb2be6..391c0993cc 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.cc,v 1.417 2002/10/13 20:34:58 robertc Exp $ + * $Id: cache_cf.cc,v 1.418 2002/10/13 23:48:23 hno Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -819,14 +819,14 @@ free_delay_pool_count(delayConfig * cfg) if (!cfg->pools) return; for (i = 0; i < cfg->pools; i++) { - if (cfg->class[i]) { + if (cfg->delay_class[i]) { delayFreeDelayPool(i); safe_free(cfg->rates[i]); } aclDestroyAccessList(&cfg->access[i]); } delayFreeDelayData(cfg->pools); - xfree(cfg->class); + xfree(cfg->delay_class); xfree(cfg->rates); xfree(cfg->access); memset(cfg, 0, sizeof(*cfg)); @@ -874,7 +874,7 @@ parse_delay_pool_count(delayConfig * cfg) parse_ushort(&cfg->pools); if (cfg->pools) { delayInitDelayData(cfg->pools); - cfg->class = xcalloc(cfg->pools, sizeof(u_char)); + cfg->delay_class = xcalloc(cfg->pools, sizeof(u_char)); cfg->rates = xcalloc(cfg->pools, sizeof(delaySpecSet *)); cfg->access = xcalloc(cfg->pools, sizeof(acl_access *)); } @@ -896,16 +896,16 @@ parse_delay_pool_class(delayConfig * cfg) return; } pool--; - if (cfg->class[pool]) { + if (cfg->delay_class[pool]) { delayFreeDelayPool(pool); safe_free(cfg->rates[pool]); } cfg->rates[pool] = xmalloc(class * sizeof(delaySpec)); - cfg->class[pool] = class; + cfg->delay_class[pool] = class; cfg->rates[pool]->aggregate.restore_bps = cfg->rates[pool]->aggregate.max_bytes = -1; - if (cfg->class[pool] >= 3) + if (cfg->delay_class[pool] >= 3) cfg->rates[pool]->network.restore_bps = cfg->rates[pool]->network.max_bytes = -1; - if (cfg->class[pool] >= 2) + if (cfg->delay_class[pool] >= 2) cfg->rates[pool]->individual.restore_bps = cfg->rates[pool]->individual.max_bytes = -1; delayCreateDelayPool(pool, class); } @@ -924,7 +924,7 @@ parse_delay_pool_rates(delayConfig * cfg) return; } pool--; - class = cfg->class[pool]; + class = cfg->delay_class[pool]; if (class == 0) { debug(3, 0) ("parse_delay_pool_rates: Ignoring pool %d attempt to set rates with class not set\n", pool + 1); return; @@ -942,7 +942,7 @@ parse_delay_pool_rates(delayConfig * cfg) ptr->max_bytes = i; ptr++; } - class = cfg->class[pool]; + class = cfg->delay_class[pool]; /* if class is 3, swap around network and individual */ if (class == 3) { delaySpec tmp; diff --git a/src/delay_pools.cc b/src/delay_pools.cc index 6698e24e2e..2ec830e628 100644 --- a/src/delay_pools.cc +++ b/src/delay_pools.cc @@ -1,6 +1,6 @@ /* - * $Id: delay_pools.cc,v 1.26 2002/09/24 21:29:31 robertc Exp $ + * $Id: delay_pools.cc,v 1.27 2002/10/13 23:48:24 hno Exp $ * * DEBUG: section 77 Delay Pools * AUTHOR: David Luyer @@ -40,14 +40,14 @@ #include "StoreClient.h" struct _class1DelayPool { - int class; + int delay_class; int aggregate; }; #define IND_MAP_SZ 256 struct _class2DelayPool { - int class; + int delay_class; int aggregate; /* OK: -1 is terminator. individual[255] is always host 255. */ /* 255 entries + 1 terminator byte */ @@ -61,7 +61,7 @@ struct _class2DelayPool { #define C3_IND_SZ (NET_MAP_SZ*IND_MAP_SZ) struct _class3DelayPool { - int class; + int delay_class; int aggregate; /* OK: -1 is terminator. network[255] is always host 255. */ /* 255 entries + 1 terminator byte */ @@ -207,22 +207,22 @@ delayUnregisterDelayIdPtr(delay_id * loc) } void -delayCreateDelayPool(unsigned short pool, u_char class) +delayCreateDelayPool(unsigned short pool, u_char delay_class) { - switch (class) { + switch (delay_class) { case 1: delay_data[pool].class1 = xmalloc(sizeof(class1DelayPool)); - delay_data[pool].class1->class = 1; + delay_data[pool].class1->delay_class = 1; memory_used += sizeof(class1DelayPool); break; case 2: delay_data[pool].class2 = xmalloc(sizeof(class2DelayPool)); - delay_data[pool].class1->class = 2; + delay_data[pool].class1->delay_class = 2; memory_used += sizeof(class2DelayPool); break; case 3: delay_data[pool].class3 = xmalloc(sizeof(class3DelayPool)); - delay_data[pool].class1->class = 3; + delay_data[pool].class1->delay_class = 3; memory_used += sizeof(class3DelayPool); break; default: @@ -231,12 +231,12 @@ delayCreateDelayPool(unsigned short pool, u_char class) } void -delayInitDelayPool(unsigned short pool, u_char class, delaySpecSet * rates) +delayInitDelayPool(unsigned short pool, u_char delay_class, delaySpecSet * rates) { /* delaySetSpec may be pointer to partial structure so MUST pass by * reference. */ - switch (class) { + switch (delay_class) { case 1: delay_data[pool].class1->aggregate = (int) (((double) rates->aggregate.max_bytes * Config.Delay.initial) / 100); @@ -264,7 +264,7 @@ void delayFreeDelayPool(unsigned short pool) { /* this is a union - and all free() cares about is the pointer location */ - switch (delay_data[pool].class1->class) { + switch (delay_data[pool].class1->delay_class) { case 1: memory_used -= sizeof(class1DelayPool); break; @@ -276,7 +276,7 @@ delayFreeDelayPool(unsigned short pool) break; default: debug(77, 1) ("delayFreeDelayPool: bad class %d\n", - delay_data[pool].class1->class); + delay_data[pool].class1->delay_class); } safe_free(delay_data[pool].class1); } @@ -314,7 +314,7 @@ delayClient(clientHttpRequest * http) int j; unsigned int host; unsigned short pool, position; - unsigned char class, net; + unsigned char delay_class, net; assert(http); r = http->request; @@ -334,12 +334,12 @@ delayClient(clientHttpRequest * http) } if (pool == Config.Delay.pools) return delayId(0, 0); - class = Config.Delay.class[pool]; - if (class == 0) + delay_class = Config.Delay.delay_class[pool]; + if (delay_class == 0) return delayId(0, 0); - if (class == 1) + if (delay_class == 1) return delayId(pool + 1, 0); - if (class == 2) { + if (delay_class == 2) { host = ntohl(ch.src_addr.s_addr) & 0xff; if (host == 255) { if (!delay_data[pool].class2->individual_255_used) { @@ -539,7 +539,7 @@ delayPoolsUpdate(void *unused) { int incr = squid_curtime - delay_pools_last_update; unsigned short i; - unsigned char class; + unsigned char delay_class; if (!Config.Delay.pools) return; eventAdd("delayPoolsUpdate", delayPoolsUpdate, NULL, 1.0, 1); @@ -547,10 +547,10 @@ delayPoolsUpdate(void *unused) return; delay_pools_last_update = squid_curtime; for (i = 0; i < Config.Delay.pools; i++) { - class = Config.Delay.class[i]; - if (!class) + delay_class = Config.Delay.delay_class[i]; + if (!delay_class) continue; - switch (class) { + switch (delay_class) { case 1: delayUpdateClass1(delay_data[i].class1, Config.Delay.rates[i], incr); break; @@ -575,10 +575,10 @@ delayBytesWanted(delay_id d, int min, int max) { unsigned short position = d & 0xFFFF; unsigned short pool = (d >> 16) - 1; - unsigned char class = (pool == 0xFFFF) ? 0 : Config.Delay.class[pool]; + unsigned char delay_class = (pool == 0xFFFF) ? 0 : Config.Delay.delay_class[pool]; int nbytes = max; - switch (class) { + switch (delay_class) { case 0: break; @@ -604,7 +604,7 @@ delayBytesWanted(delay_id d, int min, int max) break; default: - fatalf("delayBytesWanted: Invalid class %d\n", class); + fatalf("delayBytesWanted: Invalid class %d\n", delay_class); break; } nbytes = XMAX(min, nbytes); @@ -621,12 +621,12 @@ delayBytesIn(delay_id d, int qty) { unsigned short position = d & 0xFFFF; unsigned short pool = (d >> 16) - 1; - unsigned char class; + unsigned char delay_class; if (pool == 0xFFFF) return; - class = Config.Delay.class[pool]; - switch (class) { + delay_class = Config.Delay.delay_class[pool]; + switch (delay_class) { case 1: delay_data[pool].class1->aggregate -= qty; return; @@ -640,7 +640,7 @@ delayBytesIn(delay_id d, int qty) delay_data[pool].class3->individual[position] -= qty; return; } - fatalf("delayBytesWanted: Invalid class %d\n", class); + fatalf("delayBytesWanted: Invalid class %d\n", delay_class); assert(0); } @@ -841,7 +841,7 @@ delayPoolStats(StoreEntry * sentry) storeAppendPrintf(sentry, "Delay pools configured: %d\n\n", Config.Delay.pools); for (i = 0; i < Config.Delay.pools; i++) { - switch (Config.Delay.class[i]) { + switch (Config.Delay.delay_class[i]) { case 0: storeAppendPrintf(sentry, "Pool: %d\n\tClass: 0\n\n", i + 1); storeAppendPrintf(sentry, "\tMisconfigured pool.\n\n"); diff --git a/src/protos.h b/src/protos.h index 38ab57f7ee..743f0670cd 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.452 2002/10/13 20:35:03 robertc Exp $ + * $Id: protos.h,v 1.453 2002/10/13 23:48:24 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1137,8 +1137,8 @@ SQUIDCEXTERN peer *carpSelectParent(request_t *); SQUIDCEXTERN void delayPoolsInit(void); SQUIDCEXTERN void delayInitDelayData(unsigned short pools); SQUIDCEXTERN void delayFreeDelayData(unsigned short pools); -SQUIDCEXTERN void delayCreateDelayPool(unsigned short pool, u_char class); -SQUIDCEXTERN void delayInitDelayPool(unsigned short pool, u_char class, delaySpecSet * rates); +SQUIDCEXTERN void delayCreateDelayPool(unsigned short pool, u_char delay_class); +SQUIDCEXTERN void delayInitDelayPool(unsigned short pool, u_char delay_class, delaySpecSet * rates); SQUIDCEXTERN void delayFreeDelayPool(unsigned short pool); SQUIDCEXTERN void delayPoolsReconfigure(void); SQUIDCEXTERN void delaySetNoDelay(int fd); diff --git a/src/structs.h b/src/structs.h index 2fb3b6e28a..805757e9b9 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.433 2002/10/13 20:35:05 robertc Exp $ + * $Id: structs.h,v 1.434 2002/10/13 23:48:24 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -260,7 +260,7 @@ struct _delaySpecSet { struct _delayConfig { unsigned short pools; unsigned short initial; - unsigned char *class; + unsigned char *delay_class; delaySpecSet **rates; acl_access **access; };