Hi,

Please find the latest report on new defect(s) introduced to cloudstack found 
with Coverity Scan.

7 new defect(s) introduced to cloudstack found with Coverity Scan.
8 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent 
build analyzed by Coverity Scan.

New defect(s) Reported-by: Coverity Scan
Showing 7 of 7 defect(s)


** CID 1257440:  Logically dead code  (DEADCODE)
/server/src/com/cloud/configuration/ConfigurationManagerImpl.java: 2575 in 
com.cloud.configuration.ConfigurationManagerImpl.deleteDiskOffering(org.apache.cloudstack.api.command.admin.offering.DeleteDiskOfferingCmd)()

** CID 1257439:  Bx: Questionable Boxing of primitive value  
(FB.BX_UNBOXING_IMMEDIATELY_REBOXED)
/server/src/com/cloud/api/query/dao/DomainJoinDaoImpl.java: 131 in 
com.cloud.api.query.dao.DomainJoinDaoImpl.setResourceLimits(com.cloud.api.query.vo.DomainJoinVO,
 boolean, org.apache.cloudstack.api.response.ResourceLimitAndCountResponse)()

** CID 1257438:  Bx: Questionable Boxing of primitive value  
(FB.BX_BOXING_IMMEDIATELY_UNBOXED)
/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java: 1107 in 
com.cloud.storage.snapshot.SnapshotManagerImpl.allocSnapshot(java.lang.Long, 
java.lang.Long, java.lang.String)()

** CID 1257437:  Logically dead code  (DEADCODE)
/server/src/com/cloud/configuration/ConfigurationManagerImpl.java: 2488 in 
com.cloud.configuration.ConfigurationManagerImpl.updateDiskOffering(org.apache.cloudstack.api.command.admin.offering.UpdateDiskOfferingCmd)()

** CID 1257436:  Dereference null return value  (NULL_RETURNS)
/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java:
 725 in 
org.apache.cloudstack.storage.resource.NfsSecondaryStorageResource.registerTemplateOnSwift(org.apache.cloudstack.storage.command.DownloadCommand)()

** CID 1257435:  Resource leak on an exceptional path  (RESOURCE_LEAK)
/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java:
 734 in 
org.apache.cloudstack.storage.resource.NfsSecondaryStorageResource.registerTemplateOnSwift(org.apache.cloudstack.storage.command.DownloadCommand)()

** CID 1257434:  Resource leak  (RESOURCE_LEAK)
/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java:
 743 in 
org.apache.cloudstack.storage.resource.NfsSecondaryStorageResource.registerTemplateOnSwift(org.apache.cloudstack.storage.command.DownloadCommand)()


________________________________________________________________________________________________________
*** CID 1257440:  Logically dead code  (DEADCODE)
/server/src/com/cloud/configuration/ConfigurationManagerImpl.java: 2575 in 
com.cloud.configuration.ConfigurationManagerImpl.deleteDiskOffering(org.apache.cloudstack.api.command.admin.offering.DeleteDiskOfferingCmd)()
2569             if (offering == null) {
2570                 throw new InvalidParameterValueException("Unable to find 
disk offering by id " + diskOfferingId);
2571             }
2572     
2573             Long userId = CallContext.current().getCallingUserId();
2574             if (userId == null) {
>>>     CID 1257440:  Logically dead code  (DEADCODE)
>>>     Execution cannot reach this statement "userId = java.lang.Long.val...".
2575                 userId = Long.valueOf(User.UID_SYSTEM);
2576             }
2577             User user = _userDao.findById(userId);
2578             if (user == null || user.getRemoved() != null) {
2579                 throw new InvalidParameterValueException("Unable to find 
active user by id " + userId);
2580             }

________________________________________________________________________________________________________
*** CID 1257439:  Bx: Questionable Boxing of primitive value  
(FB.BX_UNBOXING_IMMEDIATELY_REBOXED)
/server/src/com/cloud/api/query/dao/DomainJoinDaoImpl.java: 131 in 
com.cloud.api.query.dao.DomainJoinDaoImpl.setResourceLimits(com.cloud.api.query.vo.DomainJoinVO,
 boolean, org.apache.cloudstack.api.response.ResourceLimitAndCountResponse)()
125             response.setSnapshotLimit(snapshotLimitDisplay);
126             response.setSnapshotTotal(snapshotTotal);
127             response.setSnapshotAvailable(snapshotAvail);
128     
129             Long templateLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getTemplateLimit(), 
fullView, ResourceType.template, domain.getId());
130             String templateLimitDisplay = (fullView || templateLimit == -1) 
? "Unlimited" : String.valueOf(templateLimit);
>>>     CID 1257439:  Bx: Questionable Boxing of primitive value  
>>> (FB.BX_UNBOXING_IMMEDIATELY_REBOXED)
>>>     Boxed value is unboxed and then immediately reboxed
131             Long templateTotal = (domain.getTemplateTotal() == null) ? 0 : 
domain.getTemplateTotal();
132             String templateAvail = (fullView || templateLimit == -1) ? 
"Unlimited" : String.valueOf(templateLimit - templateTotal);
133             response.setTemplateLimit(templateLimitDisplay);
134             response.setTemplateTotal(templateTotal);
135             response.setTemplateAvailable(templateAvail);
136     

________________________________________________________________________________________________________
*** CID 1257438:  Bx: Questionable Boxing of primitive value  
(FB.BX_BOXING_IMMEDIATELY_UNBOXED)
/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java: 1107 in 
com.cloud.storage.snapshot.SnapshotManagerImpl.allocSnapshot(java.lang.Long, 
java.lang.Long, java.lang.String)()
1101             _accountMgr.checkAccess(caller, null, true, volume);
1102             Type snapshotType = getSnapshotType(policyId);
1103             Account owner = _accountMgr.getAccount(volume.getAccountId());
1104     
1105             try {
1106                 _resourceLimitMgr.checkResourceLimit(owner, 
ResourceType.snapshot);
>>>     CID 1257438:  Bx: Questionable Boxing of primitive value  
>>> (FB.BX_BOXING_IMMEDIATELY_UNBOXED)
>>>     Primitive value is boxed and then immediately unboxed
1107                     _resourceLimitMgr.checkResourceLimit(owner, 
ResourceType.secondary_storage, new Long(volume.getSize()).longValue());
1108             } catch (ResourceAllocationException e) {
1109                 if (snapshotType != Type.MANUAL) {
1110                     String msg = "Snapshot resource limit exceeded for 
account id : " + owner.getId() + ". Failed to create recurring snapshots";
1111                     s_logger.warn(msg);
1112                     
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_UPDATE_RESOURCE_COUNT, 
0L, 0L, msg,

________________________________________________________________________________________________________
*** CID 1257437:  Logically dead code  (DEADCODE)
/server/src/com/cloud/configuration/ConfigurationManagerImpl.java: 2488 in 
com.cloud.configuration.ConfigurationManagerImpl.updateDiskOffering(org.apache.cloudstack.api.command.admin.offering.UpdateDiskOfferingCmd)()
2482             if (diskOfferingHandle == null) {
2483                 throw new InvalidParameterValueException("Unable to find 
disk offering by id " + diskOfferingId);
2484             }
2485     
2486             Long userId = CallContext.current().getCallingUserId();
2487             if (userId == null) {
>>>     CID 1257437:  Logically dead code  (DEADCODE)
>>>     Execution cannot reach this statement "userId = java.lang.Long.val...".
2488                 userId = Long.valueOf(User.UID_SYSTEM);
2489             }
2490             User user = _userDao.findById(userId);
2491             if (user == null || user.getRemoved() != null) {
2492                 throw new InvalidParameterValueException("Unable to find 
active user by id " + userId);
2493             }

________________________________________________________________________________________________________
*** CID 1257436:  Dereference null return value  (NULL_RETURNS)
/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java:
 725 in 
org.apache.cloudstack.storage.resource.NfsSecondaryStorageResource.registerTemplateOnSwift(org.apache.cloudstack.storage.command.DownloadCommand)()
719                 file = downloadFromUrlToNfs(cmd.getUrl(), nfsCacheStore, 
path, fileName);
720                 String container = "T-" + cmd.getId();
721                 String swiftPath = SwiftUtil.putObject(swiftTO, file, 
container, null);
722     
723                 //put metda file
724                 File uniqDir = _storage.createUniqDir();
>>>     CID 1257436:  Dereference null return value  (NULL_RETURNS)
>>>     Calling a method on null object "uniqDir".
725                 String metaFileName = uniqDir.getAbsolutePath() + 
File.separator + "template.properties";
726                 _storage.create(uniqDir.getAbsolutePath(), 
"template.properties");
727                 File metaFile = new File(metaFileName);
728                 FileWriter writer = new FileWriter(metaFile);
729                 BufferedWriter bufferWriter = new BufferedWriter(writer);
730                 bufferWriter.write("uniquename=" + cmd.getName());

________________________________________________________________________________________________________
*** CID 1257435:  Resource leak on an exceptional path  (RESOURCE_LEAK)
/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java:
 734 in 
org.apache.cloudstack.storage.resource.NfsSecondaryStorageResource.registerTemplateOnSwift(org.apache.cloudstack.storage.command.DownloadCommand)()
728                 FileWriter writer = new FileWriter(metaFile);
729                 BufferedWriter bufferWriter = new BufferedWriter(writer);
730                 bufferWriter.write("uniquename=" + cmd.getName());
731                 bufferWriter.write("\n");
732                 bufferWriter.write("filename=" + fileName);
733                 bufferWriter.write("\n");
>>>     CID 1257435:  Resource leak on an exceptional path  (RESOURCE_LEAK)
>>>     Variable "writer" going out of scope leaks the resource it refers to.
734                 bufferWriter.write("size=" + file.length());
735                 bufferWriter.close();
736                 writer.close();
737     
738                 SwiftUtil.putObject(swiftTO, metaFile, container, 
"template.properties");
739                 metaFile.delete();

________________________________________________________________________________________________________
*** CID 1257434:  Resource leak  (RESOURCE_LEAK)
/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java:
 743 in 
org.apache.cloudstack.storage.resource.NfsSecondaryStorageResource.registerTemplateOnSwift(org.apache.cloudstack.storage.command.DownloadCommand)()
737     
738                 SwiftUtil.putObject(swiftTO, metaFile, container, 
"template.properties");
739                 metaFile.delete();
740                 uniqDir.delete();
741                 String md5sum = null;
742                 try {
>>>     CID 1257434:  Resource leak  (RESOURCE_LEAK)
>>>     Ignoring resource created by "new java.io.FileInputStream(file)" leaks 
>>> it.
743                     md5sum = DigestUtils.md5Hex(new FileInputStream(file));
744                 } catch (IOException e) {
745                     s_logger.debug("Failed to get md5sum: " + 
file.getAbsoluteFile());
746                 }
747     
748                 DownloadAnswer answer =


________________________________________________________________________________________________________
To view the defects in Coverity Scan visit, 
http://scan.coverity.com/projects/943?tab=overview

To manage Coverity Scan email notifications for "dev@cloudstack.apache.org", 
click 
http://scan.coverity.com/subscriptions/edit?email=dev%40cloudstack.apache.org&token=494aabd5ba647999fa41b6d766646231
 .

Reply via email to