X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Flua.c;h=3f48a55dee5e122e042b38e550d2e26434f828d6;hb=a503c54a95d139f117650a0e6d80e6edfe81e8bf;hp=9a1ceed7cdf1b1fb20329f1a363e9549a6014a2a;hpb=55cf3839153384e6d1efc747a7459b334c674401;p=collectd.git diff --git a/src/lua.c b/src/lua.c index 9a1ceed7..3f48a55d 100644 --- a/src/lua.c +++ b/src/lua.c @@ -278,7 +278,7 @@ static int lua_cb_register_generic(lua_State *L, int type) /* {{{ */ char subname[DATA_MAX_NAME_LEN]; if (!lua_isfunction(L, 1) && lua_isstring(L, 1)) { const char *fname = lua_tostring(L, 1); - snprintf(subname, sizeof(subname), "%s()", fname); + ssnprintf(subname, sizeof(subname), "%s()", fname); lua_getglobal(L, fname); // Push function into stack lua_remove(L, 1); // Remove string from stack @@ -288,7 +288,7 @@ static int lua_cb_register_generic(lua_State *L, int type) /* {{{ */ } else { lua_getfield(L, LUA_REGISTRYINDEX, "collectd:callback_num"); int tmp = lua_tointeger(L, -1); - snprintf(subname, sizeof(subname), "callback_%d", tmp); + ssnprintf(subname, sizeof(subname), "callback_%d", tmp); lua_pop(L, 1); // Remove old value from stack lua_pushinteger(L, tmp + 1); lua_setfield(L, LUA_REGISTRYINDEX, "collectd:callback_num"); // pops value @@ -298,8 +298,8 @@ static int lua_cb_register_generic(lua_State *L, int type) /* {{{ */ lua_getfield(L, LUA_REGISTRYINDEX, "collectd:script_path"); char function_name[DATA_MAX_NAME_LEN]; - snprintf(function_name, sizeof(function_name), "lua/%s/%s", - lua_tostring(L, -1), subname); + ssnprintf(function_name, sizeof(function_name), "lua/%s/%s", + lua_tostring(L, -1), subname); lua_pop(L, 1); int callback_id = clua_store_callback(L, 1); @@ -322,14 +322,14 @@ static int lua_cb_register_generic(lua_State *L, int type) /* {{{ */ pthread_mutex_init(&cb->lock, NULL); if (PLUGIN_READ == type) { - int status = - plugin_register_complex_read(/* group = */ "lua", - /* name = */ function_name, - /* callback = */ clua_read, - /* interval = */ 0, - &(user_data_t){ - .data = cb, .free_func = lua_cb_free, - }); + int status = plugin_register_complex_read(/* group = */ "lua", + /* name = */ function_name, + /* callback = */ clua_read, + /* interval = */ 0, + &(user_data_t){ + .data = cb, + .free_func = lua_cb_free, + }); if (status != 0) return luaL_error(L, "%s", "plugin_register_complex_read failed"); @@ -338,7 +338,8 @@ static int lua_cb_register_generic(lua_State *L, int type) /* {{{ */ int status = plugin_register_write(/* name = */ function_name, /* callback = */ clua_write, &(user_data_t){ - .data = cb, .free_func = lua_cb_free, + .data = cb, + .free_func = lua_cb_free, }); if (status != 0) @@ -530,7 +531,7 @@ static int lua_config_script(const oconfig_item_t *ci) /* {{{ */ if (base_path[0] == '\0') sstrncpy(abs_path, rel_path, sizeof(abs_path)); else - snprintf(abs_path, sizeof(abs_path), "%s/%s", base_path, rel_path); + ssnprintf(abs_path, sizeof(abs_path), "%s/%s", base_path, rel_path); DEBUG("Lua plugin: abs_path = \"%s\";", abs_path);