Skip to content

Commit

Permalink
Remove obsolete caddr_t (#1362)
Browse files Browse the repository at this point in the history
  • Loading branch information
yadij authored and squid-anubis committed May 23, 2023
1 parent 1520f3a commit 834fddb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 29 deletions.
2 changes: 0 additions & 2 deletions compat/os/mswindows.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,6 @@ struct timezone {

#include <io.h>

typedef char * caddr_t;

#ifndef _PATH_DEVNULL
#define _PATH_DEVNULL "NUL"
#endif
Expand Down
41 changes: 20 additions & 21 deletions lib/radix.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ static char *rn_zeros, *rn_ones;
#define rm_leaf rm_rmu.rmu_leaf /* extra field would make 32 bytes */

/* Helper macros */
#define squid_Bcmp(a, b, l) (l == 0 ? 0 : memcmp((caddr_t)(a), (caddr_t)(b), (u_long)l))
#define squid_R_Malloc(p, t, n) (p = (t) xmalloc((unsigned int)(n)))
#define squid_Free(p) xfree((char *)p)
#define squid_MKGet(m) {\
Expand Down Expand Up @@ -151,7 +150,7 @@ static char *rn_zeros, *rn_ones;
struct squid_radix_node *
squid_rn_search(void *v_arg, struct squid_radix_node *head) {
register struct squid_radix_node *x;
register caddr_t v;
register char *v;

for (x = head, v = v_arg; x->rn_b >= 0;) {
if (x->rn_bmask & v[x->rn_off])
Expand All @@ -165,7 +164,7 @@ squid_rn_search(void *v_arg, struct squid_radix_node *head) {
struct squid_radix_node *
squid_rn_search_m(void *v_arg, struct squid_radix_node *head, void *m_arg) {
register struct squid_radix_node *x;
register caddr_t v = v_arg, m = m_arg;
register char *v = v_arg, *m = m_arg;

for (x = head; x->rn_b >= 0;) {
if ((x->rn_bmask & m[x->rn_off]) &&
Expand All @@ -180,8 +179,8 @@ squid_rn_search_m(void *v_arg, struct squid_radix_node *head, void *m_arg) {
int
squid_rn_refines(void *m_arg, void *n_arg)
{
register caddr_t m = m_arg, n = n_arg;
register caddr_t lim, lim2 = lim = n + *(u_char *) n;
register char *m = m_arg, *n = n_arg;
register char *lim, *lim2 = lim = n + *(u_char *) n;
int longer = (*(u_char *) n++) - (int) (*(u_char *) m++);
int masks_are_equal = 1;

Expand All @@ -206,7 +205,7 @@ squid_rn_refines(void *m_arg, void *n_arg)
struct squid_radix_node *
squid_rn_lookup(void *v_arg, void *m_arg, struct squid_radix_node_head *head) {
register struct squid_radix_node *x;
caddr_t netmask = 0;
char *netmask = NULL;

if (m_arg) {
if ((x = squid_rn_addmask(m_arg, 1, head->rnh_treetop->rn_off)) == 0)
Expand Down Expand Up @@ -243,10 +242,10 @@ rn_satsifies_leaf(char *trial, register struct squid_radix_node *leaf, int skip)

struct squid_radix_node *
squid_rn_match(void *v_arg, struct squid_radix_node_head *head) {
caddr_t v = v_arg;
char *v = v_arg;
register struct squid_radix_node *t = head->rnh_treetop, *x;
register caddr_t cp = v, cp2;
caddr_t cplim;
register char *cp = v, *cp2;
char *cplim;
struct squid_radix_node *saved_t, *top = t;
int off = t->rn_off, vlen = *(u_char *) cp, matched_off;
register int test, b, rn_b;
Expand Down Expand Up @@ -348,28 +347,28 @@ squid_rn_newpair(void *v, int b, struct squid_radix_node nodes[2]) {
t->rn_l = tt;
t->rn_off = b >> 3;
tt->rn_b = -1;
tt->rn_key = (caddr_t) v;
tt->rn_key = (char *) v;
tt->rn_p = t;
tt->rn_flags = t->rn_flags = RNF_ACTIVE;
return t;
}

struct squid_radix_node *
squid_rn_insert(void *v_arg, struct squid_radix_node_head *head, int *dupentry, struct squid_radix_node nodes[2]) {
caddr_t v = v_arg;
char *v = v_arg;
struct squid_radix_node *top = head->rnh_treetop;
int head_off = top->rn_off, vlen = (int) *((u_char *) v);
register struct squid_radix_node *t = squid_rn_search(v_arg, top);
register caddr_t cp = v + head_off;
register char *cp = v + head_off;
register int b;
struct squid_radix_node *tt;
/*
* Find first bit at which v and t->rn_key differ
*/
{
register caddr_t cp2 = t->rn_key + head_off;
register char *cp2 = t->rn_key + head_off;
register int cmp_res;
caddr_t cplim = v + vlen;
char *cplim = v + vlen;

while (cp < cplim)
if (*cp2++ != *cp++)
Expand Down Expand Up @@ -412,9 +411,9 @@ squid_rn_insert(void *v_arg, struct squid_radix_node_head *head, int *dupentry,

struct squid_radix_node *
squid_rn_addmask(void *n_arg, int search, int skip) {
caddr_t netmask = (caddr_t) n_arg;
char *netmask = (char *) n_arg;
register struct squid_radix_node *x;
register caddr_t cp, cplim;
register char *cp, *cplim;
register int b = 0, mlen, j;
int maskduplicated, m0, isnormal;
struct squid_radix_node *saved_x;
Expand Down Expand Up @@ -453,7 +452,7 @@ squid_rn_addmask(void *n_arg, int search, int skip) {
if ((saved_x = x) == 0)
return (0);
memset(x, '\0', squid_max_keylen + 2 * sizeof(*x));
netmask = cp = (caddr_t) (x + 2);
netmask = cp = (char *) (x + 2);
memcpy(cp, addmask_key, mlen);
x = squid_rn_insert(cp, squid_mask_rnhead, &maskduplicated, x);
if (maskduplicated) {
Expand Down Expand Up @@ -518,12 +517,12 @@ rn_new_radix_mask(struct squid_radix_node *tt, struct squid_radix_mask *next) {

struct squid_radix_node *
squid_rn_addroute(void *v_arg, void *n_arg, struct squid_radix_node_head *head, struct squid_radix_node treenodes[2]) {
caddr_t v = (caddr_t) v_arg, netmask = (caddr_t) n_arg;
char *v = (char *) v_arg, *netmask = (char *) n_arg;
register struct squid_radix_node *t, *x = NULL, *tt;
struct squid_radix_node *saved_tt, *top = head->rnh_treetop;
short b = 0, b_leaf = 0;
int keyduplicated;
caddr_t mmask;
char *mmask;
struct squid_radix_mask *m, **mp;

/*
Expand Down Expand Up @@ -583,7 +582,7 @@ squid_rn_addroute(void *v_arg, void *n_arg, struct squid_radix_node_head *head,
tt->rn_dupedkey = t->rn_dupedkey;
t->rn_dupedkey = tt;
}
tt->rn_key = (caddr_t) v;
tt->rn_key = (char *) v;
tt->rn_b = -1;
tt->rn_flags = RNF_ACTIVE;
}
Expand Down Expand Up @@ -666,7 +665,7 @@ squid_rn_delete(void *v_arg, void *netmask_arg, struct squid_radix_node_head *he
register struct squid_radix_node *t, *p, *x, *tt;
struct squid_radix_mask *m, *saved_m, **mp;
struct squid_radix_node *dupedkey, *saved_tt, *top;
caddr_t v, netmask;
char *v, *netmask;
int b, head_off, vlen;

v = v_arg;
Expand Down
10 changes: 4 additions & 6 deletions tools/purge/copyout.cc
Original file line number Diff line number Diff line change
Expand Up @@ -252,17 +252,15 @@ copy_out( size_t filesize, size_t metasize, unsigned debug,
}

// create source mmap to copy from (mmap complete file)
caddr_t src = (caddr_t) mmap( nullptr, filesize, PROT_READ,
MAP_FILE | MAP_SHARED, input, 0 );
if ( src == (caddr_t) -1 ) {
const auto src = static_cast<char *>(mmap(nullptr, filesize, PROT_READ, MAP_FILE | MAP_SHARED, input, 0));
if (src == reinterpret_cast<const char *>(-1)) {
perror( "mmap input" );
BAUTZ(false);
}

// create destination mmap to copy into (mmap data portion)
caddr_t dst = (caddr_t) mmap( nullptr, filesize-metasize, PROT_READ | PROT_WRITE,
MAP_FILE | MAP_SHARED, out, 0 );
if ( dst == (caddr_t) -1 ) {
auto dst = static_cast<char *>(mmap(nullptr, filesize-metasize, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, out, 0));
if (dst == reinterpret_cast<char *>(-1)) {
perror( "mmap output" );
munmap( src, filesize );
BAUTZ(false);
Expand Down

0 comments on commit 834fddb

Please sign in to comment.