diff --git a/src/plugins/select/bluegene/bluegene.c b/src/plugins/select/bluegene/bluegene.c index f0ccc5bbf439aee3e24a2bbcd771c1bcb392a973..8a6b12acc13012be19786c8475efb6a20eb4d7fc 100644 --- a/src/plugins/select/bluegene/bluegene.c +++ b/src/plugins/select/bluegene/bluegene.c @@ -84,7 +84,7 @@ static int _parse_bgl_spec(char *in_line); /** */ static int _copy_slurm_partition_list(); /** */ -static int _find_part_type(char* nodes, rm_partition_t** return_part_type); +static void _find_part_type(char* nodes, rm_partition_t** return_part_type); /** */ static int _listfindf_conf_part_record(bgl_conf_record_t* record, char *nodes); /** */ @@ -237,12 +237,7 @@ static int _copy_slurm_partition_list() bgl_record->slurm_part_id = xstrdup(slurm_part->name); bgl_record->part_type = (rm_partition_t*) xmalloc(sizeof(rm_partition_t)); - if (_find_part_type(cur_nodes, &bgl_record->part_type)){ - error("_copy_slurm_partition_list: not enough memory for bgl_record->part_type"); - err = 1; - goto cleanup_while; - } - + _find_part_type(cur_nodes, &bgl_record->part_type); bgl_record->hostlist = (hostlist_t *) xmalloc(sizeof(hostlist_t)); *(bgl_record->hostlist) = hostlist_create(cur_nodes); bgl_record->size = hostlist_count(*(bgl_record->hostlist)); @@ -258,7 +253,6 @@ static int _copy_slurm_partition_list() // print_bgl_record(bgl_record); list_push(bgl_list, bgl_record); - cleanup_while: nodes_tmp = next_ptr; cur_nodes = strtok_r(nodes_tmp, delimiter, &next_ptr); if (err) { @@ -385,21 +379,8 @@ static int _parse_bgl_spec(char *in_line) // debug("partition type %s", part_type); new_record = (bgl_conf_record_t*) xmalloc(sizeof(bgl_conf_record_t)); - if (!new_record){ - error("_parse_bgl_spec: not enough memory for new_record"); - return SLURM_ERROR; - } - new_record->nodes = xstrdup(nodes); - if (!(new_record->nodes)){ - error("_parse_bgl_spec: not enough memory for new_record nodes string"); - return SLURM_ERROR; - } new_record->part_type = xmalloc(sizeof(rm_partition_t)); - if (!(new_record->part_type)){ - error("_parse_bgl_spec: not enough memory for new_record part type"); - return SLURM_ERROR; - } if (strcasecmp(part_type, "TORUS") == 0){ // error("warning, TORUS specified, but I can't handle those yet! Defaulting to mesh"); @@ -478,7 +459,7 @@ static void _destroy_bgl_conf_record(void* object) * search through the list of nodes,types to find the partition type * for the given nodes */ -static int _find_part_type(char* nodes, rm_partition_t** return_part_type) +static void _find_part_type(char* nodes, rm_partition_t** return_part_type) { bgl_conf_record_t* record = NULL; @@ -487,19 +468,12 @@ static int _find_part_type(char* nodes, rm_partition_t** return_part_type) nodes); *return_part_type = (rm_partition_t*) xmalloc(sizeof(rm_partition_t)); - if (!(*return_part_type)) { - error("_find_part_type: not enough memory for return_part_type"); - return SLURM_ERROR; - } - if (record != NULL && record->part_type != NULL){ **return_part_type = *(record->part_type); } else { // error("warning: nodes not found in slurm.conf, defaulting to type RM_MESH"); **return_part_type = RM_MESH; } - - return SLURM_SUCCESS; } /** nodes example: 000x111 */ @@ -535,11 +509,6 @@ static int _char2intptr(char* request, int** bl, int** tr) (*bl) = (int*) xmalloc(sizeof(int) * SYSTEM_DIMENSIONS); (*tr) = (int*) xmalloc(sizeof(int) * SYSTEM_DIMENSIONS); - if (!request_tmp || !bl || !tr){ - error("_char2intptr: not enough memory for new structs"); - goto cleanup; - } - orig_ptr = request_tmp; token = strtok_r(request_tmp, delimit, &next_ptr); if (token == NULL) @@ -591,10 +560,6 @@ static int _parse_request(char* request_string, partition_t** request_result) debug("incoming request %s", request_string); *request_result = (partition_t*) xmalloc(sizeof(partition_t)); - if (!(*request_result)) { - error("parse_request: not enough memory for request"); - goto cleanup; - } /** token needs to be of the form 000x000 */ if(_extract_range(request_string, &range)){ @@ -652,10 +617,6 @@ static int _get_request_dimensions(int* bl, int* tr, uint16_t** dim) } *dim = (uint16_t*) xmalloc(sizeof(uint16_t) * SYSTEM_DIMENSIONS); - if (!(*dim)) { - error("get_request_dimensions: not enough memory for dim"); - return SLURM_ERROR; - } for (i=0; i<SYSTEM_DIMENSIONS; i++){ (*dim)[i] = tr[i] - bl[i] + 1; /* plus one because we're counting current @@ -701,10 +662,6 @@ static int _extract_range(char* request, char** result) if (!request) return SLURM_ERROR; *result = (char*) xmalloc(sizeof(RANGE_SIZE) + 1); /* +1 for NULL term */ - if (!(*result)) { - error("_extract_range: not enough memory for *result"); - return SLURM_ERROR; - } request_length = strlen(request); for(i=0; i<request_length; i++){ diff --git a/src/plugins/select/bluegene/partition_sys.c b/src/plugins/select/bluegene/partition_sys.c index 3ee9079b76a7251b22489dd64a287d79c97ca493..cc91d3c0858c7f02d5f2aa6e2c2d56fa1299176c 100755 --- a/src/plugins/select/bluegene/partition_sys.c +++ b/src/plugins/select/bluegene/partition_sys.c @@ -70,8 +70,8 @@ List bgl_sys_free = NULL; List bgl_sys_allocated = NULL; void _init_sys(partition_t*); -int _is_not_equals_all_coord(uint16_t* A, uint16_t* B); -int _is_not_equals_some_coord(uint16_t* A, uint16_t* B); +int _is_not_equals_all_coord(uint16_t* rec_a, uint16_t* rec_b); +int _is_not_equals_some_coord(uint16_t* rec_A, uint16_t* rec_b); #ifdef _RM_API_H__ /** @@ -84,39 +84,39 @@ int _is_not_equals_some_coord(uint16_t* A, uint16_t* B); * OUT - bp: will point to BP at location loc * OUT - rc: error code (0 = success) */ -int _get_bp(rm_element_t *bp, rm_location_t *loc); -int _check_bp_status(rm_location_t *loc); -void _pre_allocate(rm_partition_t* my_part, rm_connection_type_t* part_conn); -int _post_allocate(rm_partition_t *my_part, pm_partition_id_t *part_id); -int _get_switch(partition_t* partition, List switch_list); -int _get_bp_by_location(int* cur_coord, rm_BP_t* BP); -void _rm_switch_t_destroy(void* object); +static int _get_bp(rm_element_t *bp, rm_location_t *loc); +static int _check_bp_status(rm_location_t *loc); +static void _pre_allocate(rm_partition_t* my_part, rm_connection_type_t* part_conn); +static int _post_allocate(rm_partition_t *my_part, pm_partition_id_t *part_id); +static int _get_switch(partition_t* partition, List switch_list); +static int _get_bp_by_location(int* cur_coord, rm_BP_t* bp); +static void _rm_switch_t_destroy(void* object); #else -int _create_bgl_partitions(List requests); +static int _create_bgl_partitions(List requests); #endif -int _break_up_partition(List sys, partition_t* partition_to_break, int index); -int _fit_request(List sys, List allocated, uint16_t* request); +static int _break_up_partition(List sys, partition_t* partition_to_break, int index); +static int _fit_request(List sys, List allocated, uint16_t* request); -void _int_array_destroy(void* object); -int _int_array_cmpf(uint16_t* A, uint16_t* B); +static void _int_array_destroy(void* object); +static int _int_array_cmpf(uint16_t* rec_a, uint16_t* rec_b); -int _partition_cmpf_inc(struct partition* A, struct partition* B); -int _partition_cmpf_dec(struct partition* A, struct partition* B); +static int _partition_cmpf_inc(struct partition* rec_a, struct partition* rec_b); +static int _partition_cmpf_dec(struct partition* rec_a, struct partition* rec_b); #ifdef _RM_API_H__ -void _preallocate(rm_BGL_t* bgl, rm_partition_t* my_part, +static void _preallocate(rm_BGL_t* bgl, rm_partition_t* my_part, char* username, rm_connection_type_t* part_conn); -int _postallocate(rm_BGL_t *bgl, rm_partition_t *my_part, +static int _postallocate(rm_BGL_t *bgl, rm_partition_t *my_part, pm_partition_id_t *part_id); #endif -List _get_bgl_sys_free(); -List _get_bgl_sys_allocated(); +static List _get_bgl_sys_free(); +static List _get_bgl_sys_allocated(); #ifdef _UNIT_TESTS_ -void debug(const char *fmt, ...); +extern void debug(const char *fmt, ...); #endif @@ -332,11 +332,6 @@ int _break_up_partition(List sys, partition_t* partition_to_break, int index) first_part = (partition_t*) xmalloc(sizeof(partition_t)); second_part = (partition_t*) xmalloc(sizeof(partition_t)); - if (!first_part || !second_part){ - error("_break_up_partition: not enough memory to break up partitions"); - return 1; - } - copy_partition(partition_to_break, first_part); copy_partition(partition_to_break, second_part); @@ -512,23 +507,23 @@ void sort_int_array_by_dec_size(List configs){ /** * Comparator used for sorting int arrays * - * returns: -1: A greater than B 0: A equal to B 1: A less than B + * returns: -1: rec_a > rec_b 0: rec_a == rec_b 1: rec_a < rec_b * * Note: return values are "reversed" so that we can have the list * sorted in decreasing order (largest to smallest) */ -int _int_array_cmpf(uint16_t* A, uint16_t* B) +int _int_array_cmpf(uint16_t* rec_a, uint16_t* rec_b) { - int volA, volB; + int vol_a, vol_b; - if (A == NULL || B == NULL) + if (rec_a == NULL || rec_b == NULL) return -9; - volA = int_array_size(A); - volB = int_array_size(B); - if (volA > volB) + vol_a = int_array_size(rec_a); + vol_b = int_array_size(rec_b); + if (vol_a > vol_b) return -1; - else if (volA < volB) + else if (vol_a < vol_b) return 1; else return 0; @@ -685,10 +680,7 @@ int configure_switches(partition_t* partition) } /* end of cur_coord[1]*/ bgl_part_id = (pm_partition_id_t*) xmalloc(sizeof(pm_partition_id_t)); - if (!bgl_part_id){ - error("_configure_switches: not enough memory for bgl_part_id"); - return SLURM_ERROR; - } + #ifdef _RM_API_H__ post_allocate(bgl_part, bgl_part_id); bgl_rec = (bgl_record_t*) partition->bgl_record_ptr; @@ -995,7 +987,7 @@ void rm_switch_t_destroy(void* object) * this is just stupid. there are some implicit rules for where * "NextBP" goes to, but we don't know, so we have to do this. */ -int get_bp_by_location(int* cur_coord, rm_BP_t* BP) +int get_bp_by_location(int* cur_coord, rm_BP_t* bp) { int BP_num; rm_location_t* loc; @@ -1003,14 +995,14 @@ int get_bp_by_location(int* cur_coord, rm_BP_t* BP) rm_get_data(bgl, RM_BPNum, &bp_num); rm_get_data(bgl, RM_FirstBP, &BP); for (i=0; i<BP_num; i++){ - rm_get_data(BP, RM_BPLoc, &loc); + rm_get_data(bp, RM_BPLoc, &loc); if (loc.X == cur_coord[0] && loc.Y == cur_coord[1] && loc.Z == cur_coord[2]) return SLURM_SUCCESS; - rm_get_data(bgl, RM_NextBP, &BP); + rm_get_data(bgl, RM_NextBP, &bp); } - error("get_bp_by_location: could not find specified BP."); + error("get_bp_by_location: could not find specified bp."); return SLURM_ERROR; } #endif @@ -1020,11 +1012,11 @@ int get_bp_by_location(int* cur_coord, rm_BP_t* BP) * * returns 0 if equals, 1 if not equals */ -int _is_not_equals_some_coord(uint16_t* A, uint16_t* B) +int _is_not_equals_some_coord(uint16_t* rec_a, uint16_t* rec_b) { int i; for (i=0; i<SYSTEM_DIMENSIONS; i++){ - if (A[i] == B[i]) + if (rec_a[i] == rec_b[i]) return 0; } return 1; @@ -1035,11 +1027,11 @@ int _is_not_equals_some_coord(uint16_t* A, uint16_t* B) * * returns 0 if equals, 1 if not equals */ -int _is_not_equals_all_coord(uint16_t* A, uint16_t* B) +int _is_not_equals_all_coord(uint16_t* rec_a, uint16_t* rec_b) { int i; for (i=0; i<SYSTEM_DIMENSIONS; i++){ - if (A[i] != B[i]) + if (rec_a[i] != rec_b[i]) return 1; } return 0; @@ -1067,14 +1059,14 @@ void sort_partitions_by_dec_size(List parts){ /** * Comparator used for sorting partitions smallest to largest * - * returns: -1: A greater than B 0: A equal to B 1: A less than B + * returns: -1: rec_a < rec_b 0: rec_a == rec_b 1: rec_a > rec_b * */ -int _partition_cmpf_inc(struct partition* A, struct partition* B) +int _partition_cmpf_inc(struct partition* rec_a, struct partition* rec_b) { - if (A->size < B->size) + if (rec_a->size < rec_b->size) return -1; - else if (A->size > B->size) + else if (rec_a->size > rec_b->size) return 1; else return 0; @@ -1083,14 +1075,14 @@ int _partition_cmpf_inc(struct partition* A, struct partition* B) /** * Comparator used for sorting partitions largest to smallest * - * returns: -1: A greater than B 0: A equal to B 1: A less than B + * returns: -1: rec_a > rec_b 0: rec_a == rec_b 1: rec_a < rec_b * */ -int _partition_cmpf_dec(struct partition* A, struct partition* B) +int _partition_cmpf_dec(struct partition* rec_a, struct partition* rec_b) { - if (A->size > B->size) + if (rec_a->size > rec_b->size) return -1; - else if (A->size < B->size) + else if (rec_a->size < rec_b->size) return 1; else return 0;