Browse Source

Fix some warnings found with clang analyzer

personal/stbuehler/wip
Stefan Bühler 11 years ago
parent
commit
11fa781f98
  1. 6
      include/lighttpd/settings.h
  2. 2
      src/common/utils.c
  3. 1
      src/main/config_parser.rl
  4. 18
      src/main/log.c
  5. 7
      src/main/network.c
  6. 2
      src/main/plugin_core.c
  7. 2
      src/main/throttle.c
  8. 3
      src/modules/mod_dirlist.c
  9. 3
      src/modules/mod_openssl.c

6
include/lighttpd/settings.h

@ -53,8 +53,10 @@
#define CONST_STR_LEN(x) (x), (sizeof(x) - 1)
#define CONST_USTR_LEN(x) ((const guchar*) (x)), (sizeof(x) - 1)
#define GSTR_LEN(x) ((x) ? (x)->str : ""), ((x) ? (x)->len : 0)
#define GUSTR_LEN(x) (const guchar*) ((x) ? (x)->str : ""), (x) ? (x)->len : 0
#define GSTR_SAFE_LEN(x) ((x) ? (x)->str : ""), ((x) ? (x)->len : 0)
#define GUSTR_SAFE_LEN(x) (const guchar*) ((x) ? (x)->str : ""), (x) ? (x)->len : 0
#define GSTR_LEN(x) ((x)->str), ((x)->len)
#define GUSTR_LEN(x) ((const guchar*) ((x)->str)), ((x)->len)
#define GSTR_SAFE_STR(x) ((x && x->str) ? x->str : "(null)")
#include <assert.h>

2
src/common/utils.c

@ -394,7 +394,7 @@ gboolean li_querystring_find(const GString *querystring, const gchar *key, const
gchar delim = '\0';
gchar *end = querystring->str + querystring->len;
gchar *start = querystring->str;
gchar *c = querystring->str;
gchar *c;
/* search for key */
for (c = querystring->str; c != end; c++) {

1
src/main/config_parser.rl

@ -921,7 +921,6 @@ static gboolean config_parser_include(liServer *srv, GList *ctx_stack, gchar *pa
/* 'and' */
g_queue_pop_head(ctx->condition_stack);
cond = g_queue_pop_head(ctx->condition_stack);
action_last_and = a;
/* mark target pointer as 'and' */
a = li_action_new_condition(cond, (liAction*)((uintptr_t)a | 0x1), NULL);
_printf("new AND condition action: %p, target: %p, else: %p\n", (void*)a, (void*)action_last_and, NULL);

18
src/main/log.c

@ -41,10 +41,7 @@ static void li_log_write_stderr(liServer *srv, const gchar *msg, gboolean newlin
static liLog *log_open(liServer *srv, GString *path) {
liLog *log;
if (path)
log = li_radixtree_lookup_exact(srv->logs.targets, path->str, path->len * 8);
else
log = NULL;
log = li_radixtree_lookup_exact(srv->logs.targets, path->str, path->len * 8);
if (NULL == log) {
/* log not open */
@ -128,9 +125,6 @@ void li_log_init(liServer *srv) {
}
void li_log_cleanup(liServer *srv) {
guint i;
liLogTimestamp *ts;
/* wait for logging thread to exit */
if (g_atomic_int_get(&srv->logs.thread_alive) == TRUE)
{
@ -140,12 +134,8 @@ void li_log_cleanup(liServer *srv) {
li_radixtree_free(srv->logs.targets, NULL, NULL);
for (i = 0; i < srv->logs.timestamps->len; i++) {
ts = g_array_index(srv->logs.timestamps, liLogTimestamp*, i);
/*g_print("ts #%d refcount: %d\n", i, ts->refcount);*/
if (li_log_timestamp_free(srv, g_array_index(srv->logs.timestamps, liLogTimestamp*, 0)))
i--;
}
/* we allocated the first entry, lets release only that one */
li_log_timestamp_free(srv, g_array_index(srv->logs.timestamps, liLogTimestamp*, 0));
g_array_free(srv->logs.timestamps, TRUE);
ev_loop_destroy(srv->logs.loop);
@ -522,7 +512,7 @@ gboolean li_log_timestamp_free(liServer *srv, liLogTimestamp *ts) {
g_mutex_lock(srv->action_mutex);
for (guint i = 0; i < srv->logs.timestamps->len; i++) {
if (g_string_equal(g_array_index(srv->logs.timestamps, liLogTimestamp*, i)->format, ts->format)) {
if (g_array_index(srv->logs.timestamps, liLogTimestamp*, i) == ts) {
g_array_remove_index_fast(srv->logs.timestamps, i);
break;
}

7
src/main/network.c

@ -41,7 +41,6 @@ liNetworkStatus li_network_write(liVRequest *vr, int fd, liChunkQueue *cq, goffs
#ifdef TCP_CORK
int corked = 0;
#endif
goffset write_bytes, wrote;
#ifdef TCP_CORK
/* Linux: put a cork into the socket as we want to combine the write() calls
@ -53,14 +52,12 @@ liNetworkStatus li_network_write(liVRequest *vr, int fd, liChunkQueue *cq, goffs
}
#endif
write_bytes = write_max;
/* TODO: add setup-option to select the backend */
#ifdef USE_SENDFILE
res = li_network_write_sendfile(vr, fd, cq, &write_bytes);
res = li_network_write_sendfile(vr, fd, cq, &write_max);
#else
res = li_network_write_writev(vr, fd, cq, &write_bytes);
res = li_network_write_writev(vr, fd, cq, &write_max);
#endif
wrote = write_max - write_bytes;
#ifdef TCP_CORK
if (corked) {

2
src/main/plugin_core.c

@ -73,7 +73,7 @@ static liAction* core_when(liServer *srv, liWorker *wrk, liPlugin* p, liValue *v
val_act = g_array_index(val->data.list, liValue*, 1);
if (NULL == val_cond || val_cond->type != LI_VALUE_CONDITION) {
ERROR(srv, "expected condition as first parameter, got %s", li_value_type_string(val_cond->type));
ERROR(srv, "expected condition as first parameter, got %s", NULL == val_cond ? "NULL" : li_value_type_string(val_cond->type));
return NULL;
}
if (NULL == val_act || val_act->type == LI_VALUE_NONE) {

2
src/main/throttle.c

@ -278,11 +278,9 @@ void li_throttle_cb(liWaitQueue *wq, gpointer data) {
liWaitQueueElem *wqe;
liVRequest *vr;
liWorker *wrk;
ev_tstamp now;
gint supply;
wrk = data;
now = ev_now(wrk->loop);
while (NULL != (wqe = li_waitqueue_pop(wq))) {
vr = wqe->data;

3
src/modules/mod_dirlist.c

@ -398,7 +398,6 @@ static liHandlerResult dirlist(liVRequest *vr, gpointer param, gpointer *context
guint datebuflen;
struct tm tm;
gboolean hide;
gboolean have_header = FALSE, have_readme = FALSE;
if (!li_vrequest_handle_direct(vr)) {
li_stat_cache_entry_release(vr, sce);
@ -462,10 +461,8 @@ static liHandlerResult dirlist(liVRequest *vr, gpointer param, gpointer *context
g_array_append_val(directories, i);
} else {
if ((dd->include_header || dd->hide_header) && g_str_equal(sced->path, "HEADER.txt")) {
if (dd->include_header && sced->st.st_size > 0 && sced->st.st_size < MAX_INCLUDE_FILE_SIZE) have_header = TRUE;
if (dd->hide_header) continue;
} else if ((dd->include_readme || dd->hide_readme) && g_str_equal(sced->path, "README.txt")) {
if (dd->include_readme && sced->st.st_size > 0 && sced->st.st_size < MAX_INCLUDE_FILE_SIZE) have_readme = TRUE;
if (dd->hide_readme) continue;
}
g_array_append_val(files, i);

3
src/modules/mod_openssl.c

@ -177,10 +177,9 @@ static liNetworkStatus openssl_con_write(liConnection *con, goffset write_max) {
ERR_clear_error();
if ((r = SSL_write(conctx->ssl, block_data, block_len)) <= 0) {
int ssl_r;
unsigned long err;
switch ((ssl_r = SSL_get_error(conctx->ssl, r))) {
switch (SSL_get_error(conctx->ssl, r)) {
case SSL_ERROR_WANT_READ:
li_ev_io_add_events(con->wrk->loop, &con->sock_watcher, EV_READ);
return LI_NETWORK_STATUS_WAIT_FOR_EVENT;

Loading…
Cancel
Save