Skip to content

Commit

Permalink
Unify ERRMSG1 and ERRMSG2 to ERRMSG_FMT variadic macro
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Apr 7, 2024
1 parent dfa0897 commit b5b54c1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions process.c
Expand Up @@ -3140,9 +3140,13 @@ f_exec(int c, const VALUE *a, VALUE _)
UNREACHABLE_RETURN(Qnil);
}

#define ERRMSG(str) do { if (errmsg && 0 < errmsg_buflen) strlcpy(errmsg, (str), errmsg_buflen); } while (0)
#define ERRMSG1(str, a) do { if (errmsg && 0 < errmsg_buflen) snprintf(errmsg, errmsg_buflen, (str), (a)); } while (0)
#define ERRMSG2(str, a, b) do { if (errmsg && 0 < errmsg_buflen) snprintf(errmsg, errmsg_buflen, (str), (a), (b)); } while (0)
#define ERRMSG(str) \
((errmsg && 0 < errmsg_buflen) ? \
(void)strlcpy(errmsg, (str), errmsg_buflen) : (void)0)

#define ERRMSG_FMT(...) \
((errmsg && 0 < errmsg_buflen) ? \
(void)snprintf(errmsg, errmsg_buflen, __VA_ARGS__) : (void)0)

static int fd_get_cloexec(int fd, char *errmsg, size_t errmsg_buflen);
static int fd_set_cloexec(int fd, char *errmsg, size_t errmsg_buflen);
Expand Down

0 comments on commit b5b54c1

Please sign in to comment.