<!DOCTYPE html>
<html data-lt-installed="true">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body style="padding-bottom: 1px;">
<p>Hi,<br>
</p>
<div class="moz-cite-prefix">On 19.02.2025 18:41, Sergey Kaplun
wrote:<br>
</div>
<blockquote type="cite" cite="mid:Z7X7t6ZopjqXsPGk@root">
<pre wrap="" class="moz-quote-pre">Hi, Sergey!
Thanks for the fixes!
On 19.02.25, Sergey Bronnikov wrote:
</pre>
<blockquote type="cite">
<pre wrap="" class="moz-quote-pre">Hi, Sergey,
thanks for review!
On 19.02.2025 11:06, Sergey Kaplun via Tarantool-patches wrote:
</pre>
</blockquote>
<pre wrap="" class="moz-quote-pre">
<snipped>
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="" class="moz-quote-pre">It's more LuaJIT-way to use something like the following:
| if (!LJ_HASSYSPROF) {
| /* ... */
| }
This helps to avoid strange early return.
</pre>
</blockquote>
<pre wrap="" class="moz-quote-pre">Fixed.
</pre>
<blockquote type="cite">
<pre wrap="" class="moz-quote-pre">Also, please be avaired to declare all variables (stataus, opt,
err_details) in the beginning of the block.
</pre>
</blockquote>
<pre wrap="" class="moz-quote-pre">
It is a requirement for the code that strictly follows c89, when you
must declare all of your variables at the beginning of a scope block.
AFAIK, we have no such requirement, and also there is no option
"-std=c89" in CI and no any mentions in the contribution guide.
</pre>
</blockquote>
<pre wrap="" class="moz-quote-pre">
This is not mentioned in Tarantool's contribution guide, since it is
LuaJIT-specific. In the perfect world, it should be checked by the flags
mentioned in <src/Makefile.original> (see the second CWARN).
Unfortunately, there are some bugs that should be fixed first.
<snipped>
</pre>
</blockquote>
<p>Fixed:</p>
<p><br>
</p>
<p>diff --git a/src/lib_misc.c b/src/lib_misc.c<br>
index aaf08718..7b934e52 100644<br>
--- a/src/lib_misc.c<br>
+++ b/src/lib_misc.c<br>
@@ -312,15 +312,14 @@ static int sysprof_error(lua_State *L, int
status, const char *err_details)<br>
LJLIB_CF(misc_sysprof_start)<br>
{<br>
const char *err_details = NULL;<br>
+ int status = PROFILE_SUCCESS;<br>
+ struct luam_Sysprof_Options opt = {};<br>
+<br>
if (!LJ_HASSYSPROF) {<br>
err_details = err2msg(LJ_ERR_PROF_DETAILS_DISABLED);<br>
return sysprof_error(L, PROFILE_ERRUSE, err_details);<br>
}<br>
<br>
- int status = PROFILE_SUCCESS;<br>
-<br>
- struct luam_Sysprof_Options opt = {};<br>
-<br>
status = parse_sysprof_opts(L, &opt, &err_details);<br>
if (LJ_UNLIKELY(status != PROFILE_SUCCESS))<br>
return sysprof_error(L, status, err_details);<br>
@@ -337,11 +336,11 @@ LJLIB_CF(misc_sysprof_start)<br>
/* local res, err, errno = profile.sysprof_stop() */<br>
LJLIB_CF(misc_sysprof_stop)<br>
{<br>
+ int status = luaM_sysprof_stop(L);<br>
if (!LJ_HASSYSPROF) {<br>
const char *err_details =
err2msg(LJ_ERR_PROF_DETAILS_DISABLED);<br>
return sysprof_error(L, PROFILE_ERRUSE, err_details);<br>
}<br>
- int status = luaM_sysprof_stop(L);<br>
if (LJ_UNLIKELY(status != PROFILE_SUCCESS))<br>
return sysprof_error(L, status, NULL);<br>
<br>
@@ -352,15 +351,15 @@ LJLIB_CF(misc_sysprof_stop)<br>
/* local counters, err, errno = sysprof.report() */<br>
LJLIB_CF(misc_sysprof_report)<br>
{<br>
+ struct luam_Sysprof_Counters counters = {};<br>
+ GCtab *data_tab = NULL;<br>
+ GCtab *count_tab = NULL;<br>
+ int status = luaM_sysprof_report(&counters);<br>
if (!LJ_HASSYSPROF) {<br>
const char *err_details =
err2msg(LJ_ERR_PROF_DETAILS_DISABLED);<br>
return sysprof_error(L, PROFILE_ERRUSE, err_details);<br>
}<br>
- struct luam_Sysprof_Counters counters = {};<br>
- GCtab *data_tab = NULL;<br>
- GCtab *count_tab = NULL;<br>
<br>
- int status = luaM_sysprof_report(&counters);<br>
if (status != PROFILE_SUCCESS)<br>
return sysprof_error(L, status, NULL);<br>
<br>
@@ -395,14 +394,14 @@ LJLIB_CF(misc_sysprof_report)<br>
/* local started, err, errno = misc.memprof.start(fname) */<br>
LJLIB_CF(misc_memprof_start)<br>
{<br>
- if (!LJ_HASMEMPROF) {<br>
- const char *err_details =
err2msg(LJ_ERR_PROF_DETAILS_DISABLED);<br>
- return sysprof_error(L, PROFILE_ERRUSE, err_details);<br>
- }<br>
struct lj_memprof_options opt = {0};<br>
const char *fname = strdata(lj_lib_checkstr(L, 1));<br>
struct profile_ctx *ctx;<br>
int memprof_status;<br>
+ if (!LJ_HASMEMPROF) {<br>
+ const char *err_details =
err2msg(LJ_ERR_PROF_DETAILS_DISABLED);<br>
+ return sysprof_error(L, PROFILE_ERRUSE, err_details);<br>
+ }<br>
<br>
/*<br>
** FIXME: more elegant solution with ctx.<br>
@@ -453,11 +452,11 @@ LJLIB_CF(misc_memprof_start)<br>
/* local stopped, err, errno = misc.memprof.stop() */<br>
LJLIB_CF(misc_memprof_stop)<br>
{<br>
+ int status = lj_memprof_stop(L);<br>
if (!LJ_HASMEMPROF) {<br>
const char *err_details =
err2msg(LJ_ERR_PROF_DETAILS_DISABLED);<br>
return sysprof_error(L, PROFILE_ERRUSE, err_details);<br>
}<br>
- int status = lj_memprof_stop(L);<br>
if (status != PROFILE_SUCCESS) {<br>
switch (status) {<br>
case PROFILE_ERRUSE:<br>
<br>
</p>
<blockquote type="cite" cite="mid:Z7X7t6ZopjqXsPGk@root">
<pre wrap="" class="moz-quote-pre">
</pre>
</blockquote>
</body>
<lt-container></lt-container>
</html>