Drop unused parameter

value_node_add() ignores it's first argument - let's drop it to make
code more compact.

Change-Id: I17c2fed4049e1c83307feda001aefc006dfbe6a3
This commit is contained in:
Max 2019-01-25 18:40:11 +01:00
parent 4618c73f2b
commit f41973eeb2
7 changed files with 21 additions and 21 deletions

View File

@ -266,7 +266,7 @@ int osysmon_ctrl_init()
static int ctrl_client_poll(struct ctrl_client *cc, struct value_node *parent)
{
struct ctrl_client_get_var *ccgv;
struct value_node *vn_clnt = value_node_add(parent, parent, cc->cfg.name, NULL);
struct value_node *vn_clnt = value_node_add(parent, cc->cfg.name, NULL);
/* attempt to re-connect */
if (!cc->sch)
@ -288,7 +288,7 @@ static int ctrl_client_poll(struct ctrl_client *cc, struct value_node *parent)
return 0;
}
value_node_add(vn_clnt, vn_clnt, ccgv->cfg.name, value);
value_node_add(vn_clnt, ccgv->cfg.name, value);
free(value); /* no talloc, this is from sscanf() */
}
return 0;

View File

@ -82,19 +82,19 @@ static void osysmon_file_read(struct osysmon_file *of, struct value_node *parent
f = fopen(of->cfg.path, "r");
if (!f) {
value_node_add(parent, parent, of->cfg.name, "<NOTFOUND>");
value_node_add(parent, of->cfg.name, "<NOTFOUND>");
return;
}
s = fgets(buf, sizeof(buf), f);
fclose(f);
if (s == NULL) {
value_node_add(parent, parent, of->cfg.name, "<EMPTY>");
value_node_add(parent, of->cfg.name, "<EMPTY>");
return;
}
buf[sizeof(buf)-1] = '\0';
while ((nl = strrchr(buf, '\n')))
*nl = '\0';
value_node_add(parent, parent, of->cfg.name, buf);
value_node_add(parent, of->cfg.name, buf);
}
/***********************************************************************
@ -153,7 +153,7 @@ int osysmon_file_poll(struct value_node *parent)
struct value_node *vn_file;
struct osysmon_file *of;
vn_file = value_node_add(parent, parent, "file", NULL);
vn_file = value_node_add(parent, "file", NULL);
llist_for_each_entry(of, &g_oss->files, list)
osysmon_file_read(of, vn_file);

View File

@ -229,7 +229,7 @@ int main(int argc, char **argv)
}
while (1) {
struct value_node *root = value_node_add(g_oss, NULL, "root", NULL);
struct value_node *root = value_node_add(NULL, "root", NULL);
osysmon_sysinfo_poll(root);
osysmon_ctrl_poll(root);
osysmon_rtnl_poll(root);

View File

@ -216,17 +216,17 @@ static int data_cb(const struct nlmsghdr *nlh, void *data)
uint8_t *hwaddr = mnl_attr_get_payload(tb[IFLA_ADDRESS]);
snprintf(buf, sizeof(buf), "%02x:%02x:%02x:%02x:%02x:%02x",
hwaddr[0], hwaddr[1], hwaddr[2], hwaddr[3], hwaddr[4], hwaddr[5]);
value_node_add(vn_if, vn_if, "hwaddr", buf);
value_node_add(vn_if, "hwaddr", buf);
}
if (ifm->ifi_flags & IFF_RUNNING)
value_node_add(vn_if, vn_if, "running", "true");
value_node_add(vn_if, "running", "true");
else
value_node_add(vn_if, vn_if, "running", "false");
value_node_add(vn_if, "running", "false");
if (ifm->ifi_flags & IFF_UP)
value_node_add(vn_if, vn_if, "up", "true");
value_node_add(vn_if, "up", "true");
else
value_node_add(vn_if, vn_if, "up", "false");
value_node_add(vn_if, "up", "false");
return MNL_CB_OK;
}
@ -313,7 +313,7 @@ static int inet_data_cb(const struct nlmsghdr *nlh, void *data)
struct in_addr *addr = mnl_attr_get_payload(tb[IFA_ADDRESS]);
char out[INET_ADDRSTRLEN+32];
snprintf(out, sizeof(out), "%s/%u", inet_ntoa(*addr), ifa->ifa_prefixlen);
value_node_add(vn_if, vn_if, "ip", out);
value_node_add(vn_if, "ip", out);
}
return MNL_CB_OK;
@ -404,7 +404,7 @@ int osysmon_rtnl_poll(struct value_node *parent)
if (!g_oss->rcs)
g_oss->rcs = rtnl_init(NULL);
vn_net = value_node_add(parent, parent, "netdev", NULL);
vn_net = value_node_add(parent, "netdev", NULL);
if (!g_oss->rcs)
return -1;

View File

@ -63,7 +63,7 @@ int osysmon_sysinfo_poll(struct value_node *parent)
char buf[32];
int rc;
vn_sysinfo = value_node_add(parent, parent, "sysinfo", NULL);
vn_sysinfo = value_node_add(parent, "sysinfo", NULL);
rc = sysinfo(&si);
if (rc < 0)
@ -72,17 +72,17 @@ int osysmon_sysinfo_poll(struct value_node *parent)
/* Load Factor 1/5/15min */
snprintf(buf, sizeof(buf), "%.2f/%.2f/%.2f",
loadfac(si.loads[0]), loadfac(si.loads[1]), loadfac(si.loads[2]));
value_node_add(vn_sysinfo, vn_sysinfo, "load", buf);
value_node_add(vn_sysinfo, "load", buf);
/* RAM information (total/free/sared) in megabytes */
snprintf(buf, sizeof(buf), "%lu/%lu/%lu",
to_mbytes(si.totalram), to_mbytes(si.freeram), to_mbytes(si.sharedram));
value_node_add(vn_sysinfo, vn_sysinfo, "ram", buf);
value_node_add(vn_sysinfo, "ram", buf);
/* uptime in days/hours/minutes/seconds */
snprintf(buf, sizeof(buf), "%lud %02lu:%02lu:%02lu", to_days(si.uptime),
to_hours(si.uptime), to_minutes(si.uptime), to_seconds(si.uptime));
value_node_add(vn_sysinfo, vn_sysinfo, "uptime", buf);
value_node_add(vn_sysinfo, "uptime", buf);
return 0;
}

View File

@ -27,7 +27,7 @@
#include "value_node.h"
struct value_node *value_node_add(void *ctx, struct value_node *parent,
struct value_node *value_node_add(struct value_node *parent,
const char *name, const char *value)
{
struct value_node *vn = talloc_zero(parent, struct value_node);
@ -67,7 +67,7 @@ struct value_node *value_node_find_or_add(struct value_node *parent, const char
struct value_node *vn;
vn = value_node_find(parent, name);
if (!vn)
vn = value_node_add(parent, parent, name, NULL);
vn = value_node_add(parent, name, NULL);
return vn;
}

View File

@ -16,7 +16,7 @@ struct value_node {
struct llist_head children;
};
struct value_node *value_node_add(void *ctx, struct value_node *parent,
struct value_node *value_node_add(struct value_node *parent,
const char *name, const char *value);
struct value_node *value_node_find(struct value_node *parent, const char *name);
struct value_node *value_node_find_by_idx(struct value_node *parent, int idx);