Skip to contentSkip to conversation

staging: unisys: uislib: uislib.c: sparse warning of context imbalance

PATCH In review Sudip Mukherjee 3 participants 11 messages Sep 5, 2014 – Sep 8, 2014 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: unisys: uislib: uislib.c: sparse warning of context imbalance

fixed sparse warning : context imbalance in 'pause_device'
unexpected unlock
this patch will generate warning from checkpatch for lines over 80 character , but since those are user-visible strings so it was not modified.

---

hi , can you please review the patch and see if the approach is correct. The functiion is still doing the same what it was doing , only the logic is changed. if the approach is ok, then i can send a patch to fix the other two similar warning in the file.

 drivers/staging/unisys/uislib/uislib.c | 82 ++++++++++++++++------------------
 1 file changed, 39 insertions(+), 43 deletions(-)
drivers/staging/unisys/uislib/uislib.c +39 -43
index 8b89fe3..3a92d9f 100644
@@ -548,6 +548,7 @@ pause_device(CONTROLVM_MESSAGE *msg)
 	struct bus_info *bus;
 	struct device_info *dev;
 	struct guest_msgs cmd;
+	int retval = CONTROLVM_RESP_SUCCESS;
 
 	busNo = msg->cmd.deviceChangeState.busNo;
 	devNo = msg->cmd.deviceChangeState.devNo;
@@ -559,58 +560,53 @@ pause_device(CONTROLVM_MESSAGE *msg)
 			if (devNo >= bus->deviceCount) {
 				LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: device(%d) >= deviceCount(%d).",
 				     devNo, bus->deviceCount);
-				read_unlock(&BusListLock);
-				return CONTROLVM_RESP_ERROR_DEVICE_INVALID;
-			}
-			/* make sure this device exists */
-			dev = bus->device[devNo];
-			if (!dev) {
-				LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: device %d does not exist.",
-				     devNo);
-				read_unlock(&BusListLock);
-				return CONTROLVM_RESP_ERROR_ALREADY_DONE;
-			}
-			read_unlock(&BusListLock);
-			/* the msg is bound for virtpci; send
-			 * guest_msgs struct to callback
-			 */
-			if (!uuid_le_cmp(dev->channelTypeGuid,
-					UltraVhbaChannelProtocolGuid)) {
-				cmd.msgtype = GUEST_PAUSE_VHBA;
-				cmd.pause_vhba.chanptr = dev->chanptr;
-			} else
-			    if (!uuid_le_cmp(dev->channelTypeGuid,
-					    UltraVnicChannelProtocolGuid)) {
-				cmd.msgtype = GUEST_PAUSE_VNIC;
-				cmd.pause_vnic.chanptr = dev->chanptr;
+				retval = CONTROLVM_RESP_ERROR_DEVICE_INVALID;
 			} else {
-				LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: unknown channelTypeGuid.\n");
-				return
-				    CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN;
-			}
-
-			if (!VirtControlChanFunc) {
-				LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: virtpci callback not registered.");
-				return
-				    CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE;
-			}
-
-			if (!VirtControlChanFunc(&cmd)) {
-				LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: virtpci GUEST_PAUSE_[VHBA||VNIC] returned error.");
-				return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR;
+				/* make sure this device exists */
+				dev = bus->device[devNo];
+				if (!dev) {
+					LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: device %d does not exist.",
+					     devNo);
+					retval =
+					  CONTROLVM_RESP_ERROR_ALREADY_DONE;
+				}
 			}
 			break;
 		}
 	}
-
 	if (!bus) {
 		LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: bus %d does not exist",
 		     busNo);
-		read_unlock(&BusListLock);
-		return CONTROLVM_RESP_ERROR_BUS_INVALID;
+		retval = CONTROLVM_RESP_ERROR_BUS_INVALID;
 	}
-
-	return CONTROLVM_RESP_SUCCESS;
+	read_unlock(&BusListLock);
+	if (retval == CONTROLVM_RESP_SUCCESS) {
+		/* the msg is bound for virtpci; send
+		 * guest_msgs struct to callback
+		 */
+		if (!uuid_le_cmp(dev->channelTypeGuid,
+				UltraVhbaChannelProtocolGuid)) {
+			cmd.msgtype = GUEST_PAUSE_VHBA;
+			cmd.pause_vhba.chanptr = dev->chanptr;
+		} else if (!uuid_le_cmp(dev->channelTypeGuid,
+					UltraVnicChannelProtocolGuid)) {
+			cmd.msgtype = GUEST_PAUSE_VNIC;
+			cmd.pause_vnic.chanptr = dev->chanptr;
+		} else {
+			LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: unknown channelTypeGuid.\n");
+			return CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN;
+		}
+		if (!VirtControlChanFunc) {
+			LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: virtpci callback not registered.");
+			return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE;
+		}
+		if (!VirtControlChanFunc(&cmd)) {
+			LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: virtpci GUEST_PAUSE_[VHBA||VNIC] returned error.");
+			return
+			  CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR;
+		}
+	}
+	return retval;
 }
 
 static int
Signature · 1 line
1.8.1.2
Tested-by on v1 1/1
#1 lore raw
Quoted 6 lines · Sudip Mukherjee

fixed sparse warning : context imbalance in 'pause_device'
unexpected unlock
this patch will generate warning from checkpatch for lines over 80 character , but since those are user-visible strings so it was not modified.

Quoted 7 lines

---

hi , can you please review the patch and see if the approach is correct. The functiion is still doing the same what it was doing , only the logic is changed. if the approach is ok, then i can send a patch to fix the other two similar warning in the file.

Hi Sudip,

I was able to successfully build and test your patch. The changes look good to me too, so I think we should take this patch. :)

Thanks!
-- Ben

���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

#2 lore raw
Quoted 15 lines · Benjamin M
Quoted 6 lines · Sudip Mukherjee

fixed sparse warning : context imbalance in 'pause_device'
unexpected unlock
this patch will generate warning from checkpatch for lines over 80 character , but since those are user-visible strings so it was not modified.

Quoted 7 lines

---

hi , can you please review the patch and see if the approach is correct. The functiion is still doing the same what it was doing , only the logic is changed. if the approach is ok, then i can send a patch to fix the other two similar warning in the file.

Quoted 8 lines

Hi Sudip,

I was able to successfully build and test your patch. The changes look good to me too, so I think we should take this patch. :)

Thanks!
-- Ben

Hi Ben,
thanks. the same file is having two more similar warnings. if you want i can resend a patch fixing all the three warnings , or i can send two separate patches.
I personally will prefer two separate patches , as that will be easier for you to test and review.

thanks
sudip

Quoted 2 lines
#3 lore raw
Quoted 9 lines · Sudip Mukherjee

Hi Ben,
thanks. the same file is having two more similar warnings. if you want i can resend a patch fixing all the three warnings , or i can send two separate patches.
I personally will prefer two separate patches , as that will be easier for you to test and review.

thanks
sudip

That would be perfect, thanks. :)

-- Ben ���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

#4 lore raw
Quoted 8 lines · Benjamin M
Quoted 7 lines · Sudip Mukherjee

Hi Ben,
thanks. the same file is having two more similar warnings. if you want i can resend a patch fixing all the three warnings , or i can send two separate patches.
I personally will prefer two separate patches , as that will be easier for you to test and review.

Quoted 6 lines
Quoted 2 lines

thanks
sudip

That would be perfect, thanks. :)

-- Ben

Hi Ben,
sorry to disturb you again. i got confused , which one is perfect one combined patch or separate patches?

thanks
sudip

#5 lore raw
Quoted 6 lines · Sudip Mukherjee

Hi Ben,
sorry to disturb you again. i got confused , which one is perfect one combined patch or separate patches?

thanks
sudip

Two patches, as you preferred.

-- Ben

���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

#6 lore raw
Quoted 5 lines · Benjamin M
Quoted 4 lines · Sudip Mukherjee

Hi Ben,
sorry to disturb you again. i got confused , which one is perfect one combined patch or separate patches?

Quoted 8 lines
Quoted 2 lines

thanks
sudip

Two patches, as you preferred.

-- Ben

ok. and if you get time can you please also have a look at :
[PATCH v4] staging: unisys: uislib: uisqueue.c: rewrite of do_locked_client_insert Dan Carpenter has already reviwed it.

thanks
sudip

maintainer Acked-by Developer Name
#7 lore raw
In reply to Romer, Benjamin M
Quoted 15 lines · Benjamin M
Quoted 6 lines · Sudip Mukherjee

fixed sparse warning : context imbalance in 'pause_device'
unexpected unlock
this patch will generate warning from checkpatch for lines over 80 character , but since those are user-visible strings so it was not modified.

Quoted 7 lines

---

hi , can you please review the patch and see if the approach is correct. The functiion is still doing the same what it was doing , only the logic is changed. if the approach is ok, then i can send a patch to fix the other two similar warning in the file.

Quoted 4 lines

Hi Sudip,

I was able to successfully build and test your patch. The changes look good to me too, so I think we should take this patch. :)

Traditionally, you would respond with a:

so I can add it to the patch.

Care to do that here?

thanks,

greg k-h

#8 lore raw
Quoted 9 lines · Greg Kroah-Hartman

Traditionally, you would respond with a:

so I can add it to the patch.

Care to do that here?

thanks,

greg k-h

Of course. :)

Should I do this instead of Tested-by and Signed-off-by, in the future?

-- Ben ���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

#9 lore raw
Quoted 9 lines · Benjamin M
Quoted 8 lines · Greg Kroah-Hartman

Traditionally, you would respond with a:

so I can add it to the patch.

Care to do that here?

thanks,

Quoted 7 lines
Quoted 1 line

greg k-h

Of course. :)

Should I do this instead of Tested-by and Signed-off-by, in the future?

If you test it, do a tested-by.

If you sign off on it (i.e. it flows through you to me), then a signed-off is correct.

Hope this helps,

greg k-h

Acked-by Tested-by
#10 lore raw
Quoted 8 lines · Greg Kroah-Hartman

If you test it, do a tested-by.

If you sign off on it (i.e. it flows through you to me), then a signed-off is correct.

Hope this helps,

greg k-h

It does. :) We should add the Tested-by then, too.

-- Ben

���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�