int error,
int errorno))
{
- int savederrno = 0, err = 0;
+ int savederrno = 0;
if (!knet_h) {
errno = EINVAL;
pthread_rwlock_unlock(&knet_h->global_rwlock);
- errno = err ? savederrno : 0;
- return err;
+ return 0;
}
int knet_handle_add_datafd(knet_handle_t knet_h, int *datafd, int8_t *channel)
int knet_handle_get_stats(knet_handle_t knet_h, struct knet_handle_stats *stats, size_t struct_size)
{
int savederrno = 0;
- int err = 0;
if (!knet_h) {
errno = EINVAL;
stats->size = sizeof(struct knet_handle_stats);
pthread_rwlock_unlock(&knet_h->global_rwlock);
- errno = err ? savederrno : 0;
- return err;
+ return 0;
}
int knet_handle_clear_stats(knet_handle_t knet_h, int clear_option)
{
int savederrno = 0;
- int err = 0;
if (!knet_h) {
errno = EINVAL;
}
pthread_rwlock_unlock(&knet_h->global_rwlock);
- errno = err ? savederrno : 0;
- return err;
+ return 0;
}
int knet_host_get_host_list(knet_handle_t knet_h,
knet_node_id_t *host_ids, size_t *host_ids_entries)
{
- int savederrno = 0, err = 0;
+ int savederrno = 0;
if (!knet_h) {
errno = EINVAL;
*host_ids_entries = knet_h->host_ids_entries;
pthread_rwlock_unlock(&knet_h->global_rwlock);
- errno = err ? savederrno : 0;
- return err;
+ return 0;
}
int knet_host_set_policy(knet_handle_t knet_h, knet_node_id_t host_id,
struct timespec clock_now;
unsigned long long diff_pmtud, interval;
+ if (clock_gettime(CLOCK_MONOTONIC, &clock_now) != 0) {
+ log_debug(knet_h, KNET_SUB_PMTUD, "Unable to get monotonic clock");
+ return 0;
+ }
+
if (!force_run) {
interval = knet_h->pmtud_interval * 1000000000llu; /* nanoseconds */
- if (clock_gettime(CLOCK_MONOTONIC, &clock_now) != 0) {
- log_debug(knet_h, KNET_SUB_PMTUD, "Unable to get monotonic clock");
- return 0;
- }
-
timespec_diff(dst_link->pmtud_last, clock_now, &diff_pmtud);
if (diff_pmtud < interval) {
prefix_len = atoi(prefix);
- if ((prefix_len > 32) || (prefix_len < 0))
+ if ((prefix_len > 32) || (prefix_len <= 0))
return NULL;
if (inet_pton(AF_INET, ipaddr, &address) <= 0)
return NULL;
}
- if (strlen(devname) > IFNAMSIZ) {
+ /* Need to allow space for trailing NUL */
+ if (strlen(devname) >= IFNAMSIZ) {
errno = E2BIG;
return NULL;
}
nozzle_t nozzle = NULL;
char *error_string = NULL;
char *tmpdir = NULL;
- char tmpdirsrc[PATH_MAX];
+ char tmpdirsrc[PATH_MAX*2];
char tmpstr[PATH_MAX*2];
char srcfile[PATH_MAX];
char dstfile[PATH_MAX];
+ char current_dir[PATH_MAX];
/*
* create a tmp dir for storing up/down scripts.
* we cannot create symlinks src dir
*/
- strcpy(tmpdirsrc, ABSBUILDDIR "/nozzle_test_XXXXXX");
+ if (getcwd(current_dir, sizeof(current_dir)) == NULL) {
+ printf("Unable to get current working directory: %s\n", strerror(errno));
+ return -1;
+ }
+ snprintf(tmpdirsrc, sizeof(tmpdirsrc)-1, "%s/nozzle_test_XXXXXX", current_dir);
tmpdir = mkdtemp(tmpdirsrc);
if (!tmpdir) {
}
}
- si = malloc(sizeof(struct struct_info));
- if (si) {
- si->kind = STRUCTINFO_ENUM;
- qb_list_init(&si->params_list);
- si->structname = strdup(name);
- traverse_node(cur_node, "enumvalue", read_struct, si);
- qb_map_put(structures_map, refid, si);
+ if (name) {
+ si = malloc(sizeof(struct struct_info));
+ if (si) {
+ si->kind = STRUCTINFO_ENUM;
+ qb_list_init(&si->params_list);
+ si->structname = strdup(name);
+ traverse_node(cur_node, "enumvalue", read_struct, si);
+ qb_map_put(structures_map, refid, si);
+ }
}
-
}
-
}
}
free(kind);
free(def);
free(args);
-// free(name); /* don't free, it's in the map */
+ free(name);
}
}