*
* Connection Manager
*
- * Copyright (C) 2011 Intel Corporation. All rights reserved.
+ * Copyright (C) 2012-2013 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
}
-static int ppp_have_secret()
+static int ppp_have_secret(void)
{
return 1;
}
const char *user, *pass;
DBusError err;
- if (username == NULL && password == NULL)
+ if (!username && !password)
return -1;
- if (password == NULL)
+ if (!password)
return 1;
- if (connection == NULL)
+ if (!connection)
return -1;
dbus_error_init(&err);
msg = dbus_message_new_method_call(busname, path, interface, "getsec");
- if (msg == NULL)
+ if (!msg)
return -1;
dbus_message_append_args(msg, DBUS_TYPE_INVALID, DBUS_TYPE_INVALID);
reply = dbus_connection_send_with_reply_and_block(connection,
msg, -1, &err);
- if (reply == NULL) {
- if (dbus_error_is_set(&err) == TRUE)
+ if (!reply) {
+ if (dbus_error_is_set(&err))
dbus_error_free(&err);
dbus_message_unref(msg);
dbus_error_init(&err);
- if (dbus_message_get_args(reply, &err, DBUS_TYPE_STRING, &user,
- DBUS_TYPE_STRING, &pass,
- DBUS_TYPE_INVALID) == FALSE) {
- if (dbus_error_is_set(&err) == TRUE)
+ if (!dbus_message_get_args(reply, &err, DBUS_TYPE_STRING, &user,
+ DBUS_TYPE_STRING, &pass,
+ DBUS_TYPE_INVALID)) {
+ if (dbus_error_is_set(&err))
dbus_error_free(&err);
dbus_message_unref(reply);
return -1;
}
- if (username != NULL)
+ if (username)
strcpy(username, user);
strcpy(password, pass);
DBusMessageIter iter, dict;
DBusMessage *msg;
- if (connection == NULL)
+ if (!connection)
return;
if (ipcp_gotoptions[0].ouraddr == 0)
msg = dbus_message_new_method_call(busname, path,
interface, "notify");
- if (msg == NULL)
+ if (!msg)
return;
dbus_message_set_no_reply(msg, TRUE);
if (ipcp_gotoptions[0].dnsaddr[1]) {
inet_ntop(AF_INET, &ipcp_gotoptions[0].dnsaddr[1],
buf, INET_ADDRSTRLEN);
- if (add_blank == TRUE)
+ if (add_blank)
strcat(dns, " ");
strcat(dns, buf);
static void ppp_exit(void *data, int arg)
{
- if (connection != NULL) {
+ if (connection) {
dbus_connection_unref(connection);
connection = NULL;
}
- if (busname != NULL) {
+ if (busname) {
free(busname);
busname = NULL;
}
- if (interface != NULL) {
+ if (interface) {
free(interface);
interface = NULL;
}
- if (path != NULL) {
+ if (path) {
free(path);
path = NULL;
}
DBusMessage *msg;
int send_msg = 0;
- if (connection == NULL)
+ if (!connection)
return;
if (prev_phase == PHASE_AUTHENTICATE &&
if (send_msg > 0 || arg == PHASE_DEAD || arg == PHASE_DISCONNECT) {
msg = dbus_message_new_method_call(busname, path,
interface, "notify");
- if (msg == NULL)
+ if (!msg)
return;
dbus_message_set_no_reply(msg, TRUE);
inter = getenv("CONNMAN_INTERFACE");
p = getenv("CONNMAN_PATH");
- if (bus == NULL || inter == NULL || p == NULL)
+ if (!bus || !inter || !p)
return -1;
busname = strdup(bus);
interface = strdup(inter);
path = strdup(p);
- if (busname == NULL || interface == NULL || path == NULL) {
+ if (!busname || !interface || !path) {
ppp_exit(NULL, 0);
return -1;
}
connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
- if (connection == NULL) {
- if (dbus_error_is_set(&error) == TRUE)
+ if (!connection) {
+ if (dbus_error_is_set(&error))
dbus_error_free(&error);
ppp_exit(NULL, 0);