From: Pablo Neira Ayuso Date: Fri, 25 Feb 2011 17:36:49 +0000 (+0100) Subject: sqlite3: cleanup error handling of sqlite3_bind_int() in sqlite3_interp() X-Git-Tag: ulogd-2.0.0~26 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=99b7c46d0297663d8a908a42ce137d04221a4e31;p=thirdparty%2Fulogd2.git sqlite3: cleanup error handling of sqlite3_bind_int() in sqlite3_interp() Move error handling after the switch statement since it's the same for all cases, we save several lines of code. Signed-off-by: Pablo Neira Ayuso --- diff --git a/output/sqlite3/ulogd_output_SQLITE3.c b/output/sqlite3/ulogd_output_SQLITE3.c index 65e320b..d9ebe9d 100644 --- a/output/sqlite3/ulogd_output_SQLITE3.c +++ b/output/sqlite3/ulogd_output_SQLITE3.c @@ -158,70 +158,54 @@ sqlite3_interp(struct ulogd_pluginstance *pi) switch (f->key->type) { case ULOGD_RET_INT8: ret = sqlite3_bind_int(priv->p_stmt, i, k_ret->u.value.i8); - if (ret != SQLITE_OK) - goto err_bind; break; case ULOGD_RET_INT16: ret = sqlite3_bind_int(priv->p_stmt, i, k_ret->u.value.i16); - if (ret != SQLITE_OK) - goto err_bind; break; case ULOGD_RET_INT32: ret = sqlite3_bind_int(priv->p_stmt, i, k_ret->u.value.i32); - if (ret != SQLITE_OK) - goto err_bind; break; case ULOGD_RET_INT64: ret = sqlite3_bind_int(priv->p_stmt, i, k_ret->u.value.i64); - if (ret != SQLITE_OK) - goto err_bind; break; case ULOGD_RET_UINT8: ret = sqlite3_bind_int(priv->p_stmt, i, k_ret->u.value.ui8); - if (ret != SQLITE_OK) - goto err_bind; break; case ULOGD_RET_UINT16: ret = sqlite3_bind_int(priv->p_stmt, i, k_ret->u.value.ui16); - if (ret != SQLITE_OK) - goto err_bind; break; case ULOGD_RET_UINT32: ret = sqlite3_bind_int(priv->p_stmt, i, k_ret->u.value.ui32); - if (ret != SQLITE_OK) - goto err_bind; break; case ULOGD_RET_IPADDR: case ULOGD_RET_UINT64: ret = sqlite3_bind_int64(priv->p_stmt, i, k_ret->u.value.ui64); - if (ret != SQLITE_OK) - goto err_bind; break; case ULOGD_RET_BOOL: ret = sqlite3_bind_int(priv->p_stmt, i, k_ret->u.value.b); - if (ret != SQLITE_OK) - goto err_bind; break; case ULOGD_RET_STRING: ret = sqlite3_bind_text(priv->p_stmt, i, k_ret->u.value.ptr, strlen(k_ret->u.value.ptr), SQLITE_STATIC); - if (ret != SQLITE_OK) - goto err_bind; break; default: + ret = SQLITE_OK; ulogd_log(ULOGD_NOTICE, "unknown type %d for %s\n", f->key->type, f->key->name); } + if (ret != SQLITE_OK) + goto err_bind; + i++; }