Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve issues from static analyzer report. #970

Merged
merged 2 commits into from
Mar 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions tempesta_fw/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1620,13 +1620,14 @@ cache_req_process_node(TfwHttpReq *req, tfw_http_cache_cb_t action)
if (!tfw_handle_validation_req(req, ce))
goto put;

resp = tfw_cache_build_resp(req, ce);
if (!(resp = tfw_cache_build_resp(req, ce)))
goto out;
/*
* RFC 7234 p.4 Constructing Responses from Caches:
* When a stored response is used to satisfy a request without
* validation, a cache MUST generate an Age header field.
*/
if (resp && tfw_cache_set_hdr_age((TfwHttpMsg *)resp, ce)) {
if (tfw_cache_set_hdr_age((TfwHttpMsg *)resp, ce)) {
TFW_WARN("Unable to add Age: header, cached"
" response [%p] dropped\n", resp);
TFW_INC_STAT_BH(clnt.msgs_otherr);
Expand Down
12 changes: 9 additions & 3 deletions tempesta_fw/sched/tfw_sched_ratio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1044,17 +1044,20 @@ tfw_sched_ratio_srvdesc_setup_srv(TfwServer *srv, TfwRatioSrvDesc *srvdesc)
conn = srvdesc->conn;
list_for_each_entry(srv_conn, &srv->conn_list, list) {
if (unlikely(ci++ == srv->conn_n))
return -EINVAL;
goto err;
*conn++ = srv_conn;
}
if (unlikely(ci != srv->conn_n))
return -EINVAL;
goto err;

srvdesc->conn_n = srv->conn_n;
srvdesc->srv = srv;
atomic64_set(&srvdesc->counter, 0);

return 0;
err:
kfree(srvdesc->conn);
return -EINVAL;
}

/**
Expand Down Expand Up @@ -1258,8 +1261,10 @@ tfw_sched_ratio_add_srv(TfwServer *srv)

if (!(srvdesc = kzalloc(sizeof(TfwRatioSrvDesc), GFP_KERNEL)))
return -ENOMEM;
if ((r = tfw_sched_ratio_srvdesc_setup_srv(srv, srvdesc)))
if ((r = tfw_sched_ratio_srvdesc_setup_srv(srv, srvdesc))) {
kfree(srvdesc);
return r;
}

rcu_assign_pointer(srv->sched_data, srvdesc);

Expand All @@ -1270,6 +1275,7 @@ static void
tfw_sched_ratio_put_srv_data(struct rcu_head *rcu)
{
TfwRatioSrvDesc *srvdesc = container_of(rcu, TfwRatioSrvDesc, rcu);
kfree(srvdesc->conn);
kfree(srvdesc);
}

Expand Down
2 changes: 1 addition & 1 deletion tempesta_fw/t/unit/test_http_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ split_and_parse_n(unsigned char *str, int type, size_t len, size_t chunks)
static int
set_sample_req(unsigned char *str)
{
size_t len = len = strlen(str);
size_t len = strlen(str);
int r;

if (sample_req)
Expand Down