diff options
author | Aleksejs Sestakovs <aleksejs.sestakovs@zabbix.com> | 2022-01-14 17:51:20 +0300 |
---|---|---|
committer | Aleksejs Sestakovs <aleksejs.sestakovs@zabbix.com> | 2022-01-14 17:53:32 +0300 |
commit | 0ce1b8b611649e1980d043a36fdb3939993b207d (patch) | |
tree | 2ed773a208ab19e4c2fb7d18341ace489d876b64 /src | |
parent | 73d6578772209dceb95f16b811360d91ef3ff74e (diff) |
.......PS. [ZBXNEXT-7101] fixed overflow_before_widen warning
* commit '55777a1b0ec1bf9281fa3a50d76279a1dd07fc98':
.......PS. [ZBXNEXT-7101] fixed to use zbx_es_get_env()
.......PS. [ZBXNEXT-7101] fixed overflow_before_widen warning
(cherry picked from commit 538f64e27cd980c7b1adac7d1555c77749118d3e)
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/zbxembed/zabbix.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/libs/zbxembed/zabbix.c b/src/libs/zbxembed/zabbix.c index c9477bdda1f..86ad4a7ecf3 100644 --- a/src/libs/zbxembed/zabbix.c +++ b/src/libs/zbxembed/zabbix.c @@ -128,13 +128,15 @@ out: ******************************************************************************/ static duk_ret_t es_zabbix_sleep(duk_context *ctx) { - zbx_es_env_t *env; - duk_memory_functions out_funcs; - struct timespec ts_sleep; - zbx_uint64_t timeout, duration; - unsigned int sleep_ms; - double sleep_dbl; - duk_idx_t err_idx = -1; + zbx_es_env_t *env; + struct timespec ts_sleep; + zbx_uint64_t timeout, duration; + unsigned int sleep_ms; + double sleep_dbl; + duk_idx_t err_idx = -1; + + if (NULL == (env = zbx_es_get_env(ctx))) + return duk_error(ctx, DUK_ERR_ERROR, "cannot access internal environment"); /* use duk_to_number() instead of duk_to_uint() to distinguish between zero value and error */ sleep_dbl = duk_to_number(ctx, 0); @@ -147,9 +149,7 @@ static duk_ret_t es_zabbix_sleep(duk_context *ctx) else sleep_ms = (unsigned int)sleep_dbl; - duk_get_memory_functions(ctx, &out_funcs); - env = (zbx_es_env_t *)out_funcs.udata; - timeout = (unsigned int)env->timeout * 1000; + timeout = env->timeout <= 0 ? 0 : (zbx_uint64_t)env->timeout * 1000; if (sleep_ms > timeout) { |