gemini-code-assist[bot] commented on code in PR #70:
URL: https://github.com/apache/tvm-ffi/pull/70#discussion_r2388141430
##########
include/tvm/ffi/error.h:
##########
@@ -362,7 +362,7 @@ TVM_FFI_CHECK_FUNC(_NE, !=)
#define TVM_FFI_ICHECK(x) \
if (!(x)) TVM_FFI_THROW(InternalError) << "Check failed: (" #x << ") is
false: "
-#define TVM_FFI_CHECK(ErrorKind, cond) \
+#define TVM_FFI_CHECK(cond, ErrorKind) \
if (!(cond)) TVM_FFI_THROW(ErrorKind) << "Check failed: (" #cond << ") is
false: "
Review Comment:

This macro is not wrapped in a `do { ... } while(0)` block. This can lead to
subtle bugs when used in `if` statements without braces (the 'dangling else'
problem). It's a good practice to wrap statement-like macros in `do-while(0)`
to ensure they behave like a single statement.
Note that the `TVM_FFI_ICHECK` macro defined just above has the same issue
and would benefit from a similar fix.
```c
#define TVM_FFI_CHECK(cond, ErrorKind) \
do { if (!(cond)) TVM_FFI_THROW(ErrorKind) << "Check failed: (" #cond <<
") is false: "; } while (0)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]