Skip to content
Snippets Groups Projects
Commit ca602576 authored by Maxim Menshikov's avatar Maxim Menshikov
Browse files

qosmngr: fix errors reported by static analysis

parent 48e212bb
Branches mmenshikov-qosmngr-cflags
No related tags found
1 merge request!13qosmngr: consider more warnings as errors and fix discovered issues
Pipeline #79819 passed
......@@ -128,7 +128,7 @@ static int get_interface_index(const char *ifname)
* @param none
* retrun integer value 0 on success and -1 on failure
*/
static int init_qstat()
static int init_qstat(void)
{
int ret = 0;
int index = 0;
......@@ -169,9 +169,9 @@ static int init_qstat()
if (uci_sec) {
qos_interface_data *data = &interfaces[index];
struct uci_option *uci_opn = uci_lookup_option(uci_ctx, uci_sec, "ifname");
int queues;
size_t queues;
queues = get_no_queues(uci_opn->v.string);
queues = (size_t)get_no_queues(uci_opn->v.string);
strcpy(data->if_name, uci_opn->v.string);
data->q_count = queues;
data->q_stat = (struct qos_stats *)calloc(queues,
......@@ -260,11 +260,11 @@ static int prepare_stats_blob(struct blob_buf *b, struct qos_stats *stats, void
dd = blobmsg_open_table(b, "");
blobmsg_add_string(b, "iface", ifname);
blobmsg_add_u32(b, "qid", qid);
blobmsg_add_u32(b, "tx_packets", q_stat->tx_packets);
blobmsg_add_u32(b, "tx_bytes", q_stat->tx_bytes);
blobmsg_add_u32(b, "tx_dropped_packets", q_stat->tx_dropped_packets);
blobmsg_add_u32(b, "tx_dropped_bytes", q_stat->tx_dropped_bytes);
blobmsg_add_u32(b, "qid", (uint32_t)qid);
blobmsg_add_u32(b, "tx_packets", (uint32_t)q_stat->tx_packets);
blobmsg_add_u32(b, "tx_bytes", (uint32_t)q_stat->tx_bytes);
blobmsg_add_u32(b, "tx_dropped_packets", (uint32_t)q_stat->tx_dropped_packets);
blobmsg_add_u32(b, "tx_dropped_bytes", (uint32_t)q_stat->tx_dropped_bytes);
blobmsg_close_table(b, dd);
......@@ -347,15 +347,15 @@ static int get_stats_for_all_intf(struct blob_buf *b, struct qos_stats *stats, v
*/
static int validate_keys(char *req_json)
{
int i;
size_t i;
int ret = 0;
int len = strlen(req_json);
size_t len = strlen(req_json);
for (i = 0; i < len; i++) {
if (req_json[i] == QUOTE) {
char key[IFNAMSIZ] = {0};
int j = 0;
size_t j = 0;
i++;
while ((i < len) && (req_json[i] != QUOTE)) {
......@@ -436,7 +436,7 @@ int qosmngr_get_stats(struct ubus_context *ctx, struct ubus_object *obj,
/* Parse optional arguments */
if (tb[QOS_POLICY_QID])
qid = blobmsg_get_u32(tb[QOS_POLICY_QID]);
qid = (int)blobmsg_get_u32(tb[QOS_POLICY_QID]);
/* Can't have a queue id specified without an interface */
if (tb[QOS_POLICY_QID] && !tb[QOS_POLICY_IFNAME])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment