mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
refactoring and code cleanups
This commit is contained in:
parent
62fbb55e2c
commit
14656232ad
5 changed files with 14 additions and 20 deletions
|
@ -118,7 +118,7 @@ int jitter_calc_read(struct hook *h, struct sample *smps[], unsigned *cnt)
|
|||
stats("%s: jitter=%" PRId64 " usec, moving average=%" PRId64 " usec, moving variance=%" PRId64 " usec", __FUNCTION__, j->jitter_val[(j->curr_count + 1) % GPS_NTP_DELAY_WIN_SIZE], j->moving_avg[j->curr_count], j->moving_var[j->curr_count]);
|
||||
|
||||
j->curr_count++;
|
||||
if(j->curr_count >= GPS_NTP_DELAY_WIN_SIZE)
|
||||
if (j->curr_count >= GPS_NTP_DELAY_WIN_SIZE)
|
||||
j->curr_count = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -264,7 +264,7 @@ int tc_netem_set_delay_distribution(struct rtnl_qdisc *qdisc, json_t *json)
|
|||
{
|
||||
if (json_is_string(json))
|
||||
return rtnl_netem_set_delay_distribution(qdisc, json_string_value(json));
|
||||
else if (json_is_array(json)){
|
||||
else if (json_is_array(json)) {
|
||||
json_t *elm;
|
||||
size_t idx;
|
||||
size_t len = json_array_size(json);
|
||||
|
|
|
@ -37,14 +37,14 @@ int log_parse_wrapper(struct log *l, json_t *cfg)
|
|||
json_t *json_logging = NULL;
|
||||
json_error_t err;
|
||||
|
||||
if(cfg) {
|
||||
if (cfg) {
|
||||
ret = json_unpack_ex(cfg, &err, 0, "{s?: o}",
|
||||
"logging", &json_logging
|
||||
);
|
||||
if (ret)
|
||||
jerror(&err, "Failed to parse logging from global configuration");
|
||||
|
||||
if(json_logging)
|
||||
if (json_logging)
|
||||
log_parse(l, json_logging);
|
||||
}
|
||||
|
||||
|
@ -91,12 +91,7 @@ void jerror(json_error_t *err, const char *fmt, ...)
|
|||
va_end(ap);
|
||||
|
||||
log_print(l, LOG_LVL_ERROR, "%s:", buf);
|
||||
{
|
||||
log_print(l, LOG_LVL_ERROR, "%s in %s:%d:%d", err->text, err->source, err->line, err->column);
|
||||
|
||||
if (l->syslog)
|
||||
syslog(LOG_ERR, "%s in %s:%d:%d", err->text, err->source, err->line, err->column);
|
||||
}
|
||||
log_print(l, LOG_LVL_ERROR, " %s in %s:%d:%d", err->text, err->source, err->line, err->column);
|
||||
|
||||
free(buf);
|
||||
|
||||
|
|
|
@ -72,27 +72,26 @@ static struct memory_allocation * memory_hugepage_alloc(struct memory_type *m, s
|
|||
|
||||
ma->address = mmap(NULL, ma->length, prot, flags, -1, 0);
|
||||
if (ma->address == MAP_FAILED) {
|
||||
//try again without hugepages as fallback solution, warn the user
|
||||
|
||||
/* Try again without hugepages as fallback solution, warn the user */
|
||||
prot= PROT_READ | PROT_WRITE;
|
||||
|
||||
/* Same flags as above without hugepages */
|
||||
flags = MAP_PRIVATE | MAP_ANONYMOUS;
|
||||
#ifdef __linux__
|
||||
if (getuid() == 0){
|
||||
if (getuid() == 0)
|
||||
flags |= MAP_LOCKED;
|
||||
}
|
||||
#endif
|
||||
/* Length has to be aligned with pagesize */
|
||||
ma->length = ALIGN(len, kernel_get_page_size());
|
||||
|
||||
/* Try mmap again */
|
||||
ma->address = mmap(NULL, ma->length, prot, flags, -1, 0);
|
||||
if(ma->address == MAP_FAILED){
|
||||
if (ma->address == MAP_FAILED) {
|
||||
free(ma);
|
||||
return NULL;
|
||||
}
|
||||
else{
|
||||
warn("memory_hugepage_alloc: hugepage could not be mapped, mapped without hugepages instead!");
|
||||
}
|
||||
|
||||
warn("memory_hugepage_alloc: hugepage could not be mapped, mapped without hugepages instead!");
|
||||
}
|
||||
|
||||
return ma;
|
||||
|
|
|
@ -55,11 +55,11 @@ static struct memory_allocation * memory_ib_alloc(struct memory_type *m, size_t
|
|||
ma->parent = mi->parent->alloc(mi->parent, len + sizeof(struct ibv_mr *), alignment);
|
||||
ma->address = ma->parent->address;
|
||||
|
||||
if(!mi->pd)
|
||||
if (!mi->pd)
|
||||
error("Protection domain is not registered!");
|
||||
|
||||
ma->ib.mr = ibv_reg_mr(mi->pd, ma->address, ma->length, IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE);
|
||||
if(!ma->ib.mr) {
|
||||
if (!ma->ib.mr) {
|
||||
mi->parent->free(mi->parent, ma->parent);
|
||||
free(ma);
|
||||
return NULL;
|
||||
|
|
Loading…
Add table
Reference in a new issue