diff --git a/src/image/Image.cc b/src/image/Image.cc index 0b068ac2e7..3b419df06b 100644 --- a/src/image/Image.cc +++ b/src/image/Image.cc @@ -147,7 +147,6 @@ int Image::insert(SqlDB *db) ostringstream tmp_hashstream; ostringstream tmp_sourcestream; - // --------------------------------------------------------------------- // Check default image attributes // --------------------------------------------------------------------- diff --git a/src/image/ImagePool.cc b/src/image/ImagePool.cc index 38e2b566e8..da71fb9d98 100644 --- a/src/image/ImagePool.cc +++ b/src/image/ImagePool.cc @@ -91,56 +91,54 @@ int ImagePool::allocate ( const string& stemplate, int * oid) { - int rc; - Image * img; + int rc; + Image * img; - string name; - char * error_msg; + string name; + char * error_msg; - // --------------------------------------------------------------------- - // Build a new Image object - // --------------------------------------------------------------------- - img = new Image(uid); + // --------------------------------------------------------------------- + // Build a new Image object + // --------------------------------------------------------------------- + img = new Image(uid); - // --------------------------------------------------------------------- - // Parse template - // --------------------------------------------------------------------- - rc = img->image_template.parse(stemplate, &error_msg); + // --------------------------------------------------------------------- + // Parse template + // --------------------------------------------------------------------- + rc = img->image_template.parse(stemplate, &error_msg); - if ( rc != 0 ) - { - goto error_parse; - } + if ( rc != 0 ) + { + ostringstream oss; + oss << "ImagePool template parse error: " << error_msg; + NebulaLog::log("IMG", Log::ERROR, oss); - img->get_template_attribute("NAME", name); + free(error_msg); + delete img; - // --------------------------------------------------------------------- - // Insert the Object in the pool - // --------------------------------------------------------------------- + return -1; + } - *oid = PoolSQL::allocate(img); + img->get_template_attribute("NAME", name); - if ( *oid == -1 ) - { - return -1; - } + // --------------------------------------------------------------------- + // Insert the Object in the pool + // --------------------------------------------------------------------- - // --------------------------------------------------------------------- - // Add the image name to the map of image_names - // --------------------------------------------------------------------- + *oid = PoolSQL::allocate(img); - image_names.insert(make_pair(name, *oid)); + if ( *oid == -1 ) + { + return -1; + } - return *oid; + // --------------------------------------------------------------------- + // Add the image name to the map of image_names + // --------------------------------------------------------------------- -error_parse: - ostringstream oss; - oss << "ImagePool template parse error: " << error_msg; - NebulaLog::log("IMG", Log::ERROR, oss); - free(error_msg); - delete img; - *oid = -2; - return -2; + image_names.insert(make_pair(name, *oid)); + + return *oid; } /* -------------------------------------------------------------------------- */ diff --git a/src/image/test/ImagePoolTest.cc b/src/image/test/ImagePoolTest.cc index 63a1cad8a5..a883c070d0 100644 --- a/src/image/test/ImagePoolTest.cc +++ b/src/image/test/ImagePoolTest.cc @@ -388,7 +388,7 @@ public: "END" }; - int results[] = { -1, -1, -2 }; + int results[] = { -1, -1, -1 }; int i = 0; while( templates[i] != "END" ) diff --git a/src/vm/VirtualMachinePool.cc b/src/vm/VirtualMachinePool.cc index 67bc153758..bc370a9305 100644 --- a/src/vm/VirtualMachinePool.cc +++ b/src/vm/VirtualMachinePool.cc @@ -191,7 +191,7 @@ int VirtualMachinePool::allocate ( delete vm; - return -2; + return -1; } // ------------------------------------------------------------------------ @@ -200,11 +200,6 @@ int VirtualMachinePool::allocate ( *oid = PoolSQL::allocate(vm); - if ( *oid == -1 ) - { - return -1; - } - return *oid; }