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);
void SMS_Finish(struct object *obj);
/* 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_TTLchanged(const struct object *o);
void SMP_FreeObj(struct object *o);
void SMP_FreeObj(const struct object *o);
void SMP_Ready(void);
void SMP_NewBan(double t0, const char *ban);
......
......@@ -279,7 +279,10 @@ pan_backtrace(void)
if (Symbol_Lookup(vsp, array[i]) < 0) {
char **strings;
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");
}
......
......@@ -212,13 +212,13 @@ static void *
wrk_thread(void *priv)
{
struct wq *qp;
volatile unsigned nhttp;
unsigned nhttp;
unsigned siov;
CAST_OBJ_NOTNULL(qp, priv, WQ_MAGIC);
/* We need to snapshot these two for consistency */
nhttp = params->http_headers;
siov = nhttp * 2; /* XXX param ? */
siov = nhttp * 2;
if (siov > IOV_MAX)
siov = IOV_MAX;
return (wrk_thread_real(qp,
......
......@@ -201,6 +201,9 @@
-efunc(539, http_FilterFields) // 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
-efunc(525, vcl_handlingname) // Negative indentation from line
-esym(528, vcl_handlingname) // Not referenced
......
......@@ -199,6 +199,10 @@ struct params {
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 struct heritage heritage;
......
......@@ -648,7 +648,7 @@ smp_save_segs(struct smp_sc *sc)
*/
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_object *so;
......@@ -785,7 +785,7 @@ smp_open_bans(struct smp_sc *sc, struct smp_signctx *ctx)
*/
void
SMP_FreeObj(struct object *o)
SMP_FreeObj(const struct object *o)
{
struct smp_seg *sg;
......
......@@ -137,5 +137,4 @@ struct smp_object {
double ttl;
double ban;
struct object *ptr;
uint64_t len; /* XXX: madvise */
};
......@@ -50,7 +50,6 @@ struct vev {
#define EV_WR POLLOUT
#define EV_ERR POLLERR
#define EV_HUP POLLHUP
#define EV_GONE POLLNVAL
#define EV_SIG -1
int sig;
unsigned sig_flags;
......
......@@ -45,97 +45,88 @@ SVNID("$Id: execinfo.c,v 1.3 2004/07/19 05:21:09 sobomax Exp $")
#include <string.h>
#include <unistd.h>
static void *getreturnaddr(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
backtrace(void **buffer, int size)
{
int i;
for (i = 1; getframeaddr(i + 1) != NULL && i != size + 1; i++) {
buffer[i - 1] = getreturnaddr(i);
if (buffer[i - 1] == NULL)
break;
}
int i;
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 **
backtrace_symbols(void *const *buffer, int size)
{
size_t clen, alen;
int i;
char **rval;
size_t clen, alen;
int i;
char **rval;
clen = size * sizeof(char *);
rval = malloc(clen);
if (rval == NULL)
return NULL;
for (i = 0; i < size; i++) {
clen = size * sizeof(char *);
rval = malloc(clen);
if (rval == NULL)
return (NULL);
for (i = 0; i < size; i++) {
#ifdef HAVE_DLADDR
{
Dl_info info;
int offset;
{
Dl_info info;
int offset;
if (dladdr(buffer[i], &info) != 0) {
if (info.dli_sname == NULL)
info.dli_sname = "???";
if (info.dli_saddr == NULL)
info.dli_saddr = buffer[i];
offset = (const char*)buffer[i] - (const char*)info.dli_saddr;
/* "0x01234567 <function+offset> at filename" */
alen = 2 + /* "0x" */
(sizeof(void *) * 2) + /* "01234567" */
2 + /* " <" */
strlen(info.dli_sname) + /* "function" */
1 + /* "+" */
10 + /* "offset */
5 + /* "> at " */
strlen(info.dli_fname) + /* "filename" */
1; /* "\0" */
rval = realloc_safe(rval, clen + alen);
if (rval == NULL)
return NULL;
snprintf((char *) rval + clen, alen, "%p <%s+%d> at %s",
buffer[i], info.dli_sname, offset, info.dli_fname);
rval[i] = (char *) clen;
clen += alen;
continue;
}
}
if (dladdr(buffer[i], &info) != 0) {
if (info.dli_sname == NULL)
info.dli_sname = "?";
if (info.dli_saddr == NULL)
info.dli_saddr = buffer[i];
offset = (const char*)buffer[i] -
(const char*)info.dli_saddr;
/* "0x01234567 <function+offset> at filename" */
alen = 2 + /* "0x" */
(sizeof(void *) * 2) + /* "01234567" */
2 + /* " <" */
strlen(info.dli_sname) + /* "function" */
1 + /* "+" */
10 + /* "offset */
5 + /* "> at " */
strlen(info.dli_fname) + /* "filename" */
1; /* "\0" */
rval = realloc(rval, clen + alen);
if (rval == NULL)
return NULL;
(void)snprintf((char *) rval + clen, alen,
"%p <%s+%d> at %s", buffer[i], info.dli_sname,
offset, info.dli_fname);
rval[i] = (char *) clen;
clen += alen;
continue;
}
}
#endif
alen = 2 + /* "0x" */
(sizeof(void *) * 2) + /* "01234567" */
1; /* "\0" */
rval = realloc_safe(rval, clen + alen);
if (rval == NULL)
return NULL;
snprintf((char *) rval + clen, alen, "%p", buffer[i]);
rval[i] = (char *) clen;
clen += alen;
}
for (i = 0; i < size; i++)
rval[i] += (long) rval;
alen = 2 + /* "0x" */
(sizeof(void *) * 2) + /* "01234567" */
1; /* "\0" */
rval = realloc(rval, clen + alen);
if (rval == NULL)
return NULL;
(void)snprintf((char *) rval + clen, alen, "%p", buffer[i]);
rval[i] = (char *) clen;
clen += alen;
}
return rval;
for (i = 0; i < size; i++)
rval[i] += (long) rval;
return (rval);
}
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