From a529981e0567745ed5434f3b94a60c6cf5968a69 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Thu, 21 May 2009 13:08:05 +0200 Subject: [PATCH] Updated error checking of forb_sequence_alloc_buf() --- fres/cbroker/fcb.c | 14 ++++++++------ frsh_api/frsh_spare_capacity.c | 4 +++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/fres/cbroker/fcb.c b/fres/cbroker/fcb.c index 4c8efcd..1167893 100644 --- a/fres/cbroker/fcb.c +++ b/fres/cbroker/fcb.c @@ -416,7 +416,9 @@ rebalance_spare_capacity_and_reserve(struct resource *resource, fres_block_spare_capacity *s; fres_contract_ptr_seq contracts; - forb_sequence_alloc_buf(contracts, rl->length); + if (!forb_sequence_alloc_buf(contracts, rl->length)) { + return errno; + } contracts._length = rl->length; i=0; /* Initialize optimization */ @@ -531,7 +533,9 @@ change_vreses(struct fcb *fcb, fres_contract_ptr_seq *schedulable_contracts) int i, ret; CORBA_Environment ev; - forb_sequence_alloc_buf(vreses, schedulable_contracts->_length); + if (!forb_sequence_alloc_buf(vreses, schedulable_contracts->_length)) { + return errno; + } vreses._length = 0; for (i=0; i_length; i++) { @@ -617,8 +621,7 @@ negotiate_contracts(fres_contract_broker obj, /* Allocate all the needed memory before doing reservation. If * there is no enough memory, it has no sense to call resource * manager. */ - forb_sequence_alloc_buf(commit_ids, rl.length); - if (!commit_ids._buffer) { + if (!forb_sequence_alloc_buf(commit_ids, rl.length)) { ret = errno; goto err_free_fcb_contracts; } @@ -687,8 +690,7 @@ negotiate_contracts(fres_contract_broker obj, /* Return IDs and delete canceled contracts from out database */ - forb_sequence_alloc_buf(**ids_out, contracts->_length); - if (!(*ids_out)->_buffer) { + if (!forb_sequence_alloc_buf(**ids_out, contracts->_length)) { ev->major = FORB_EX_NO_MEMORY; goto err_cancel_contracts; } diff --git a/frsh_api/frsh_spare_capacity.c b/frsh_api/frsh_spare_capacity.c index 5806c7c..77b5bb1 100644 --- a/frsh_api/frsh_spare_capacity.c +++ b/frsh_api/frsh_spare_capacity.c @@ -103,7 +103,9 @@ int frsh_contract_set_reclamation_params if (utilization_set) { int i; - forb_sequence_alloc_buf(s->variants, utilization_set->size); + if (!forb_sequence_alloc_buf(s->variants, utilization_set->size)) { + goto err; + } for (i=0; isize; i++) { struct fres_container *c = NULL; fres_block_basic *b = NULL; -- 2.39.2