Commit b9b97d47 authored by Vladimír Čunát's avatar Vladimír Čunát

nitpick fixes for clang-tidy

parent ac1b73be
......@@ -174,7 +174,7 @@ static int cache_open(lua_State *L)
/* 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) ">");
......
......@@ -136,12 +136,12 @@ static int l_ffi_deinit(struct kr_module *module)
#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)
{
......
......@@ -27,10 +27,10 @@
#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)
......
......@@ -635,7 +635,7 @@ static int bind_sockets(struct network *net, addr_array_t *addr_set, bool tls) {
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));
......
......@@ -373,7 +373,7 @@ static int set_bpf_cb(const char *key, void *val, void *ext)
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);
......@@ -415,7 +415,7 @@ static int clear_bpf_cb(const char *key, void *val, void *ext)
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);
......
......@@ -36,7 +36,7 @@
#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. */
......@@ -548,7 +548,7 @@ ssize_t tls_process_input_data(struct session *s, const uint8_t *buf, ssize_t nr
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)
......
......@@ -29,7 +29,7 @@
#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
......
......@@ -97,7 +97,7 @@ struct qr_task
#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
......
......@@ -216,8 +216,8 @@ static node_t* twig(node_t *t, uint i)
* 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. */
......
......@@ -1547,7 +1547,7 @@ int kr_resolve_checkout(struct kr_request *request, const struct sockaddr *src,
}
/* 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);
}
......
......@@ -24,8 +24,6 @@
#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)
{
......@@ -269,7 +267,8 @@ int kr_rplan_pop(struct kr_rplan *rplan, struct kr_query *qry)
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;
......
......@@ -585,7 +585,7 @@ static char* hint_ttl(void *env, struct kr_module *module, const char *args)
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;
}
......
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