bluetoothmgmt/bluetoothclientlib/btlib/btsocket.cpp
changeset 51 20ac952a623c
parent 17 907b2fb7aa8e
--- a/bluetoothmgmt/bluetoothclientlib/btlib/btsocket.cpp	Thu Sep 23 17:06:47 2010 +0300
+++ b/bluetoothmgmt/bluetoothclientlib/btlib/btsocket.cpp	Wed Oct 13 16:20:29 2010 +0300
@@ -25,10 +25,16 @@
 
 
 void Panic(TBTSocketPanics aCode)
-	{
-	_LIT(KPanicName, "BTSocket");
-	User::Panic(KPanicName, aCode);
-	}
+    {
+    _LIT(KPanicName, "BTSocket");
+    User::Panic(KPanicName, aCode);
+    }
+
+void GeneralPanic(TInt aCode)
+    {
+    _LIT(KPanicName, "BTSocket-General");
+    User::Panic(KPanicName, aCode);
+    }
 
 
 
@@ -1674,15 +1680,20 @@
 	// This is done as a best effort in order to make more efficient usage
 	// of the baseband packets being created. As a result we don't bother 
 	// checking the results as if they fail it won't cause the socket to 
-	// behave incorrectly	
-	TPckgBuf<TUint> optBuf(65535); //If all else fails we should get a max 64K buffer
+	// behave incorrectly
+    
+    // Note. We are managing the fact that the GetOpts might fail using
+    // this KMaxBufferSize, hence the Coverity tags.
+	const TUint KMaxBufferSize = 65535; //max 64K buffer	
+	TPckgBuf<TUint> optBuf(KMaxBufferSize); //If all else fails we should get a max 64K buffer
 	TProtocolDesc info;
 	
 	TInt err = iSocket.Info(info);
 	
 	if (err == KErrNone && info.iProtocol == KRFCOMM)
 		{
-		// For RFCOMM we set the buffers based on the optimal MTU for RFCOMM	
+		// For RFCOMM we set the buffers based on the optimal MTU for RFCOMM
+		// Coverity[check_return]
 		iSocket.GetOpt(KRFCOMMMaximumMTU, KSolBtRFCOMM, optBuf);
 		iSocket.SetOpt(KSOSendBuf, KSOLSocket, optBuf);
 		iSocket.SetOpt(KSORecvBuf, KSOLSocket, optBuf);		
@@ -1690,10 +1701,12 @@
 	else
 		{
 		// For L2CAP, or others, we just ensure that we can accomodate the negotiated MTU
+		// Coverity[check_return]
 		iSocket.GetOpt(KL2CAPNegotiatedOutboundMTU, KSolBtL2CAP, optBuf);
 		iSocket.SetOpt(KSOSendBuf, KSOLSocket, optBuf);
-			
-		iSocket.GetOpt(KL2CAPInboundMTU, KSolBtL2CAP, optBuf);
+
+		err = iSocket.GetOpt(KL2CAPInboundMTU, KSolBtL2CAP, optBuf);
+		optBuf = err?KMaxBufferSize:optBuf(); //if err use max buf not the result of the previous GetOpt
 		iSocket.SetOpt(KSORecvBuf, KSOLSocket, optBuf);
 		}
 	}