Fix bugs found with the static clang analyzer (http://clang-analyzer.llvm.org/)

personal/stbuehler/wip
Stefan Bühler 14 years ago
parent f4f2bd1f38
commit a061745193

@ -103,4 +103,4 @@ LI_API void li_stat_cache_entry_acquire(liVRequest *vr, liStatCacheEntry *sce);
/* release a stat_cache_entry so it can be cleaned up */
LI_API void li_stat_cache_entry_release(liVRequest *vr, liStatCacheEntry *sce);
#endif
#endif

@ -88,5 +88,5 @@ cleanup:
if (config_path) g_free((gchar*) config_path);
if (module_dir != def_module_dir) g_free((gchar*) module_dir);
return 0;
return result;
}

@ -273,6 +273,7 @@ static gboolean plugins_activate_module(liServer *srv, server_module *sm) {
for (i = 0; i < sm->plugins->len; i++) {
p = g_ptr_array_index(sm->plugins, i);
g_ptr_array_add(ps->load_plugins, p);
g_hash_table_insert(ps->load_ht_plugins, (gpointer) p->name, p);
if (!p->items) continue;
for (pi = p->items; pi->name; pi++) {
@ -288,8 +289,6 @@ static gboolean plugins_activate_module(liServer *srv, server_module *sm) {
}
}
g_hash_table_insert(ps->load_ht_plugins, (gpointer) p->name, p);
return TRUE;
item_collission:
@ -302,6 +301,7 @@ item_collission:
for ( ; i-- > 0; ) {
p = g_ptr_array_index(sm->plugins, i);
g_hash_table_remove(ps->load_ht_plugins, p->name);
if (!p->items) continue;
for (pi = p->items; pi->name; pi++) {
@ -359,13 +359,13 @@ liPlugin *li_angel_plugin_register(liServer *srv, liModule *mod, const gchar *na
sm = g_hash_table_lookup(ps->load_module_refs, modname);
if (!sm) {
ERROR(srv, "Module '%s' not loaded; cannot load plugin '%s'", mod->name->str, name);
ERROR(srv, "Module '%s' not loaded; cannot load plugin '%s'", modname, name);
return NULL;
}
p = plugin_new(name);
if (!init(srv, p)) {
ERROR(srv, "Couldn't load plugin '%s' for module '%s': init failed", name, mod->name->str);
ERROR(srv, "Couldn't load plugin '%s' for module '%s': init failed", name, modname);
li_plugin_free(srv, p);
return NULL;
}

@ -215,7 +215,6 @@ liHandlerResult li_action_execute(liVRequest *vr) {
action_stack_pop(srv, vr, as);
while (NULL != (ase = action_stack_top(as)) && (ase->act->type != ACTION_TBALANCER || !ase->act->data.balancer.provide_backlog)) {
action_stack_pop(srv, vr, as);
ase = action_stack_top(as);
}
if (!ase) { /* no backlogging balancer found */
if (li_vrequest_handle_direct(vr))

@ -756,8 +756,6 @@ gboolean li_chunkqueue_extract_to(liVRequest *vr, liChunkQueue *cq, goffset len,
if (len > cq->length) return FALSE;
ci = chunkqueue_iter(cq);
coff = 0;
clen = chunkiter_length(ci);
while (len > 0) {
coff = 0;
@ -791,8 +789,6 @@ gboolean li_chunkqueue_extract_to_bytearr(liVRequest *vr, liChunkQueue *cq, goff
g_byte_array_set_size(dest, 0);
ci = chunkqueue_iter(cq);
coff = 0;
clen = chunkiter_length(ci);
while (len > 0) {
coff = 0;

@ -445,6 +445,7 @@ static liHandlerResult li_condition_check_eval_int(liVRequest *vr, liCondition *
switch (cond->lvalue->type) {
case LI_COMP_REQUEST_CONTENT_LENGTH:
val = vr->request.content_length;
break;
case LI_COMP_PHYSICAL_SIZE:
if (!vr->physical.have_stat) {
if (vr->physical.have_errno || !li_vrequest_stat(vr)) {

@ -931,9 +931,8 @@
ctx->in_setup_block = FALSE;
}
else {
liAction *al;
/* pop action list stack */
al = g_queue_pop_head(ctx->action_list_stack);
g_queue_pop_head(ctx->action_list_stack);
}
}

@ -528,7 +528,6 @@ static gboolean core_event_handler(liServer *srv, liPlugin* p, liValue *val) {
}
str = val->data.string->str;
backend = 0; /* libev will chose the right one by default */
if (g_str_equal(str, "select"))
backend = EVBACKEND_SELECT;

@ -258,7 +258,7 @@ static void li_server_listen_cb(struct ev_loop *loop, ev_io *w, int revents) {
while (-1 != (s = accept(w->fd, &sa, &l))) {
liWorker *wrk = srv->main_worker;
guint i, min_load = g_atomic_int_get(&wrk->connection_load), sel = 0;
guint i, min_load = g_atomic_int_get(&wrk->connection_load);
if (l <= sizeof(sa)) {
remote_addr.addr = g_slice_alloc(l);
@ -277,12 +277,10 @@ static void li_server_listen_cb(struct ev_loop *loop, ev_io *w, int revents) {
if (load < min_load) {
wrk = wt;
min_load = load;
sel = i;
}
}
g_atomic_int_inc((gint*) &wrk->connection_load);
/* TRACE(srv, "selected worker %u with load %u", sel, min_load); */
li_server_socket_acquire(sock);
li_worker_new_con(srv->main_worker, wrk, remote_addr, s, sock);
}

@ -114,7 +114,7 @@ liValue* li_value_from_lua(liServer *srv, lua_State *L) {
if (a) {
li_action_acquire(a);
lua_pop(L, 1);
return val = li_value_new_action(srv, a);
return li_value_new_action(srv, a);
}
}
{ /* check for condition */
@ -122,7 +122,7 @@ liValue* li_value_from_lua(liServer *srv, lua_State *L) {
if (c) {
li_condition_acquire(c);
lua_pop(L, 1);
return val = li_value_new_condition(srv, c);
return li_value_new_condition(srv, c);
}
}
ERROR(srv, "%s", "Unknown lua userdata");

@ -153,7 +153,6 @@ static gpointer debug_collect_func(liWorker *wrk, gpointer fdata) {
static void debug_collect_cb(gpointer cbdata, gpointer fdata, GPtrArray *result, gboolean complete) {
mod_debug_job_t *job = cbdata;
liVRequest *vr;
liPlugin *p;
GString *html;
UNUSED(fdata);
@ -187,7 +186,6 @@ static void debug_collect_cb(gpointer cbdata, gpointer fdata, GPtrArray *result,
}
vr = job->vr;
p = job->p;
/* clear context so it doesn't get cleaned up anymore */
*(job->context) = NULL;

@ -161,14 +161,13 @@ static void dirlist_format_size(gchar *buf, goffset size) {
*buf++ = remaining + '0';
}
*buf++ = *u;
*buf++ = '\0';
*buf = '\0';
}
static liHandlerResult dirlist(liVRequest *vr, gpointer param, gpointer *context) {
GString *listing;
liStatCacheEntry *sce;
dirlist_data *dd;
dirlist_plugin_data *pd;
UNUSED(context);
@ -183,7 +182,6 @@ static liHandlerResult dirlist(liVRequest *vr, gpointer param, gpointer *context
}
dd = param;
pd = dd->plugin->data;
if (sce->data.failed) {
/* stat failed */

@ -284,7 +284,7 @@ static gboolean rewrite_internal(liVRequest *vr, GString *dest_path, GString *de
g_string_printf(vr->con->wrk->tmp_str, "%"L_GOFFSET_FORMAT, vr->request.content_length);
str = vr->con->wrk->tmp_str;
break;
default: str = NULL;
default: continue;
}
if (rp->data.cond_lval == LI_COMP_REQUEST_SCHEME) {

Loading…
Cancel
Save