cloudstack-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CLOUDSTACK-10156) Fix Coverity new problems CID(1349987, 1349986, 1347248)
Date Thu, 23 Nov 2017 06:11:00 GMT

    [ https://issues.apache.org/jira/browse/CLOUDSTACK-10156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16263854#comment-16263854
] 

ASF GitHub Bot commented on CLOUDSTACK-10156:
---------------------------------------------

rhtyd closed pull request #2332: [CLOUDSTACK-10156] Fix Coverity new problems CID(1349987,
1349986, 1347248)
URL: https://github.com/apache/cloudstack/pull/2332
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaStatementCmd.java
b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaStatementCmd.java
index 3efdf113da5..ebf3f1c636b 100644
--- a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaStatementCmd.java
+++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaStatementCmd.java
@@ -21,7 +21,6 @@
 
 import javax.inject.Inject;
 
-import org.apache.log4j.Logger;
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseCmd;
@@ -29,10 +28,10 @@
 import org.apache.cloudstack.api.response.AccountResponse;
 import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.api.response.QuotaResponseBuilder;
+import org.apache.cloudstack.api.response.QuotaStatementItemResponse;
 import org.apache.cloudstack.api.response.QuotaStatementResponse;
-import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.quota.vo.QuotaUsageVO;
-import org.apache.cloudstack.api.response.QuotaStatementItemResponse;
+import org.apache.log4j.Logger;
 
 import com.cloud.user.Account;
 
@@ -62,7 +61,7 @@
     private Long accountId;
 
     @Inject
-    QuotaResponseBuilder _responseBuilder;
+    private QuotaResponseBuilder _responseBuilder;
 
     public Long getAccountId() {
         return accountId;
@@ -119,9 +118,9 @@ public String getCommandName() {
 
     @Override
     public long getEntityOwnerId() {
-        Long accountId = _accountService.getActiveAccountByName(accountName, domainId).getAccountId();
-        if (accountId == null) {
-            return CallContext.current().getCallingAccount().getId();
+        Account activeAccountByName = _accountService.getActiveAccountByName(accountName,
domainId);
+        if (activeAccountByName != null) {
+            return activeAccountByName.getAccountId();
         }
         return Account.ACCOUNT_ID_SYSTEM;
     }
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateWithStorageReceiveCommandWrapper.java
b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateWithStorageReceiveCommandWrapper.java
index fdcb7b5ffbe..803e24bb439 100644
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateWithStorageReceiveCommandWrapper.java
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateWithStorageReceiveCommandWrapper.java
@@ -21,10 +21,9 @@
 
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Map;
 import java.util.List;
+import java.util.Map;
 
-import com.google.gson.Gson;
 import org.apache.log4j.Logger;
 
 import com.cloud.agent.api.Answer;
@@ -39,8 +38,8 @@
 import com.cloud.network.Networks.TrafficType;
 import com.cloud.resource.CommandWrapper;
 import com.cloud.resource.ResourceWrapper;
-import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.Pair;
+import com.cloud.utils.exception.CloudRuntimeException;
 import com.xensource.xenapi.Connection;
 import com.xensource.xenapi.Host;
 import com.xensource.xenapi.Network;
@@ -66,7 +65,6 @@ public Answer execute(final MigrateWithStorageReceiveCommand command, final
XenS
             // agent attache. Seriliaze the SR and Network objects here to a string and pass
in
             // the answer object. It'll be deserialzed and object created in migrate with
             // storage send command execution.
-            Gson gson = new Gson();
             // Get a map of all the SRs to which the vdis will be migrated.
             final List<Pair<VolumeTO, Object>> volumeToSr = new ArrayList<>();
 
@@ -76,7 +74,6 @@ public Answer execute(final MigrateWithStorageReceiveCommand command, final
XenS
 
                 volumeToSr.add(new Pair<VolumeTO, Object>(entry.first(), sr));
             }
-
             // Get the list of networks to which the vifs will attach.
             final List<Pair<NicTO, Object>> nicToNetwork = new ArrayList<Pair<NicTO,
Object>>();
             for (final NicTO nicTo : vmSpec.getNics()) {
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateWithStorageSendCommandWrapper.java
b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateWithStorageSendCommandWrapper.java
index d847cd9e844..c4ebb0065e9 100644
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateWithStorageSendCommandWrapper.java
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xen610/XenServer610MigrateWithStorageSendCommandWrapper.java
@@ -20,11 +20,10 @@
 package com.cloud.hypervisor.xenserver.resource.wrapper.xen610;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.List;
 
-import com.google.gson.Gson;
 import org.apache.log4j.Logger;
 
 import com.cloud.agent.api.Answer;
@@ -36,8 +35,8 @@
 import com.cloud.hypervisor.xenserver.resource.XenServer610Resource;
 import com.cloud.resource.CommandWrapper;
 import com.cloud.resource.ResourceWrapper;
-import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.Pair;
+import com.cloud.utils.exception.CloudRuntimeException;
 import com.xensource.xenapi.Connection;
 import com.xensource.xenapi.Network;
 import com.xensource.xenapi.SR;
@@ -73,7 +72,6 @@ public Answer execute(final MigrateWithStorageSendCommand command, final
XenServ
             // agent attache. Seriliaze the SR and Network objects here to a string and pass
in
             // the answer object. It'll be deserialzed and object created in migrate with
             // storage send command execution.
-            Gson gson = new Gson();
             final Map<String, String> other = new HashMap<String, String>();
             other.put("live", "true");
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Fix Coverity new problems CID(1349987, 1349986, 1347248) 
> ---------------------------------------------------------
>
>                 Key: CLOUDSTACK-10156
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10156
>             Project: CloudStack
>          Issue Type: Improvement
>      Security Level: Public(Anyone can view this level - this is the default.) 
>            Reporter: Rafael Weingärtner
>            Assignee: Rafael Weingärtner
>            Priority: Minor
>
> Solving Coverity new problems CID(1349987, 1349986, 1347248).
> This is  basically the removal of dead code.
> The PR used to solve those problems is: https://github.com/apache/cloudstack/pull/2332



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message