]> err.no Git - varnish/commitdiff
Introduce the TRUST_ME() macro for voilating the C compilers pointer
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 16 Jan 2008 11:34:28 +0000 (11:34 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 16 Jan 2008 11:34:28 +0000 (11:34 +0000)
sensibilities.  If only they had done const right...

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2348 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_http.c
varnish-cache/bin/varnishd/cache_pool.c
varnish-cache/bin/varnishd/common.h
varnish-cache/bin/varnishd/shmlog.c

index 6d1b0e3bed9e8f2c62f6ec91bd3eb98dde9f0d42..256966c39ba92324b2e5436ee00118a2db86ad44 100644 (file)
@@ -522,8 +522,8 @@ http_SetH(struct http *to, unsigned n, const char *fm)
 
        assert(n < HTTP_HDR_MAX);
        AN(fm);
-       to->hd[n].b = (void*)(uintptr_t)fm;
-       to->hd[n].e = (void*)(uintptr_t)strchr(fm, '\0');
+       to->hd[n].b = TRUST_ME(fm);
+       to->hd[n].e = strchr(to->hd[n].b, '\0');
        to->hdf[n] = 0;
 }
 
index dba99507c90fae4eec56e6b2a9b1d64cb88b8083..8894ca7313bbf1362549c798246c5880ffe60419 100644 (file)
@@ -135,7 +135,7 @@ WRK_Write(struct worker *w, const void *ptr, int len)
                len = strlen(ptr);
        if (w->niov == MAX_IOVS)
                (void)WRK_Flush(w);
-       w->iov[w->niov].iov_base = (void*)(uintptr_t)ptr;
+       w->iov[w->niov].iov_base = TRUST_ME(ptr);
        w->iov[w->niov].iov_len = len;
        w->liov += len;
        w->niov++;
index 43fd2fbce14aa79f1f9237b4735ddeb956c089a5..dc5f48bfe4e0bfc66c8dfa6b4413e791e4df264d 100644 (file)
@@ -44,3 +44,5 @@ extern struct varnish_stats *VSL_stats;
 void TCP_name(const struct sockaddr *addr, unsigned l, char *abuf, unsigned alen, char *pbuf, unsigned plen);
 void TCP_myname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen);
 int TCP_filter_http(int sock);
+
+#define TRUST_ME(ptr)  ((void*)(uintptr_t)(ptr))
index 05ea8844f6d0698b063e9adc32c71ad5c520cf59..7799d2bd18ce5ccec99f200cbaefc34a4449fa74 100644 (file)
@@ -77,7 +77,7 @@ vsl_wrap(void)
 }
 
 static void
-vsl_hdr(enum shmlogtag tag, unsigned char *p, unsigned len, int id)
+vsl_hdr(enum shmlogtag tag, unsigned char *p, unsigned len, unsigned id)
 {
 
        p[__SHMLOG_LEN_HIGH] = (len >> 8) & 0xff;
@@ -142,8 +142,8 @@ VSL(enum shmlogtag tag, int id, const char *fmt, ...)
        va_start(ap, fmt);
 
        if (strchr(fmt, '%') == NULL) {
-               t.b = (void*)(uintptr_t)fmt;
-               t.e = strchr(fmt, '\0');
+               t.b = TRUST_ME(fmt);
+               t.e = strchr(t.b, '\0');
                VSLR(tag, id, t);
        } else {
                LOCKSHM(&vsl_mtx);
@@ -239,8 +239,8 @@ WSL(struct worker *w, enum shmlogtag tag, int id, const char *fmt, ...)
        va_start(ap, fmt);
 
        if (strchr(fmt, '%') == NULL) {
-               t.b = (void*)(uintptr_t)fmt;
-               t.e = strchr(fmt, '\0');
+               t.b = TRUST_ME(fmt);
+               t.e = strchr(t.b, '\0');
                WSLR(w, tag, id, t);
        } else {
                assert(w->wlp < w->wle);