Skip to content

Conversation

@lneto
Copy link
Contributor

@lneto lneto commented Dec 25, 2025

  • add lunatik_monitor
  • remove unecessary branch on error handling
  • simplify error levels
  • fix style

if (!lua_isboolean(L, -1))
lua_pushinteger(L, -EINVAL);
else
lua_pushinteger(L, 0);
Copy link
Contributor Author

@lneto lneto Dec 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qrsikno2 why should we return 0 if it's not error?

}

LUAHID_CALLBACK(probe, 2, 1, err);
LUAHID_CALLBACK(report_fixup, 4, 0, warn);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qrsikno2 there was any reason to use warn here?

};

static const luaL_Reg luahid_mt[] = {
{"__index", lunatik_monitorobject},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qrsikno2 there was any reason to not use monitor here?

if (luahid_checkdriver(L, hid, -1)) { \
pr_err(#NAME ": invaild driver\n"); \
lua_pushinteger(L, -ENXIO); \
return 1; \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qrsikno2 please check if it will make any difference.. from Lua perspective, it will just discard the return value if there's no assignment

@lneto
Copy link
Contributor Author

lneto commented Dec 25, 2025

@qrsikno2 I noticed that we use both lunatik_run and lunatik_runirq to run different callbacks.. is that guaranteed that the driver will not call them concurrently?

@lneto lneto requested review from carloslack and glk0 December 25, 2025 13:51
lib/luahid.c Outdated
else
lua_pushinteger(L, 0);

lua_pushinteger(L, !lua_isboolean(L, -1) ? EINVAL : 0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you want -EINVAL here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch! thanks!

lneto and others added 3 commits January 1, 2026 20:52
* add lunatik_monitor
* remove unecessary branch on error handling
* simplify error levels and the overall logics
* fix style
Instead of suffixing the callback function with
pre and post, use a proper struct with function
pointers.

Signed-off-by: Ashwani Kumar Kamal <[email protected]>
Copy link
Contributor

@glk0 glk0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing looks bad to me.

@lneto
Copy link
Contributor Author

lneto commented Jan 5, 2026

#366

@lneto lneto closed this Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants