Kaydet (Commit) 957bd581 authored tarafından Miklos Vajna's avatar Miklos Vajna

error: could not convert from 'void' to 'bool'

coverity#1202762 fix probably wanted to handle the result of
dbus_message_iter_init(), not the result of
dbus_message_iter_init_append()

Change-Id: I31de559b729421bace92b0a768cb218b072d7b4c
üst 59af5e5b
...@@ -769,27 +769,22 @@ setDBusBooleanProperty( DBusConnection *pConnection, DBusObject *pAdapter, ...@@ -769,27 +769,22 @@ setDBusBooleanProperty( DBusConnection *pConnection, DBusObject *pAdapter,
DBusMessage *pMsg = pProperties->getMethodCall( "Set" ); DBusMessage *pMsg = pProperties->getMethodCall( "Set" );
DBusMessageIter itIn; DBusMessageIter itIn;
if(!dbus_message_iter_init_append( pMsg, &itIn )) dbus_message_iter_init_append( pMsg, &itIn );
const char* pInterface = "org.bluez.Adapter1";
dbus_message_iter_append_basic( &itIn, DBUS_TYPE_STRING, &pInterface );
dbus_message_iter_append_basic( &itIn, DBUS_TYPE_STRING, &pPropertyName );
{ {
SAL_WARN( "sdremote.bluetooth", "error init dbus" ); DBusMessageIter varIt;
dbus_message_iter_open_container( &itIn, DBUS_TYPE_VARIANT,
DBUS_TYPE_BOOLEAN_AS_STRING, &varIt );
dbus_bool_t bDBusBoolean = bBoolean;
dbus_message_iter_append_basic( &varIt, DBUS_TYPE_BOOLEAN, &bDBusBoolean );
dbus_message_iter_close_container( &itIn, &varIt );
} }
else
{
const char* pInterface = "org.bluez.Adapter1";
dbus_message_iter_append_basic( &itIn, DBUS_TYPE_STRING, &pInterface );
dbus_message_iter_append_basic( &itIn, DBUS_TYPE_STRING, &pPropertyName );
{ pMsg = sendUnrefAndWaitForReply( pConnection, pMsg );
DBusMessageIter varIt;
dbus_message_iter_open_container( &itIn, DBUS_TYPE_VARIANT,
DBUS_TYPE_BOOLEAN_AS_STRING, &varIt );
dbus_bool_t bDBusBoolean = bBoolean;
dbus_message_iter_append_basic( &varIt, DBUS_TYPE_BOOLEAN, &bDBusBoolean );
dbus_message_iter_close_container( &itIn, &varIt );
}
pMsg = sendUnrefAndWaitForReply( pConnection, pMsg );
}
if( !pMsg ) if( !pMsg )
{ {
SAL_WARN( "sdremote.bluetooth", "no valid reply / timeout" ); SAL_WARN( "sdremote.bluetooth", "no valid reply / timeout" );
...@@ -917,45 +912,48 @@ DBusHandlerResult ProfileMessageFunction ...@@ -917,45 +912,48 @@ DBusHandlerResult ProfileMessageFunction
} }
DBusMessageIter it; DBusMessageIter it;
dbus_message_iter_init(pMessage, &it); if (!dbus_message_iter_init(pMessage, &it))
SAL_WARN( "sdremote.bluetooth", "error init dbus" );
else
{
char* pPath;
dbus_message_iter_get_basic(&it, &pPath);
SAL_INFO("sdremote.bluetooth", "Adapter path:" << pPath);
char* pPath; if (!dbus_message_iter_next(&it))
dbus_message_iter_get_basic(&it, &pPath); SAL_WARN("sdremote.bluetooth", "not enough parameters passed");
SAL_INFO("sdremote.bluetooth", "Adapter path:" << pPath);
if (!dbus_message_iter_next(&it)) // DBUS_TYPE_UNIX_FD == 'h' -- doesn't exist in older versions
SAL_WARN("sdremote.bluetooth", "not enough parameters passed"); // of dbus (< 1.3?) hence defined manually for now
if ('h' == dbus_message_iter_get_arg_type(&it))
{
// DBUS_TYPE_UNIX_FD == 'h' -- doesn't exist in older versions int nDescriptor;
// of dbus (< 1.3?) hence defined manually for now dbus_message_iter_get_basic(&it, &nDescriptor);
if ('h' == dbus_message_iter_get_arg_type(&it)) std::vector<Communicator*>* pCommunicators = (std::vector<Communicator*>*) user_data;
{
int nDescriptor; // Bluez gives us non-blocking sockets, but our code relies
dbus_message_iter_get_basic(&it, &nDescriptor); // on blocking behaviour.
std::vector<Communicator*>* pCommunicators = (std::vector<Communicator*>*) user_data; (void)fcntl(nDescriptor, F_SETFL, fcntl(nDescriptor, F_GETFL) & ~O_NONBLOCK);
// Bluez gives us non-blocking sockets, but our code relies SAL_INFO( "sdremote.bluetooth", "connection accepted " << nDescriptor);
// on blocking behaviour. Communicator* pCommunicator = new Communicator( new BufferedStreamSocket( nDescriptor ) );
(void)fcntl(nDescriptor, F_SETFL, fcntl(nDescriptor, F_GETFL) & ~O_NONBLOCK); pCommunicators->push_back( pCommunicator );
pCommunicator->launch();
}
SAL_INFO( "sdremote.bluetooth", "connection accepted " << nDescriptor); // For some reason an (empty?) reply is expected.
Communicator* pCommunicator = new Communicator( new BufferedStreamSocket( nDescriptor ) ); DBusMessage* pRet = dbus_message_new_method_return(pMessage);
pCommunicators->push_back( pCommunicator ); dbus_connection_send(pConnection, pRet, NULL);
pCommunicator->launch(); dbus_message_unref(pRet);
// We could read the remote profile version and features here
// (i.e. they are provided as part of the DBusMessage),
// however for us they are irrelevant (as our protocol handles
// equivalent functionality independently of whether we're on
// bluetooth or normal network connection).
return DBUS_HANDLER_RESULT_HANDLED;
} }
// For some reason an (empty?) reply is expected.
DBusMessage* pRet = dbus_message_new_method_return(pMessage);
dbus_connection_send(pConnection, pRet, NULL);
dbus_message_unref(pRet);
// We could read the remote profile version and features here
// (i.e. they are provided as part of the DBusMessage),
// however for us they are irrelevant (as our protocol handles
// equivalent functionality independently of whether we're on
// bluetooth or normal network connection).
return DBUS_HANDLER_RESULT_HANDLED;
} }
else if (OString(dbus_message_get_member(pMessage)).equals("RequestDisconnection")) else if (OString(dbus_message_get_member(pMessage)).equals("RequestDisconnection"))
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment