trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kic...@apache.org
Subject trafficserver git commit: TS-1611: fix coverity scan defects and use TSError instead of fprintf to stderr
Date Wed, 01 Apr 2015 08:05:13 GMT
Repository: trafficserver
Updated Branches:
  refs/heads/master 4cbf3cb0a -> 0b3fac4a3


TS-1611: fix coverity scan defects and use TSError instead of fprintf to stderr


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/0b3fac4a
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/0b3fac4a
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/0b3fac4a

Branch: refs/heads/master
Commit: 0b3fac4a3f291a2b88dc2b7934a61d3e834c53eb
Parents: 4cbf3cb
Author: Kit Chan <kichan@apache.org>
Authored: Wed Apr 1 01:02:51 2015 -0700
Committer: Kit Chan <kichan@apache.org>
Committed: Wed Apr 1 01:02:51 2015 -0700

----------------------------------------------------------------------
 plugins/experimental/ts_lua/ts_lua.c            |  2 +-
 plugins/experimental/ts_lua/ts_lua_common.h     |  5 ----
 plugins/experimental/ts_lua/ts_lua_hook.c       | 24 +++++++++-----------
 .../experimental/ts_lua/ts_lua_http_intercept.c | 10 ++++----
 plugins/experimental/ts_lua/ts_lua_transform.c  |  4 ++--
 plugins/experimental/ts_lua/ts_lua_util.c       |  2 +-
 6 files changed, 20 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0b3fac4a/plugins/experimental/ts_lua/ts_lua.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua.c b/plugins/experimental/ts_lua/ts_lua.c
index 4df5fc0..44870a2 100644
--- a/plugins/experimental/ts_lua/ts_lua.c
+++ b/plugins/experimental/ts_lua/ts_lua.c
@@ -165,7 +165,7 @@ TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
 
   ts_lua_set_cont_info(L, NULL);
   if (lua_pcall(L, 0, 1, 0) != 0) {
-    ee("lua_pcall failed: %s", lua_tostring(L, -1));
+    TSError("lua_pcall failed: %s", lua_tostring(L, -1));
     ret = TSREMAP_NO_REMAP;
 
   } else {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0b3fac4a/plugins/experimental/ts_lua/ts_lua_common.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_common.h b/plugins/experimental/ts_lua/ts_lua_common.h
index bd1f0f2..3f9ce4e 100644
--- a/plugins/experimental/ts_lua/ts_lua_common.h
+++ b/plugins/experimental/ts_lua/ts_lua_common.h
@@ -84,11 +84,6 @@
     X, #X                       \
   }
 
-#define ee(...)                              \
-  fprintf(stderr, "Lua *** %s: ", __func__); \
-  fprintf(stderr, __VA_ARGS__);              \
-  fprintf(stderr, " @%s:%d\n", __FILE__, __LINE__)
-
 /* for http config or cntl var */
 typedef struct {
   int nvar;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0b3fac4a/plugins/experimental/ts_lua/ts_lua_hook.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_hook.c b/plugins/experimental/ts_lua/ts_lua_hook.c
index 30c3262..8ec9ca5 100644
--- a/plugins/experimental/ts_lua/ts_lua_hook.c
+++ b/plugins/experimental/ts_lua/ts_lua_hook.c
@@ -80,11 +80,9 @@ ts_lua_add_hook(lua_State *L)
   int entry;
 
   TSVConn connp;
-  TSCont main_contp;
   ts_lua_http_ctx *http_ctx;
 
   http_ctx = ts_lua_get_http_ctx(L);
-  main_contp = http_ctx->cinfo.contp;
 
   entry = lua_tointeger(L, 1); // get hook id
 
@@ -95,7 +93,7 @@ ts_lua_add_hook(lua_State *L)
   switch (entry) {
   case TS_LUA_HOOK_CACHE_LOOKUP_COMPLETE:
     if (http_ctx) {
-      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK, main_contp);
+      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK, http_ctx->cinfo.contp);
       http_ctx->has_hook = 1;
       lua_pushvalue(L, 2);
       lua_setglobal(L, TS_LUA_FUNCTION_CACHE_LOOKUP_COMPLETE);
@@ -107,7 +105,7 @@ ts_lua_add_hook(lua_State *L)
 
   case TS_LUA_HOOK_SEND_REQUEST_HDR:
     if (http_ctx) {
-      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_SEND_REQUEST_HDR_HOOK, main_contp);
+      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_SEND_REQUEST_HDR_HOOK, http_ctx->cinfo.contp);
       http_ctx->has_hook = 1;
       lua_pushvalue(L, 2);
       lua_setglobal(L, TS_LUA_FUNCTION_SEND_REQUEST);
@@ -119,7 +117,7 @@ ts_lua_add_hook(lua_State *L)
 
   case TS_LUA_HOOK_READ_RESPONSE_HDR:
     if (http_ctx) {
-      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_READ_RESPONSE_HDR_HOOK, main_contp);
+      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_READ_RESPONSE_HDR_HOOK, http_ctx->cinfo.contp);
       http_ctx->has_hook = 1;
       lua_pushvalue(L, 2);
       lua_setglobal(L, TS_LUA_FUNCTION_READ_RESPONSE);
@@ -131,7 +129,7 @@ ts_lua_add_hook(lua_State *L)
 
   case TS_LUA_HOOK_SEND_RESPONSE_HDR:
     if (http_ctx) {
-      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_SEND_RESPONSE_HDR_HOOK, main_contp);
+      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_SEND_RESPONSE_HDR_HOOK, http_ctx->cinfo.contp);
       http_ctx->has_hook = 1;
       lua_pushvalue(L, 2);
       lua_setglobal(L, TS_LUA_FUNCTION_SEND_RESPONSE);
@@ -143,7 +141,7 @@ ts_lua_add_hook(lua_State *L)
 
   case TS_LUA_HOOK_READ_REQUEST_HDR:
     if (http_ctx) {
-      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_READ_REQUEST_HDR_HOOK, main_contp);
+      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_READ_REQUEST_HDR_HOOK, http_ctx->cinfo.contp);
       http_ctx->has_hook = 1;
       lua_pushvalue(L, 2);
       lua_setglobal(L, TS_LUA_FUNCTION_READ_REQUEST);
@@ -155,7 +153,7 @@ ts_lua_add_hook(lua_State *L)
 
   case TS_LUA_HOOK_TXN_START:
     if (http_ctx) {
-      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_TXN_START_HOOK, main_contp);
+      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_TXN_START_HOOK, http_ctx->cinfo.contp);
       http_ctx->has_hook = 1;
       lua_pushvalue(L, 2);
       lua_setglobal(L, TS_LUA_FUNCTION_TXN_START);
@@ -167,7 +165,7 @@ ts_lua_add_hook(lua_State *L)
 
   case TS_LUA_HOOK_PRE_REMAP:
     if (http_ctx) {
-      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_PRE_REMAP_HOOK, main_contp);
+      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_PRE_REMAP_HOOK, http_ctx->cinfo.contp);
       http_ctx->has_hook = 1;
       lua_pushvalue(L, 2);
       lua_setglobal(L, TS_LUA_FUNCTION_PRE_REMAP);
@@ -179,7 +177,7 @@ ts_lua_add_hook(lua_State *L)
 
   case TS_LUA_HOOK_POST_REMAP:
     if (http_ctx) {
-      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_POST_REMAP_HOOK, main_contp);
+      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_POST_REMAP_HOOK, http_ctx->cinfo.contp);
       http_ctx->has_hook = 1;
       lua_pushvalue(L, 2);
       lua_setglobal(L, TS_LUA_FUNCTION_POST_REMAP);
@@ -191,7 +189,7 @@ ts_lua_add_hook(lua_State *L)
 
   case TS_LUA_HOOK_OS_DNS:
     if (http_ctx) {
-      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_OS_DNS_HOOK, main_contp);
+      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_OS_DNS_HOOK, http_ctx->cinfo.contp);
       http_ctx->has_hook = 1;
       lua_pushvalue(L, 2);
       lua_setglobal(L, TS_LUA_FUNCTION_OS_DNS);
@@ -203,7 +201,7 @@ ts_lua_add_hook(lua_State *L)
 
   case TS_LUA_HOOK_SELECT_ALT:
     if (http_ctx) {
-      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_SELECT_ALT_HOOK, main_contp);
+      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_SELECT_ALT_HOOK, http_ctx->cinfo.contp);
       http_ctx->has_hook = 1;
       lua_pushvalue(L, 2);
       lua_setglobal(L, TS_LUA_FUNCTION_SELECT_ALT);
@@ -215,7 +213,7 @@ ts_lua_add_hook(lua_State *L)
 
   case TS_LUA_HOOK_READ_CACHE_HDR:
     if (http_ctx) {
-      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_READ_CACHE_HDR_HOOK, main_contp);
+      TSHttpTxnHookAdd(http_ctx->txnp, TS_HTTP_READ_CACHE_HDR_HOOK, http_ctx->cinfo.contp);
       http_ctx->has_hook = 1;
       lua_pushvalue(L, 2);
       lua_setglobal(L, TS_LUA_FUNCTION_READ_CACHE);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0b3fac4a/plugins/experimental/ts_lua/ts_lua_http_intercept.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_http_intercept.c b/plugins/experimental/ts_lua/ts_lua_http_intercept.c
index 766e9f4..031def8 100644
--- a/plugins/experimental/ts_lua/ts_lua_http_intercept.c
+++ b/plugins/experimental/ts_lua/ts_lua_http_intercept.c
@@ -74,13 +74,13 @@ ts_lua_http_intercept(lua_State *L)
   n = lua_gettop(L);
 
   if (n < 1) {
-    ee("ts.http.intercept need at least one param");
+    TSError("ts.http.intercept need at least one param");
     return 0;
   }
 
   type = lua_type(L, 1);
   if (type != LUA_TFUNCTION) {
-    ee("ts.http.intercept should use function as param, but there is %s", lua_typename(L,
type));
+    TSError("ts.http.intercept should use function as param, but there is %s", lua_typename(L,
type));
     return 0;
   }
 
@@ -106,13 +106,13 @@ ts_lua_http_server_intercept(lua_State *L)
   n = lua_gettop(L);
 
   if (n < 1) {
-    ee("ts.http.server_intercept need at least one param");
+    TSError("ts.http.server_intercept need at least one param");
     return 0;
   }
 
   type = lua_type(L, 1);
   if (type != LUA_TFUNCTION) {
-    ee("ts.http.server_intercept should use function as param, but there is %s", lua_typename(L,
type));
+    TSError("ts.http.server_intercept should use function as param, but there is %s", lua_typename(L,
type));
     return 0;
   }
 
@@ -273,7 +273,7 @@ ts_lua_http_intercept_run_coroutine(ts_lua_http_intercept_ctx *ictx, int
n)
     break;
 
   default: // error
-    ee("lua_resume failed: %s", lua_tostring(L, -1));
+    TSError("lua_resume failed: %s", lua_tostring(L, -1));
     lua_pop(L, 1);
     return -1;
   }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0b3fac4a/plugins/experimental/ts_lua/ts_lua_transform.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_transform.c b/plugins/experimental/ts_lua/ts_lua_transform.c
index ce7db9b..d19ab3f 100644
--- a/plugins/experimental/ts_lua/ts_lua_transform.c
+++ b/plugins/experimental/ts_lua/ts_lua_transform.c
@@ -52,7 +52,7 @@ ts_lua_transform_entry(TSCont contp, TSEvent ev, void *edata)
 
   case TS_LUA_EVENT_COROUTINE_CONT:
     n = (intptr_t)edata;
-
+  /* FALL THROUGH */
   case TS_EVENT_VCONN_WRITE_READY:
   default:
     ts_lua_transform_handler(contp, transform_ctx, event, n);
@@ -189,7 +189,7 @@ ts_lua_transform_handler(TSCont contp, ts_lua_http_transform_ctx *transform_ctx,
       break;
 
     default: // coroutine failed
-      ee("lua_resume failed: %s", lua_tostring(L, -1));
+      TSError("lua_resume failed: %s", lua_tostring(L, -1));
       ret = 1;
       res = NULL;
       res_len = 0;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0b3fac4a/plugins/experimental/ts_lua/ts_lua_util.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_util.c b/plugins/experimental/ts_lua/ts_lua_util.c
index 31bf80f..7353e81 100644
--- a/plugins/experimental/ts_lua/ts_lua_util.c
+++ b/plugins/experimental/ts_lua/ts_lua_util.c
@@ -762,7 +762,7 @@ ts_lua_http_cont_handler(TSCont contp, TSEvent ev, void *edata)
     break;
 
   default: // coroutine failed
-    ee("lua_resume failed: %s", lua_tostring(L, -1));
+    TSError("lua_resume failed: %s", lua_tostring(L, -1));
     rc = -1;
     lua_pop(L, 1);
     break;


Mime
View raw message