/**
* collectd - src/utils_config_cores.c
*
- * Copyright(c) 2017 Intel Corporation. All rights reserved.
+ * Copyright(c) 2018 Intel Corporation. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
return -EINVAL;
char *endptr = NULL;
- *n = (unsigned) strtoul(s, &endptr, 0);
+ *n = (unsigned)strtoul(s, &endptr, 0);
if (*s == '\0' || *endptr != '\0') {
ERROR(UTIL_NAME ": Failed to parse '%s' into unsigned number", s);
return -EINVAL;
* Number of elements placed into nums.
*/
static size_t str_list_to_nums(char *s, unsigned *nums, size_t nums_len) {
- char *saveptr;
+ char *saveptr = NULL;
char *token;
size_t idx = 0;
- while((token = strtok_r(s, ",", &saveptr))) {
+ while ((token = strtok_r(s, ",", &saveptr))) {
char *pos;
unsigned start, end = 0;
s = NULL;
if (is_in_list(i, nums, idx))
continue;
if (idx >= nums_len) {
- WARNING(UTIL_NAME ": exceeded the cores number limit: %zu", nums_len);
+ WARNING(UTIL_NAME ": exceeded the cores number limit: %" PRIsz,
+ nums_len);
return idx;
}
nums[idx] = i;
ERROR(UTIL_NAME ": Missing closing bracket ] in option %s.", in);
return -EINVAL;
}
- if ((end - start) >= out_size) {
+ if ((size_t)(end - start) >= out_size) {
ERROR(UTIL_NAME ": Out buffer is too small.");
return -EINVAL;
}
unsigned cores[MAX_CORES] = {0};
if (cg_idx >= STATIC_ARRAY_SIZE(cgroups)) {
- ERROR(UTIL_NAME ": Configuration exceeds maximum number of cores: %zu",
+ ERROR(UTIL_NAME
+ ": Configuration exceeds maximum number of cores: %" PRIsz,
STATIC_ARRAY_SIZE(cgroups));
ret = -EINVAL;
goto parse_error;
parse_error:
cg_idx = 0;
- while(cg_idx < STATIC_ARRAY_SIZE(cgroups) && cgroups[cg_idx].desc != NULL) {
+ while (cg_idx < STATIC_ARRAY_SIZE(cgroups) && cgroups[cg_idx].desc != NULL) {
sfree(cgroups[cg_idx].desc);
sfree(cgroups[cg_idx].cores);
cg_idx++;
cgl->cgroups[i].desc = strdup(desc);
if (cgl->cgroups[i].desc == NULL) {
- ERROR(UTIL_NAME ": Failed to allocate description for cgroup %d.", i);
- config_cores_cleanup(cgl);
- return -ENOMEM;
+ ERROR(UTIL_NAME ": Failed to allocate description for cgroup %d.", i);
+ config_cores_cleanup(cgl);
+ return -ENOMEM;
}
}
return 0;
/* if not all cores are the same */
return -1;
}
-