/* Select cache storage backend */
struct engine *engine = engine_luaget(L);
- lua_Number csize_lua = lua_tointeger(L, 1);
+ lua_Integer csize_lua = lua_tointeger(L, 1);
if (!(csize_lua >= 8192 && csize_lua < SIZE_MAX)) { /* min. is basically arbitrary */
lua_error_p(L, "invalid cache size specified, it must be in range <8192, "
STR(SIZE_MAX) ">");
#define LAYER_FFI_CALL(ctx, slot_name) \
const int *cb_slot = (ctx)->api->cb_slots + SLOT_ ## slot_name; \
if (*cb_slot <= 0) { \
- return ctx->state; \
+ return (ctx)->state; \
} \
struct kr_module *module = (ctx)->api->data; \
lua_State *L = module->lib; \
lua_rawgeti(L, LUA_REGISTRYINDEX, *cb_slot); \
- lua_pushnumber(L, ctx->state)
+ lua_pushnumber(L, (ctx)->state)
static int l_ffi_layer_begin(kr_layer_t *ctx)
{
#include "daemon/session.h"
#define negotiate_bufsize(func, handle, bufsize_want) do { \
- int bufsize = 0; func(handle, &bufsize); \
- if (bufsize < bufsize_want) { \
- bufsize = bufsize_want; \
- func(handle, &bufsize); \
+ int bufsize = 0; (func)((handle), &bufsize); \
+ if (bufsize < (bufsize_want)) { \
+ bufsize = (bufsize_want); \
+ (func)((handle), &bufsize); \
} \
} while (0)
char buf[INET6_ADDRSTRLEN + 1];
const char *addr = kr_straddr_split(addr_set->at[i], buf, &port);
/* NULL will result into kr_strerror(EINVAL) -> correct. */
- int ret = network_listen(net, addr, (uint16_t)port, flags);
+ int ret = network_listen(net, addr, port, flags);
if (ret != 0) {
kr_log_error("[system] bind to '%s@%d' %s%s\n",
addr, port, tls ? "(TLS) " : "", kr_strerror(ret));
assert(bpffd != NULL);
for (size_t i = 0; i < endpoints->len; i++) {
- struct endpoint *endpoint = (struct endpoint *)endpoints->at[i];
+ struct endpoint *endpoint = endpoints->at[i];
uv_os_fd_t sockfd = -1;
if (endpoint->tcp != NULL) uv_fileno((const uv_handle_t *)endpoint->tcp, &sockfd);
if (endpoint->udp != NULL) uv_fileno((const uv_handle_t *)endpoint->udp, &sockfd);
assert(endpoints != NULL);
for (size_t i = 0; i < endpoints->len; i++) {
- struct endpoint *endpoint = (struct endpoint *)endpoints->at[i];
+ struct endpoint *endpoint = endpoints->at[i];
uv_os_fd_t sockfd = -1;
if (endpoint->tcp != NULL) uv_fileno((const uv_handle_t *)endpoint->tcp, &sockfd);
if (endpoint->udp != NULL) uv_fileno((const uv_handle_t *)endpoint->udp, &sockfd);
#include "daemon/worker.h"
#include "daemon/session.h"
-#define EPHEMERAL_CERT_EXPIRATION_SECONDS_RENEW_BEFORE 60*60*24*7
+#define EPHEMERAL_CERT_EXPIRATION_SECONDS_RENEW_BEFORE (60*60*24*7)
#define GNUTLS_PIN_MIN_VERSION 0x030400
/** @internal Debugging facility. */
DNS-over-TLS OOB key-pins: https://tools.ietf.org/html/rfc7858#appendix-A
HPKP pin reference: https://tools.ietf.org/html/rfc7469#appendix-A
*/
-#define PINLEN (((32) * 8 + 4)/6) + 3 + 1
+#define PINLEN ((((32) * 8 + 4)/6) + 3 + 1)
/* out must be at least PINLEN octets long */
static int get_oob_key_pin(gnutls_x509_crt_t crt, char *outchar, ssize_t outchar_len)
#define EPHEMERAL_PRIVKEY_FILENAME "ephemeral_key.pem"
#define INVALID_HOSTNAME "dns-over-tls.invalid"
-#define EPHEMERAL_CERT_EXPIRATION_SECONDS 60*60*24*90
+#define EPHEMERAL_CERT_EXPIRATION_SECONDS (60*60*24*90)
/* This is an attempt to grab an exclusive, advisory, non-blocking
* lock based on a filename. At the moment it's POSIX-only, but it
#define qr_task_ref(task) \
do { ++(task)->refs; } while(0)
#define qr_task_unref(task) \
- do { if (task && --(task)->refs == 0) { qr_task_free(task); } } while (0)
+ do { if ((task) && --(task)->refs == 0) { qr_task_free((task)); } } while (0)
/** @internal get key for tcp session
* @note kr_straddr() return pointer to static string
* Having this separate might be meaningful for performance optimization.
*/
#define TWIGOFFMAX(off, max, t, b) do { \
- off = twigoff(t, b); \
- max = bitmap_weight(t->branch.bitmap); \
+ (off) = twigoff((t), (b)); \
+ (max) = bitmap_weight((t)->branch.bitmap);\
} while(0)
/*! \brief Simple string comparator. */
}
/* Randomize query case (if secret changed) */
- knot_dname_t *qname = (knot_dname_t *)knot_pkt_qname(packet);
+ knot_dname_t *qname = knot_pkt_qname(packet);
if (qry->secret != old_minimization_secret) {
randomized_qname_case(qname, qry->secret);
}
#include "lib/layer.h"
#define VERBOSE_MSG(qry, ...) QRVERBOSE(qry, "plan", __VA_ARGS__)
-#define QUERY_PROVIDES(q, name, cls, type) \
- ((q)->sclass == (cls) && (q)->stype == type && knot_dname_is_equal((q)->sname, name))
inline static unsigned char chars_or(const unsigned char a, const unsigned char b)
{
bool kr_rplan_satisfies(struct kr_query *closure, const knot_dname_t *name, uint16_t cls, uint16_t type)
{
while (name && closure) {
- if (QUERY_PROVIDES(closure, name, cls, type)) {
+ if (closure->sclass == cls && closure->stype == type
+ && knot_dname_is_equal(closure->sname, name)) {
return true;
}
closure = closure->parent;
JsonNode *root_node = args ? json_decode(args) : NULL;
if (root_node && root_node->tag == JSON_NUMBER) {
double ttl_d = root_node->number_;
- uint32_t ttl = round(ttl_d);
+ uint32_t ttl = (uint32_t)round(ttl_d);
if (ttl_d >= 0 && fabs(ttl_d - ttl) * 64 < 1) {
data->ttl = ttl;
}