~connman-maintainers/connman/head

« back to all changes in this revision

Viewing changes to src/agent.c

  • Committer: Patrik Flykt
  • Author(s): Daniel Wagner
  • Date: 2013-08-07 06:46:54 UTC
  • Revision ID: git-v1:bd99aaa74d1c627d43353ed0ae77b72e1e2bc8e6
core: Do not compare expression against NULL

This patch generate via coccinelle with:

@ disable is_null,isnt_null1 @
expression E;
@@

(
- E == NULL
+ !E
|
- E != NULL
+ E
)

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
 
61
61
static void agent_data_free(struct connman_agent *data)
62
62
{
63
 
        if (data == NULL)
 
63
        if (!data)
64
64
                return;
65
 
        if (data->user_context != NULL) {
66
 
                if (data->driver != NULL && data->driver->context_unref != NULL)
 
65
        if (data->user_context) {
 
66
                if (data->driver && data->driver->context_unref)
67
67
                        data->driver->context_unref(data->user_context);
68
68
        }
69
 
        if (data->msg != NULL)
 
69
        if (data->msg)
70
70
                dbus_message_unref(data->msg);
71
 
        if (data->call != NULL)
 
71
        if (data->call)
72
72
                dbus_pending_call_cancel(data->call);
73
73
 
74
74
        g_free(data);
78
78
 
79
79
static int agent_send_next_request(void)
80
80
{
81
 
        if (agent_request != NULL)
 
81
        if (agent_request)
82
82
                return -EBUSY;
83
83
 
84
 
        if (agent_queue == NULL)
 
84
        if (!agent_queue)
85
85
                return 0;
86
86
 
87
87
        agent_request = agent_queue->data;
92
92
                                                agent_request->timeout))
93
93
                goto fail;
94
94
 
95
 
        if (agent_request->call == NULL)
 
95
        if (!agent_request->call)
96
96
                goto fail;
97
97
 
98
98
        if (!dbus_pending_call_set_notify(agent_request->call,
114
114
{
115
115
        DBusMessage *message;
116
116
 
117
 
        if (agent_sender == NULL || agent == NULL || agent->driver == NULL)
 
117
        if (!agent_sender || !agent || !agent->driver)
118
118
                return 0;
119
119
 
120
120
        message = dbus_message_new_method_call(agent_sender, agent_path,
121
121
                        agent->driver->interface, "Cancel");
122
 
        if (message != NULL) {
 
122
        if (message) {
123
123
                dbus_message_set_no_reply(message, TRUE);
124
124
                g_dbus_send_message(connection, message);
125
125
                return 0;
178
178
        struct connman_agent_driver *driver;
179
179
        int err;
180
180
 
181
 
        if (user_context == NULL || callback == NULL)
 
181
        if (!user_context || !callback)
182
182
                return -EBADMSG;
183
183
 
184
184
        queue_data = g_new0(struct connman_agent, 1);
185
 
        if (queue_data == NULL)
 
185
        if (!queue_data)
186
186
                return -ENOMEM;
187
187
 
188
188
        driver = get_driver();
189
189
        DBG("driver %p", driver);
190
190
 
191
 
        if (driver != NULL && driver->context_ref != NULL) {
 
191
        if (driver && driver->context_ref) {
192
192
                queue_data->user_context = driver->context_ref(user_context);
193
193
                queue_data->driver = driver;
194
194
        } else
217
217
 
218
218
        item = agent_queue;
219
219
 
220
 
        while (item != NULL) {
 
220
        while (item) {
221
221
                next = g_list_next(item);
222
222
                queued_req = item->data;
223
223
 
224
224
                if (queued_req->user_context == user_context ||
225
 
                                                        user_context == NULL) {
 
225
                                                        !user_context) {
226
226
                        agent_data_free(queued_req);
227
227
                        agent_queue = g_list_delete_link(agent_queue, item);
228
228
                }
230
230
                item = next;
231
231
        }
232
232
 
233
 
        if (agent_request == NULL)
 
233
        if (!agent_request)
234
234
                return;
235
235
 
236
236
        if (agent_request->user_context != user_context &&
237
 
                                                user_context != NULL)
 
237
                                                user_context)
238
238
                return;
239
239
 
240
240
        agent_send_cancel(agent_request);
272
272
int connman_agent_register(const char *sender, const char *path)
273
273
{
274
274
        DBG("sender %s path %s", sender, path);
275
 
        if (agent_path != NULL)
 
275
        if (agent_path)
276
276
                return -EEXIST;
277
277
 
278
278
        agent_sender = g_strdup(sender);
288
288
{
289
289
        DBG("sender %s path %s", sender, path);
290
290
 
291
 
        if (agent_path == NULL)
 
291
        if (!agent_path)
292
292
                return -ESRCH;
293
293
 
294
294
        if (agent_watch > 0)
313
313
 
314
314
        if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {
315
315
                dbus_err = dbus_message_get_error_name(reply);
316
 
                if (dbus_err != NULL &&
 
316
                if (dbus_err &&
317
317
                        strcmp(dbus_err,
318
318
                                CONNMAN_AGENT_INTERFACE ".Error.Retry") == 0)
319
319
                        retry = true;
333
333
        struct report_error_data *report_error;
334
334
        int err;
335
335
 
336
 
        if (user_context == NULL || agent_path == NULL || error == NULL ||
337
 
                                                        callback == NULL)
 
336
        if (!user_context || !agent_path || !error ||
 
337
                                                        !callback)
338
338
                return -ESRCH;
339
339
 
340
340
        message = dbus_message_new_method_call(agent_sender, agent_path,
341
341
                                        CONNMAN_AGENT_INTERFACE,
342
342
                                        "ReportError");
343
 
        if (message == NULL)
 
343
        if (!message)
344
344
                return -ENOMEM;
345
345
 
346
346
        dbus_message_iter_init_append(message, &iter);
351
351
                                DBUS_TYPE_STRING, &error);
352
352
 
353
353
        report_error = g_try_new0(struct report_error_data, 1);
354
 
        if (report_error == NULL) {
 
354
        if (!report_error) {
355
355
                dbus_message_unref(message);
356
356
                return -ENOMEM;
357
357
        }
411
411
{
412
412
        GSList *list;
413
413
 
414
 
        if (driver == NULL)
 
414
        if (!driver)
415
415
                return;
416
416
 
417
417
        DBG("Unregistering driver %p name %s", driver, driver->name);
418
418
 
419
 
        if (agent_sender == NULL && agent_path == NULL)
 
419
        if (!agent_sender && !agent_path)
420
420
                goto out;
421
421
 
422
422
        for (list = driver_list; list; list = list->next) {
430
430
 
431
431
                message = dbus_message_new_method_call(agent_sender, agent_path,
432
432
                                driver->interface, "Release");
433
 
                if (message != NULL) {
 
433
                if (message) {
434
434
                        dbus_message_set_no_reply(message, TRUE);
435
435
                        g_dbus_send_message(connection, message);
436
436
                }
459
459
        DBG("");
460
460
 
461
461
        connection = connman_dbus_get_connection();
462
 
        if (connection == NULL)
 
462
        if (!connection)
463
463
                return -1;
464
464
 
465
465
        return 0;
469
469
{
470
470
        DBG("");
471
471
 
472
 
        if (connection == NULL)
 
472
        if (!connection)
473
473
                return;
474
474
 
475
475
        if (agent_watch > 0)