Commit adf857b8 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Various flexelint inspired cleanups



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4582 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent f709639d
...@@ -695,10 +695,10 @@ struct vsb *SMS_Makesynth(struct object *obj); ...@@ -695,10 +695,10 @@ struct vsb *SMS_Makesynth(struct object *obj);
void SMS_Finish(struct object *obj); void SMS_Finish(struct object *obj);
/* storage_persistent.c */ /* storage_persistent.c */
void SMP_Fixup(struct sess *sp, struct objhead *oh, struct objcore *oc); void SMP_Fixup(struct sess *sp, const struct objhead *oh, struct objcore *oc);
void SMP_BANchanged(const struct object *o, double t); void SMP_BANchanged(const struct object *o, double t);
void SMP_TTLchanged(const struct object *o); void SMP_TTLchanged(const struct object *o);
void SMP_FreeObj(struct object *o); void SMP_FreeObj(const struct object *o);
void SMP_Ready(void); void SMP_Ready(void);
void SMP_NewBan(double t0, const char *ban); void SMP_NewBan(double t0, const char *ban);
......
...@@ -279,7 +279,10 @@ pan_backtrace(void) ...@@ -279,7 +279,10 @@ pan_backtrace(void)
if (Symbol_Lookup(vsp, array[i]) < 0) { if (Symbol_Lookup(vsp, array[i]) < 0) {
char **strings; char **strings;
strings = backtrace_symbols(&array[i], 1); strings = backtrace_symbols(&array[i], 1);
vsb_printf(vsp, "%p: %s", array[i], strings[0]); if (strings != NULL && strings[0] != NULL)
vsb_printf(vsp, "%p: %s", array[i], strings[0]);
else
vsb_printf(vsp, "%p: (?)", array[i]);
} }
vsb_printf (vsp, "\n"); vsb_printf (vsp, "\n");
} }
......
...@@ -212,13 +212,13 @@ static void * ...@@ -212,13 +212,13 @@ static void *
wrk_thread(void *priv) wrk_thread(void *priv)
{ {
struct wq *qp; struct wq *qp;
volatile unsigned nhttp; unsigned nhttp;
unsigned siov; unsigned siov;
CAST_OBJ_NOTNULL(qp, priv, WQ_MAGIC); CAST_OBJ_NOTNULL(qp, priv, WQ_MAGIC);
/* We need to snapshot these two for consistency */ /* We need to snapshot these two for consistency */
nhttp = params->http_headers; nhttp = params->http_headers;
siov = nhttp * 2; /* XXX param ? */ siov = nhttp * 2;
if (siov > IOV_MAX) if (siov > IOV_MAX)
siov = IOV_MAX; siov = IOV_MAX;
return (wrk_thread_real(qp, return (wrk_thread_real(qp,
......
...@@ -201,6 +201,9 @@ ...@@ -201,6 +201,9 @@
-efunc(539, http_FilterFields) // Positive indentation from line -efunc(539, http_FilterFields) // Positive indentation from line
-efunc(539, http_EstimateWS) // Positive indentation from line -efunc(539, http_EstimateWS) // Positive indentation from line
-esym(525, __builtin_frame_address) // Not defined
-esym(525, __builtin_return_address) // Not defined
// cache_vcl.c // cache_vcl.c
-efunc(525, vcl_handlingname) // Negative indentation from line -efunc(525, vcl_handlingname) // Negative indentation from line
-esym(528, vcl_handlingname) // Not referenced -esym(528, vcl_handlingname) // Not referenced
......
...@@ -199,6 +199,10 @@ struct params { ...@@ -199,6 +199,10 @@ struct params {
unsigned syslog_cli_traffic; unsigned syslog_cli_traffic;
}; };
/*
* We declare this a volatile pointer, so that reads of parameters
* become atomic, leaving the CLI thread lattitude to change the values
*/
extern volatile struct params *params; extern volatile struct params *params;
extern struct heritage heritage; extern struct heritage heritage;
......
...@@ -648,7 +648,7 @@ smp_save_segs(struct smp_sc *sc) ...@@ -648,7 +648,7 @@ smp_save_segs(struct smp_sc *sc)
*/ */
void void
SMP_Fixup(struct sess *sp, struct objhead *oh, struct objcore *oc) SMP_Fixup(struct sess *sp, const struct objhead *oh, struct objcore *oc)
{ {
struct smp_seg *sg; struct smp_seg *sg;
struct smp_object *so; struct smp_object *so;
...@@ -785,7 +785,7 @@ smp_open_bans(struct smp_sc *sc, struct smp_signctx *ctx) ...@@ -785,7 +785,7 @@ smp_open_bans(struct smp_sc *sc, struct smp_signctx *ctx)
*/ */
void void
SMP_FreeObj(struct object *o) SMP_FreeObj(const struct object *o)
{ {
struct smp_seg *sg; struct smp_seg *sg;
......
...@@ -137,5 +137,4 @@ struct smp_object { ...@@ -137,5 +137,4 @@ struct smp_object {
double ttl; double ttl;
double ban; double ban;
struct object *ptr; struct object *ptr;
uint64_t len; /* XXX: madvise */
}; };
...@@ -50,7 +50,6 @@ struct vev { ...@@ -50,7 +50,6 @@ struct vev {
#define EV_WR POLLOUT #define EV_WR POLLOUT
#define EV_ERR POLLERR #define EV_ERR POLLERR
#define EV_HUP POLLHUP #define EV_HUP POLLHUP
#define EV_GONE POLLNVAL
#define EV_SIG -1 #define EV_SIG -1
int sig; int sig;
unsigned sig_flags; unsigned sig_flags;
......
...@@ -45,97 +45,88 @@ SVNID("$Id: execinfo.c,v 1.3 2004/07/19 05:21:09 sobomax Exp $") ...@@ -45,97 +45,88 @@ SVNID("$Id: execinfo.c,v 1.3 2004/07/19 05:21:09 sobomax Exp $")
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
static void *getreturnaddr(int); static void *getreturnaddr(int);
static void *getframeaddr(int); static void *getframeaddr(int);
#define D10(x) ceil(log10(((x) == 0) ? 2 : ((x) + 1)))
inline static void *
realloc_safe(void *ptr, size_t size)
{
void *nptr;
nptr = realloc(ptr, size);
if (nptr == NULL)
free(ptr);
return nptr;
}
int int
backtrace(void **buffer, int size) backtrace(void **buffer, int size)
{ {
int i; int i;
for (i = 1; getframeaddr(i + 1) != NULL && i != size + 1; i++) {
buffer[i - 1] = getreturnaddr(i);
if (buffer[i - 1] == NULL)
break;
}
return i - 1; for (i = 1; getframeaddr(i + 1) != NULL && i != size + 1; i++) {
buffer[i - 1] = getreturnaddr(i);
if (buffer[i - 1] == NULL)
break;
}
return (i - 1);
} }
/*
* XXX: This implementation should be changed to a much more conservative
* XXX: memory strategy: Allocate 4k up front, realloc 4K more as needed.
*/
char ** char **
backtrace_symbols(void *const *buffer, int size) backtrace_symbols(void *const *buffer, int size)
{ {
size_t clen, alen; size_t clen, alen;
int i; int i;
char **rval; char **rval;
clen = size * sizeof(char *); clen = size * sizeof(char *);
rval = malloc(clen); rval = malloc(clen);
if (rval == NULL) if (rval == NULL)
return NULL; return (NULL);
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
#ifdef HAVE_DLADDR #ifdef HAVE_DLADDR
{ {
Dl_info info; Dl_info info;
int offset; int offset;
if (dladdr(buffer[i], &info) != 0) { if (dladdr(buffer[i], &info) != 0) {
if (info.dli_sname == NULL) if (info.dli_sname == NULL)
info.dli_sname = "???"; info.dli_sname = "?";
if (info.dli_saddr == NULL) if (info.dli_saddr == NULL)
info.dli_saddr = buffer[i]; info.dli_saddr = buffer[i];
offset = (const char*)buffer[i] - (const char*)info.dli_saddr; offset = (const char*)buffer[i] -
/* "0x01234567 <function+offset> at filename" */ (const char*)info.dli_saddr;
alen = 2 + /* "0x" */ /* "0x01234567 <function+offset> at filename" */
(sizeof(void *) * 2) + /* "01234567" */ alen = 2 + /* "0x" */
2 + /* " <" */ (sizeof(void *) * 2) + /* "01234567" */
strlen(info.dli_sname) + /* "function" */ 2 + /* " <" */
1 + /* "+" */ strlen(info.dli_sname) + /* "function" */
10 + /* "offset */ 1 + /* "+" */
5 + /* "> at " */ 10 + /* "offset */
strlen(info.dli_fname) + /* "filename" */ 5 + /* "> at " */
1; /* "\0" */ strlen(info.dli_fname) + /* "filename" */
rval = realloc_safe(rval, clen + alen); 1; /* "\0" */
if (rval == NULL) rval = realloc(rval, clen + alen);
return NULL; if (rval == NULL)
snprintf((char *) rval + clen, alen, "%p <%s+%d> at %s", return NULL;
buffer[i], info.dli_sname, offset, info.dli_fname); (void)snprintf((char *) rval + clen, alen,
rval[i] = (char *) clen; "%p <%s+%d> at %s", buffer[i], info.dli_sname,
clen += alen; offset, info.dli_fname);
continue; rval[i] = (char *) clen;
} clen += alen;
} continue;
}
}
#endif #endif
alen = 2 + /* "0x" */ alen = 2 + /* "0x" */
(sizeof(void *) * 2) + /* "01234567" */ (sizeof(void *) * 2) + /* "01234567" */
1; /* "\0" */ 1; /* "\0" */
rval = realloc_safe(rval, clen + alen); rval = realloc(rval, clen + alen);
if (rval == NULL) if (rval == NULL)
return NULL; return NULL;
snprintf((char *) rval + clen, alen, "%p", buffer[i]); (void)snprintf((char *) rval + clen, alen, "%p", buffer[i]);
rval[i] = (char *) clen; rval[i] = (char *) clen;
clen += alen; clen += alen;
} }
for (i = 0; i < size; i++)
rval[i] += (long) rval;
return rval; for (i = 0; i < size; i++)
rval[i] += (long) rval;
return (rval);
} }
static void * static void *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment