Commit c5e093bd authored by Ondřej Surý's avatar Ondřej Surý

Convert all named variadic macros to ISO C __VA_ARGS__ (with ## extension)

parent 3afe1620
......@@ -57,8 +57,8 @@ static void test_int(const char *in, int expected, int errcode)
}
// mute warn_unused_result
#define asprintf(args...) do { \
int r = (asprintf)(args); assert(r >= 0); \
#define asprintf(args, ...) do { \
int r = (asprintf)(args, ##__VA_ARGS__); assert(r >= 0); \
} while (0);
int main(int argc, char *argv[])
......
This diff is collapsed.
......@@ -154,26 +154,26 @@ int log_msg_zone_str(int priority, const char *zone, const char *fmt, ...)
/* Convenient logging. */
#define log_fatal(msg...) log_msg(LOG_CRIT, msg)
#define log_error(msg...) log_msg(LOG_ERR, msg)
#define log_warning(msg...) log_msg(LOG_WARNING, msg)
#define log_notice(msg...) log_msg(LOG_NOTICE, msg)
#define log_info(msg...) log_msg(LOG_INFO, msg)
#define log_debug(msg...) log_msg(LOG_DEBUG, msg)
#define log_zone_fatal(zone, msg...) log_msg_zone(LOG_CRIT, zone, msg)
#define log_zone_error(zone, msg...) log_msg_zone(LOG_ERR, zone, msg)
#define log_zone_warning(zone, msg...) log_msg_zone(LOG_WARNING, zone, msg)
#define log_zone_notice(zone, msg...) log_msg_zone(LOG_NOTICE, zone, msg)
#define log_zone_info(zone, msg...) log_msg_zone(LOG_INFO, zone, msg)
#define log_zone_debug(zone, msg...) log_msg_zone(LOG_DEBUG, zone, msg)
#define log_zone_str_fatal(zone, msg...) log_msg_zone_str(LOG_CRIT, zone, msg)
#define log_zone_str_error(zone, msg...) log_msg_zone_str(LOG_ERR, zone, msg)
#define log_zone_str_warning(zone, msg...) log_msg_zone_str(LOG_WARNING, zone, msg)
#define log_zone_str_notice(zone, msg...) log_msg_zone_str(LOG_NOTICE, zone, msg)
#define log_zone_str_info(zone, msg...) log_msg_zone_str(LOG_INFO, zone, msg)
#define log_zone_str_debug(zone, msg...) log_msg_zone_str(LOG_DEBUG, zone, msg)
#define log_fatal(msg, ...) log_msg(LOG_CRIT, msg, ##__VA_ARGS__)
#define log_error(msg, ...) log_msg(LOG_ERR, msg, ##__VA_ARGS__)
#define log_warning(msg, ...) log_msg(LOG_WARNING, msg, ##__VA_ARGS__)
#define log_notice(msg, ...) log_msg(LOG_NOTICE, msg, ##__VA_ARGS__)
#define log_info(msg, ...) log_msg(LOG_INFO, msg, ##__VA_ARGS__)
#define log_debug(msg, ...) log_msg(LOG_DEBUG, msg, ##__VA_ARGS__)
#define log_zone_fatal(zone, msg, ...) log_msg_zone(LOG_CRIT, zone, msg, ##__VA_ARGS__)
#define log_zone_error(zone, msg, ...) log_msg_zone(LOG_ERR, zone, msg, ##__VA_ARGS__)
#define log_zone_warning(zone, msg, ...) log_msg_zone(LOG_WARNING, zone, msg, ##__VA_ARGS__)
#define log_zone_notice(zone, msg, ...) log_msg_zone(LOG_NOTICE, zone, msg, ##__VA_ARGS__)
#define log_zone_info(zone, msg, ...) log_msg_zone(LOG_INFO, zone, msg, ##__VA_ARGS__)
#define log_zone_debug(zone, msg, ...) log_msg_zone(LOG_DEBUG, zone, msg, ##__VA_ARGS__)
#define log_zone_str_fatal(zone, msg, ...) log_msg_zone_str(LOG_CRIT, zone, msg, ##__VA_ARGS__)
#define log_zone_str_error(zone, msg, ...) log_msg_zone_str(LOG_ERR, zone, msg, ##__VA_ARGS__)
#define log_zone_str_warning(zone, msg, ...) log_msg_zone_str(LOG_WARNING, zone, msg, ##__VA_ARGS__)
#define log_zone_str_notice(zone, msg, ...) log_msg_zone_str(LOG_NOTICE, zone, msg, ##__VA_ARGS__)
#define log_zone_str_info(zone, msg, ...) log_msg_zone_str(LOG_INFO, zone, msg, ##__VA_ARGS__)
#define log_zone_str_debug(zone, msg, ...) log_msg_zone_str(LOG_DEBUG, zone, msg, ##__VA_ARGS__)
/*!
* \brief Update open files ownership.
......
......@@ -31,7 +31,7 @@ const yp_item_t scheme_mod_dnsproxy[] = {
};
/* Defines. */
#define MODULE_ERR(msg...) log_error("module 'dnsproxy', " msg)
#define MODULE_ERR(msg, ...) log_error("module 'dnsproxy', " msg, ##__VA_ARGS__)
struct dnsproxy {
struct sockaddr_storage remote;
......
......@@ -36,7 +36,7 @@ const yp_item_t scheme_mod_dnstap[] = {
};
/* Defines. */
#define MODULE_ERR(msg...) log_error("module 'dnstap', " msg)
#define MODULE_ERR(msg, ...) log_error("module 'dnstap', " msg, ##__VA_ARGS__)
static int log_message(int state, const knot_pkt_t *pkt, struct query_data *qdata, void *ctx)
{
......
......@@ -340,7 +340,7 @@ int cache_remove(MDB_txn *txn, MDB_dbi dbi, const knot_dname_t *name)
#define DEFAULT_PORT 514
#define SYSLOG_BUFLEN 1024 /* RFC3164, 4.1 message size. */
#define SYSLOG_FACILITY 3 /* System daemon. */
#define MODULE_ERR(msg...) log_error("module 'rose', " msg)
#define MODULE_ERR(msg, ...) log_error("module 'rose', " msg, ##__VA_ARGS__)
/*! \brief Safe stream skipping. */
static int stream_skip(char **stream, size_t *maxlen, int nbytes)
......@@ -356,8 +356,8 @@ static int stream_skip(char **stream, size_t *maxlen, int nbytes)
}
/*! \brief Stream write with constraints checks. */
#define STREAM_WRITE(stream, maxlen, fn, args...) \
if (stream_skip(&(stream), (maxlen), fn(stream, *(maxlen), args)) != KNOT_EOK) { \
#define STREAM_WRITE(stream, maxlen, fn, args, ...) \
if (stream_skip(&(stream), (maxlen), fn(stream, *(maxlen), args, ##__VA_ARGS__)) != KNOT_EOK) { \
return KNOT_ESPACE; \
}
......
......@@ -74,7 +74,7 @@ const yp_item_t scheme_mod_synth_record[] = {
/* Defines. */
#define ARPA_ZONE_LABELS 2
#define MODULE_ERR(msg...) log_error("module 'synth_record', " msg)
#define MODULE_ERR(msg, ...) log_error("module 'synth_record', " msg, ##__VA_ARGS__)
/*!
* \brief Synthetic response template.
......
......@@ -209,8 +209,8 @@ int xfr_process_list(knot_pkt_t *pkt, xfr_put_cb process_item,
}
/* AXFR-specific logging (internal, expects 'qdata' variable set). */
#define AXFROUT_LOG(severity, msg...) \
QUERY_LOG(severity, qdata, "AXFR, outgoing", msg)
#define AXFROUT_LOG(severity, msg, ...) \
QUERY_LOG(severity, qdata, "AXFR, outgoing", msg, ##__VA_ARGS__)
int axfr_query_process(knot_pkt_t *pkt, struct query_data *qdata)
{
......@@ -307,8 +307,8 @@ static int axfr_answer_init(struct answer_data *data)
}
/* AXFR-specific logging (internal, expects 'adata' variable set). */
#define AXFRIN_LOG(severity, msg...) \
ANSWER_LOG(severity, adata, "AXFR, incoming", msg)
#define AXFRIN_LOG(severity, msg, ...) \
ANSWER_LOG(severity, adata, "AXFR, incoming", msg, ##__VA_ARGS__)
static int axfr_answer_finalize(struct answer_data *adata)
{
......
......@@ -58,8 +58,8 @@ struct ixfr_proc {
};
/* IXFR-out-specific logging (internal, expects 'qdata' variable set). */
#define IXFROUT_LOG(severity, msg...) \
QUERY_LOG(severity, qdata, "IXFR, outgoing", msg)
#define IXFROUT_LOG(severity, msg, ...) \
QUERY_LOG(severity, qdata, "IXFR, outgoing", msg, ##__VA_ARGS__)
/*! \brief Helper macro for putting RRs into packet. */
#define IXFR_SAFE_PUT(pkt, rr) \
......@@ -331,8 +331,8 @@ static int ixfr_answer_soa(knot_pkt_t *pkt, struct query_data *qdata)
/* ------------------------- IXFR-in processing ----------------------------- */
/* IXFR-in-specific logging (internal, expects 'adata' variable set). */
#define IXFRIN_LOG(severity, msg...) \
ANSWER_LOG(severity, adata, "IXFR, incoming", msg)
#define IXFRIN_LOG(severity, msg, ...) \
ANSWER_LOG(severity, adata, "IXFR, incoming", msg, ##__VA_ARGS__)
/*! \brief Checks whether server responded with AXFR-style IXFR. */
static bool ixfr_is_axfr(const knot_pkt_t *pkt)
......
......@@ -43,8 +43,8 @@
/*----------------------------------------------------------------------------*/
/* NOTIFY-specific logging (internal, expects 'qdata' variable set). */
#define NOTIFY_QLOG(severity, msg...) \
QUERY_LOG(severity, qdata, "NOTIFY, incoming", msg)
#define NOTIFY_QLOG(severity, msg, ...) \
QUERY_LOG(severity, qdata, "NOTIFY, incoming", msg, ##__VA_ARGS__)
static int notify_check_query(struct query_data *qdata)
{
......@@ -110,8 +110,8 @@ int notify_process_query(knot_pkt_t *pkt, struct query_data *qdata)
#undef NOTIFY_QLOG
/* NOTIFY-specific logging (internal, expects 'adata' variable set). */
#define NOTIFY_RLOG(severity, msg...) \
ANSWER_LOG(severity, adata, "NOTIFY, outgoing", msg)
#define NOTIFY_RLOG(severity, msg, ...) \
ANSWER_LOG(severity, adata, "NOTIFY, outgoing", msg, ##__VA_ARGS__)
int notify_process_answer(knot_pkt_t *pkt, struct answer_data *adata)
{
......
......@@ -34,9 +34,9 @@ const knot_layer_api_t *process_answer_layer(void);
#define KNOT_STATE_ANSWER process_answer_layer()
/*! \brief Answer processing logging base. */
#define ANSWER_LOG(severity, data, operation, msg...) \
#define ANSWER_LOG(severity, data, operation, msg, ...) \
NS_PROC_LOG(severity, (data)->param->remote, (data)->param->zone->name, \
operation, msg);
operation, msg, ##__VA_ARGS__);
/*!
* \brief Processing module parameters.
......
......@@ -43,9 +43,9 @@ const knot_layer_api_t *process_query_layer(void);
} while (0)
/*! \brief Query logging common base. */
#define QUERY_LOG(severity, qdata, operation, msg...) \
#define QUERY_LOG(severity, qdata, operation, msg, ...) \
NS_PROC_LOG(severity, (qdata)->param->remote, knot_pkt_qname((qdata)->query), \
operation, msg);
operation, msg, ##__VA_ARGS__);
/* Query processing specific flags. */
enum process_query_flag {
......
......@@ -38,8 +38,8 @@
#include "libknot/processing/requestor.h"
/* UPDATE-specific logging (internal, expects 'qdata' variable set). */
#define UPDATE_LOG(severity, msg...) \
QUERY_LOG(severity, qdata, "DDNS", msg)
#define UPDATE_LOG(severity, msg, ...) \
QUERY_LOG(severity, qdata, "DDNS", msg, ##__VA_ARGS__)
static void init_qdata_from_request(struct query_data *qdata,
const zone_t *zone,
......
......@@ -46,8 +46,8 @@
/* ------------------------- zone query requesting -------------------------- */
/*! \brief Zone event logging. */
#define ZONE_QUERY_LOG(severity, zone, remote, operation, msg...) \
NS_PROC_LOG(severity, &(remote)->addr, zone->name, operation, msg)
#define ZONE_QUERY_LOG(severity, zone, remote, operation, msg, ...) \
NS_PROC_LOG(severity, &(remote)->addr, zone->name, operation, msg, ##__VA_ARGS__)
/*! \brief Create zone query packet. */
static knot_pkt_t *zone_query(const zone_t *zone, uint16_t pkt_type, mm_ctx_t *mm)
......@@ -152,11 +152,11 @@ fail:
}
/* @note Module specific, expects some variables set. */
#define ZONE_XFER_LOG(severity, pkt_type, msg...) \
#define ZONE_XFER_LOG(severity, pkt_type, msg, ...) \
if (pkt_type == KNOT_QUERY_AXFR) { \
ZONE_QUERY_LOG(severity, zone, master, "AXFR, incoming", msg); \
ZONE_QUERY_LOG(severity, zone, master, "AXFR, incoming", msg, ##__VA_ARGS__); \
} else { \
ZONE_QUERY_LOG(severity, zone, master, "IXFR, incoming", msg); \
ZONE_QUERY_LOG(severity, zone, master, "IXFR, incoming", msg, ##__VA_ARGS__); \
}
/*! \brief Execute zone transfer request. */
......
......@@ -39,9 +39,9 @@
#include "knot/zone/zone-dump.h"
#include "libknot/rrtype/naptr.h"
#define ERROR(zone, fmt...) log_zone_error(zone, "zone loader, " fmt)
#define WARNING(zone, fmt...) log_zone_warning(zone, "zone loader, " fmt)
#define INFO(zone, fmt...) log_zone_info(zone, "zone loader, " fmt)
#define ERROR(zone, fmt, ...) log_zone_error(zone, "zone loader, " fmt, ##__VA_ARGS__)
#define WARNING(zone, fmt, ...) log_zone_warning(zone, "zone loader, " fmt, ##__VA_ARGS__)
#define INFO(zone, fmt, ...) log_zone_info(zone, "zone loader, " fmt, ##__VA_ARGS__)
void process_error(zs_scanner_t *s)
{
......
......@@ -20,12 +20,12 @@
* Returns the index of the found element or @N if no exists. Uses `ary_lt_x(ary,i,x)` to compare the @i'th element with @x.
* The time complexity is `O(log(N))`.
**/
#define BIN_SEARCH_FIRST_GE_CMP(ary,N,ary_lt_x, x...) ({ \
#define BIN_SEARCH_FIRST_GE_CMP(ary, N, ary_lt_x, x, ...) ({ \
uns l = 0, r = (N); \
while (l < r) \
{ \
uns m = (l+r)/2; \
if (ary_lt_x(ary,m,x)) \
if (ary_lt_x(ary, m, x, __VA_ARGS__)) \
l = m+1; \
else \
r = m; \
......
......@@ -112,7 +112,7 @@ static bool hhelem_isequal(hhelem_t *elm, const char *key, uint16_t len)
/*! \brief Binary search index for key. */
#define CMP_I2K(t, k) (t)->item[t->index[k]].d
#define CMP_LE(t,i,x...) (key_cmp(KEY_STR(CMP_I2K(t, i)), key_readlen(CMP_I2K(t, i)), x) <= 0)
#define CMP_LE(t, i, x, ...) (key_cmp(KEY_STR(CMP_I2K(t, i)), key_readlen(CMP_I2K(t, i)), x, __VA_ARGS__) <= 0)
/*! \brief Find matching index + offset. */
static int hhelem_free(hhash_t* tbl, uint32_t id, unsigned dist, value_t *val)
......
......@@ -31,7 +31,7 @@
#define MAX(a, b) \
({ typeof (a) _a = (a); typeof (b) _b = (b); _a > _b ? _a : _b; })
#endif
#define DBG(s...)
#define DBG(s, ...)
/** \note Imported MMAP backend from bigalloc.c */
#define CONFIG_UCW_POOL_IS_MMAP
......
......@@ -33,10 +33,10 @@
#define WARNING_ "; Warning: "
#define DEBUG_ "; Debug: "
#define ERR(m...) { printf(ERROR_ m); fflush(stdout); }
#define INFO(m...) { printf(INFO_ m); fflush(stdout); }
#define WARN(m...) { printf(WARNING_ m); fflush(stdout); }
#define DBG(m...) msg_debug(DEBUG_ m)
#define ERR(msg, ...) { printf(ERROR_ msg, ##__VA_ARGS__); fflush(stdout); }
#define INFO(msg, ...) { printf(INFO_ msg, ##__VA_ARGS__); fflush(stdout); }
#define WARN(msg, ...) { printf(WARNING_ msg, ##__VA_ARGS__); fflush(stdout); }
#define DBG(msg, ...) msg_debug(DEBUG_ msg, ##__VA_ARGS__)
/*! \brief Enable/disable debugging. */
int msg_enable_debug(int val);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment