Skip to content

[Discussion] macro for error handling #306

@qrsikno2

Description

@qrsikno2

Hi team,

To simplify repetitive error handling, the following macro was proposed:

#define luaxxx_error(code, op, msg)      \
do {                                     \
    pr_err("%s: %s\n", (op), (msg));      \
    return code;                         \
} while (0)

This makes error handling very concise. However, a concern was raised that it hides the return statement, which can make control flow less explicit.

An alternative is the more traditional approach of using a helper function and calling return explicitly, like: if (err = check(...)) { return err; }.

I'm opening this issue to discuss which pattern we should prefer for the project. Should we favor the conciseness of a macro like luaxxx_error, or the clarity of an explicit return?

Looking forward to your thoughts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions