* [Tarantool-patches] [PATCH luajit] test: define UNUSED macros only once
@ 2025-01-29 9:39 Sergey Bronnikov via Tarantool-patches
2025-01-29 14:55 ` Sergey Kaplun via Tarantool-patches
0 siblings, 1 reply; 3+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2025-01-29 9:39 UTC (permalink / raw)
To: tarantool-patches, Sergey Kaplun
The macros `UNUSED` is widely used across the suite
`tarantool-c-tests`. The patch defines macros only once in
`test.h` to reuse it in other tests and removes definitions in
tests.
---
Branch: https://github.com/tarantool/luajit/tree/ligurio/gh-xxxx-define-unused
test/tarantool-c-tests/fix-yield-c-hook.test.c | 2 --
test/tarantool-c-tests/gh-8594-sysprof-ffunc-crash.test.c | 2 --
test/tarantool-c-tests/lj-1168-unmarked-finalizer-tab.test.c | 2 --
test/tarantool-c-tests/lj-549-lua-load.test.c | 2 --
test/tarantool-c-tests/misclib-sysprof-capi.test.c | 2 --
test/tarantool-c-tests/test.h | 2 ++
test/tarantool-c-tests/unit-tap.test.c | 2 --
7 files changed, 2 insertions(+), 12 deletions(-)
diff --git a/test/tarantool-c-tests/fix-yield-c-hook.test.c b/test/tarantool-c-tests/fix-yield-c-hook.test.c
index 0e9fa5d6..aff4a371 100644
--- a/test/tarantool-c-tests/fix-yield-c-hook.test.c
+++ b/test/tarantool-c-tests/fix-yield-c-hook.test.c
@@ -3,8 +3,6 @@
#include "test.h"
#include "utils.h"
-#define UNUSED(x) ((void)(x))
-
/*
* This test demonstrates LuaJIT's incorrect behaviour, when
* calling `lua_yield()` inside a C hook.
diff --git a/test/tarantool-c-tests/gh-8594-sysprof-ffunc-crash.test.c b/test/tarantool-c-tests/gh-8594-sysprof-ffunc-crash.test.c
index 769d333a..2550f43c 100644
--- a/test/tarantool-c-tests/gh-8594-sysprof-ffunc-crash.test.c
+++ b/test/tarantool-c-tests/gh-8594-sysprof-ffunc-crash.test.c
@@ -46,8 +46,6 @@
* * https://github.com/tarantool/tarantool/issues/9387
*/
-#define UNUSED(x) ((void)(x))
-
#define MESSAGE "Canary is alive"
#define LUACALL "local a = tostring('" MESSAGE "') return a"
diff --git a/test/tarantool-c-tests/lj-1168-unmarked-finalizer-tab.test.c b/test/tarantool-c-tests/lj-1168-unmarked-finalizer-tab.test.c
index 9e57efb8..2d54da89 100644
--- a/test/tarantool-c-tests/lj-1168-unmarked-finalizer-tab.test.c
+++ b/test/tarantool-c-tests/lj-1168-unmarked-finalizer-tab.test.c
@@ -3,8 +3,6 @@
#include "test.h"
-#define UNUSED(x) ((void)(x))
-
/*
* This test demonstrates LuaJIT's incorrect behaviour on
* loading Lua chunk with cdata numbers.
diff --git a/test/tarantool-c-tests/lj-549-lua-load.test.c b/test/tarantool-c-tests/lj-549-lua-load.test.c
index 42a14be5..b0e94f6f 100644
--- a/test/tarantool-c-tests/lj-549-lua-load.test.c
+++ b/test/tarantool-c-tests/lj-549-lua-load.test.c
@@ -3,8 +3,6 @@
#include "lj_def.h"
-#define UNUSED(x) ((void)(x))
-
/*
* XXX: In C language, objects with static storage duration have
* to be initialized with constant expressions or with aggregate
diff --git a/test/tarantool-c-tests/misclib-sysprof-capi.test.c b/test/tarantool-c-tests/misclib-sysprof-capi.test.c
index 21e40d22..f0dc4405 100644
--- a/test/tarantool-c-tests/misclib-sysprof-capi.test.c
+++ b/test/tarantool-c-tests/misclib-sysprof-capi.test.c
@@ -18,8 +18,6 @@
/* Need for skipcond for OS and ARCH. */
#include "lj_arch.h"
-#define UNUSED(x) ((void)(x))
-
/* --- utils -------------------------------------------------- */
#define SYSPROF_INTERVAL_DEFAULT 100
diff --git a/test/tarantool-c-tests/test.h b/test/tarantool-c-tests/test.h
index 3b22fb92..c1717932 100644
--- a/test/tarantool-c-tests/test.h
+++ b/test/tarantool-c-tests/test.h
@@ -4,6 +4,8 @@
#include <stdio.h>
#include <stdlib.h>
+#define UNUSED(x) ((void)(x))
+
/*
* Test module, based on TAP 14 specification [1].
* [1]: https://testanything.org/tap-version-14-specification.html
diff --git a/test/tarantool-c-tests/unit-tap.test.c b/test/tarantool-c-tests/unit-tap.test.c
index ca0709ca..1f9a37ef 100644
--- a/test/tarantool-c-tests/unit-tap.test.c
+++ b/test/tarantool-c-tests/unit-tap.test.c
@@ -1,7 +1,5 @@
#include "test.h"
-#define UNUSED(x) ((void)(x))
-
static int test_ok(void *test_state)
{
UNUSED(test_state);
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Tarantool-patches] [PATCH luajit] test: define UNUSED macros only once
2025-01-29 9:39 [Tarantool-patches] [PATCH luajit] test: define UNUSED macros only once Sergey Bronnikov via Tarantool-patches
@ 2025-01-29 14:55 ` Sergey Kaplun via Tarantool-patches
2025-01-30 13:55 ` Sergey Bronnikov via Tarantool-patches
0 siblings, 1 reply; 3+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2025-01-29 14:55 UTC (permalink / raw)
To: Sergey Bronnikov; +Cc: tarantool-patches
Hi, Sergey!
Thanks for the patch!
LGTM, with a minor comment below.
On 29.01.25, Sergey Bronnikov wrote:
> The macros `UNUSED` is widely used across the suite
Typo: s/macros/macro/
> `tarantool-c-tests`. The patch defines macros only once in
Typo: s/macros/macro/
> `test.h` to reuse it in other tests and removes definitions in
> tests.
> ---
>
> Branch: https://github.com/tarantool/luajit/tree/ligurio/gh-xxxx-define-unused
>
<snipped>
> diff --git a/test/tarantool-c-tests/test.h b/test/tarantool-c-tests/test.h
> index 3b22fb92..c1717932 100644
> --- a/test/tarantool-c-tests/test.h
> +++ b/test/tarantool-c-tests/test.h
> @@ -4,6 +4,8 @@
> #include <stdio.h>
> #include <stdlib.h>
>
> +#define UNUSED(x) ((void)(x))
Minor: I suggest to wrapping this into the `#ifndef`, since the
`UNUSED()` is a very common macro. The same one is used in the LuaJIT.
For now these macros are the same [1] but to avoid rewriting code in the
case of the changes, it is better to use `#ifndef` directive here.
> +
> /*
> * Test module, based on TAP 14 specification [1].
> * [1]: https://testanything.org/tap-version-14-specification.html
<snipped>
[1]: https://gcc.gnu.org/onlinedocs/cpp/Undefining-and-Redefining-Macros.html
--
Best regards,
Sergey Kaplun
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Tarantool-patches] [PATCH luajit] test: define UNUSED macros only once
2025-01-29 14:55 ` Sergey Kaplun via Tarantool-patches
@ 2025-01-30 13:55 ` Sergey Bronnikov via Tarantool-patches
0 siblings, 0 replies; 3+ messages in thread
From: Sergey Bronnikov via Tarantool-patches @ 2025-01-30 13:55 UTC (permalink / raw)
To: Sergey Kaplun, Sergey Bronnikov; +Cc: tarantool-patches
[-- Attachment #1: Type: text/plain, Size: 1691 bytes --]
Hi, Sergey,
thanks for review! Changes force-pushed.
Sergey
On 29.01.2025 17:55, Sergey Kaplun via Tarantool-patches wrote:
> Hi, Sergey!
> Thanks for the patch!
> LGTM, with a minor comment below.
>
> On 29.01.25, Sergey Bronnikov wrote:
>> The macros `UNUSED` is widely used across the suite
> Typo: s/macros/macro/
Fixed.
>
>> `tarantool-c-tests`. The patch defines macros only once in
> Typo: s/macros/macro/
Fixed.
>
>> `test.h` to reuse it in other tests and removes definitions in
>> tests.
>> ---
>>
>> Branch:https://github.com/tarantool/luajit/tree/ligurio/gh-xxxx-define-unused
>>
> <snipped>
>
>> diff --git a/test/tarantool-c-tests/test.h b/test/tarantool-c-tests/test.h
>> index 3b22fb92..c1717932 100644
>> --- a/test/tarantool-c-tests/test.h
>> +++ b/test/tarantool-c-tests/test.h
>> @@ -4,6 +4,8 @@
>> #include <stdio.h>
>> #include <stdlib.h>
>>
>> +#define UNUSED(x) ((void)(x))
> Minor: I suggest to wrapping this into the `#ifndef`, since the
> `UNUSED()` is a very common macro. The same one is used in the LuaJIT.
> For now these macros are the same [1] but to avoid rewriting code in the
> case of the changes, it is better to use `#ifndef` directive here.
Updated:
--- a/test/tarantool-c-tests/test.h
+++ b/test/tarantool-c-tests/test.h
@@ -4,7 +4,9 @@
#include <stdio.h>
#include <stdlib.h>
+#ifndef UNUSED
#define UNUSED(x) ((void)(x))
+#endif
/*
* Test module, based on TAP 14 specification [1].
>
>> +
>> /*
>> * Test module, based on TAP 14 specification [1].
>> * [1]:https://testanything.org/tap-version-14-specification.html
> <snipped>
>
> [1]:https://gcc.gnu.org/onlinedocs/cpp/Undefining-and-Redefining-Macros.html
>
[-- Attachment #2: Type: text/html, Size: 3697 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-30 13:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-29 9:39 [Tarantool-patches] [PATCH luajit] test: define UNUSED macros only once Sergey Bronnikov via Tarantool-patches
2025-01-29 14:55 ` Sergey Kaplun via Tarantool-patches
2025-01-30 13:55 ` Sergey Bronnikov via Tarantool-patches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox