Commit 8b5b7109 authored by Marek Vavruša's avatar Marek Vavruša

lint: enabled several readability linters and fixed issues

this checks things such as inconsistent declarations and definitions
parent 61ad51b6
---
Checks: 'bugprone-*,cert-*,-clang-analyzer-unix.Malloc,-clang-analyzer-deadcode.DeadStores,-clang-analyzer-valist.Uninitialized,-readability-*,-readability-braces-*,-readability-else-after-return,google-readability-casting,misc-*,-misc-macro-parentheses,-misc-unused-parameters'
Checks: 'bugprone-*,cert-*,-clang-analyzer-unix.Malloc,-clang-analyzer-deadcode.DeadStores,-clang-analyzer-valist.Uninitialized,readability-*,-readability-braces-*,-readability-else-after-return,-readability-redundant-declaration,-readability-non-const-parameter,google-readability-casting,misc-*,-misc-macro-parentheses,-misc-unused-parameters'
WarningsAsErrors: 'cert-*,misc-*,readability-*,clang-analyzer-*,-readability-non-const-parameter'
HeaderFilterRegex: 'contrib/ucw/*.h'
CheckOptions:
......
......@@ -35,7 +35,7 @@
FILE *g_tty = NULL; //!< connection to the daemon
static char *run_cmd(const char *cmd, size_t * msg_len);
static char *run_cmd(const char *cmd, size_t * out_len);
const char *prompt(EditLine * e)
{
......
......@@ -86,8 +86,8 @@ int engine_ipc(struct engine *engine, const char *expr);
*/
int engine_start(struct engine *engine, const char *config_path);
void engine_stop(struct engine *engine);
int engine_register(struct engine *engine, const char *module, const char *precedence, const char* ref);
int engine_unregister(struct engine *engine, const char *module);
int engine_register(struct engine *engine, const char *name, const char *precedence, const char* ref);
int engine_unregister(struct engine *engine, const char *name);
void engine_lualib(struct engine *engine, const char *name, int (*lib_cb) (struct lua_State *));
......
......@@ -71,7 +71,7 @@ int tls_process(struct worker_ctx *worker, uv_stream_t *handle, const uint8_t *b
int tls_certificate_set(struct network *net, const char *tls_cert, const char *tls_key);
/*! Borrow TLS credentials for context. */
struct tls_credentials *tls_credentials_reserve(struct tls_credentials *worker);
struct tls_credentials *tls_credentials_reserve(struct tls_credentials *tls_credentials);
/*! Release TLS credentials for context (decrements refcount or frees). */
int tls_credentials_release(struct tls_credentials *tls_credentials);
......
......@@ -104,14 +104,14 @@ static int worker_add_tcp_connected(struct worker_ctx *worker,
static int worker_del_tcp_connected(struct worker_ctx *worker,
const struct sockaddr *addr);
static struct session* worker_find_tcp_connected(struct worker_ctx *worker,
const struct sockaddr *srv);
const struct sockaddr *addr);
static int worker_add_tcp_waiting(struct worker_ctx *worker,
const struct sockaddr *addr,
struct session *session);
static int worker_del_tcp_waiting(struct worker_ctx *worker,
const struct sockaddr *addr);
static struct session* worker_find_tcp_waiting(struct worker_ctx *worker,
const struct sockaddr *srv);
const struct sockaddr *addr);
static int session_add_waiting(struct session *session, struct qr_task *task);
static int session_del_waiting(struct session *session, struct qr_task *task);
static int session_add_tasks(struct session *session, struct qr_task *task);
......@@ -1700,7 +1700,7 @@ static struct qr_task* find_task(const struct session *session, uint16_t msg_id)
int worker_submit(struct worker_ctx *worker, uv_handle_t *handle,
knot_pkt_t *msg, const struct sockaddr* addr)
knot_pkt_t *query, const struct sockaddr* addr)
{
bool OK = worker && handle && handle->data;
if (!OK) {
......@@ -1711,15 +1711,15 @@ int worker_submit(struct worker_ctx *worker, uv_handle_t *handle,
struct session *session = handle->data;
/* Parse packet */
int ret = parse_packet(msg);
int ret = parse_packet(query);
/* Start new task on listening sockets,
* or resume if this is subrequest */
struct qr_task *task = NULL;
if (!session->outgoing) { /* request from a client */
/* Ignore badly formed queries or responses. */
if (!msg || ret != 0 || knot_wire_get_qr(msg->wire)) {
if (msg) worker->stats.dropped += 1;
if (!query || ret != 0 || knot_wire_get_qr(query->wire)) {
if (query) worker->stats.dropped += 1;
return kr_error(EILSEQ);
}
struct request_ctx *ctx = request_create(worker, handle, addr);
......@@ -1727,7 +1727,7 @@ int worker_submit(struct worker_ctx *worker, uv_handle_t *handle,
return kr_error(ENOMEM);
}
ret = request_start(ctx, msg);
ret = request_start(ctx, query);
if (ret != 0) {
request_free(ctx);
return kr_error(ENOMEM);
......@@ -1738,8 +1738,8 @@ int worker_submit(struct worker_ctx *worker, uv_handle_t *handle,
request_free(ctx);
return kr_error(ENOMEM);
}
} else if (msg) { /* response from upstream */
task = find_task(session, knot_wire_get_id(msg->wire));
} else if (query) { /* response from upstream */
task = find_task(session, knot_wire_get_id(query->wire));
if (task == NULL) {
return kr_error(ENOENT);
}
......@@ -1748,7 +1748,7 @@ int worker_submit(struct worker_ctx *worker, uv_handle_t *handle,
assert(uv_is_closing(session->handle) == false);
/* Consume input and produce next message */
return qr_task_step(task, NULL, msg);
return qr_task_step(task, NULL, query);
}
static int map_add_tcp_session(map_t *map, const struct sockaddr* addr,
......
......@@ -290,7 +290,7 @@ int kr_cache_clear(struct kr_cache *cache)
return ret;
}
int kr_cache_match(struct kr_cache *cache, uint8_t tag, const knot_dname_t *name, knot_db_val_t *val, int maxcount)
int kr_cache_match(struct kr_cache *cache, uint8_t tag, const knot_dname_t *name, knot_db_val_t *vals, int valcnt)
{
if (!cache_isvalid(cache) || !name ) {
return kr_error(EINVAL);
......@@ -307,7 +307,7 @@ int kr_cache_match(struct kr_cache *cache, uint8_t tag, const knot_dname_t *name
/* Trim type from the search key */
knot_db_val_t key = { keybuf, key_len - 2 };
return cache_op(cache, match, &key, val, maxcount);
return cache_op(cache, match, &key, vals, valcnt);
}
int kr_cache_peek_rr(struct kr_cache *cache, knot_rrset_t *rr, uint8_t *rank, uint8_t *flags, uint32_t *timestamp)
......
......@@ -48,7 +48,7 @@ typedef struct {
} cb_node_t;
/* Return true if ptr is internal node. */
static inline int ref_is_internal(uint8_t *p)
static inline int ref_is_internal(const uint8_t *p)
{
return 1 & (intptr_t)p;
}
......@@ -168,7 +168,7 @@ EXPORT void *map_get(map_t *map, const char *str)
}
/*! Inserts str into map, returns 0 on success */
EXPORT int map_set(map_t *map, const char *str, void *value)
EXPORT int map_set(map_t *map, const char *str, void *val)
{
const uint8_t *const ubytes = (void *)str;
const size_t ulen = strlen(str);
......@@ -182,7 +182,7 @@ EXPORT int map_set(map_t *map, const char *str, void *value)
void **wherep = NULL;
if (p == NULL) {
map->root = cbt_make_data(map, (const uint8_t *)str, ulen + 1, value);
map->root = cbt_make_data(map, (const uint8_t *)str, ulen + 1, val);
if (map->root == NULL) {
return ENOMEM;
}
......@@ -212,7 +212,7 @@ EXPORT int map_set(map_t *map, const char *str, void *value)
newotherbits = data->key[newbyte];
goto different_byte_found;
}
data->value = value;
data->value = val;
return 1;
different_byte_found:
......@@ -228,7 +228,7 @@ EXPORT int map_set(map_t *map, const char *str, void *value)
return ENOMEM;
}
x = (uint8_t *)cbt_make_data(map, ubytes, ulen + 1, value);
x = (uint8_t *)cbt_make_data(map, ubytes, ulen + 1, val);
if (x == NULL) {
map->free(map->baton, newnode);
return ENOMEM;
......
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