summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2013-07-22 16:22:20 +0200
committerDaniel Wagner <daniel.wagner@bmw-carit.de>2013-07-23 09:03:36 +0200
commit47e034b91eb042ec31cf0c53baec26bd934951b7 (patch)
tree61b89189fffa041fb35843dc6036fefc03e89b59
parenta56c9f7f460fa1d7b8e65692971cedc1bc8d9fd3 (diff)
downloadconnman-47e034b91eb042ec31cf0c53baec26bd934951b7.tar.gz
tools: Convert to stdbool with coccinelle
This patch is completely generated by set of coccille rules and containts zero manual changes. The rule set is not really beautiful but it does the job. We might miss a few conversions but there should be none accidently wrong converted bool here. The rules are as following: //// Do not compare boolean expressions @@ expression E; symbol TRUE; symbol FALSE; @@ ( E - == TRUE | - TRUE == E + E | - E != TRUE + !E | - TRUE != E + !E | - E == FALSE + !E | - FALSE == E + !E | E - != FALSE | - FALSE != E + E ) //// Convert connman_bool_t to stdbool @@ connman_bool_t x; @@ x = ( - TRUE + true | - FALSE + false ) @@ identifier f; @@ connman_bool_t f(...) { <... - return TRUE; + return true; ...> } @@ identifier f; @@ connman_bool_t f(...) { <... - return FALSE; + return false; ...> } @r@ identifier f; parameter list[n] ps; identifier i; @@ f(ps, connman_bool_t i, ...) { ... } @@ identifier r.f; expression list [r.n] es; @@ f(es, ( - FALSE + false | - TRUE + true ) ,...) @r2@ type T; identifier f; parameter list[n] ps; identifier i; @@ T f(ps, connman_bool_t i, ...); @@ identifier r2.f; expression list [r.n] es; @@ f(es, ( - FALSE + false | - TRUE + true ) ,...) @@ typedef bool; @@ - connman_bool_t + bool //// Convert gboolean to stdbool @@ gboolean x; @@ x = ( - TRUE + true | - FALSE + false ) // Figure out which function signature will to be fixed... // when we have the defitition @r@ identifier f; parameter list[n] ps; identifier i; @@ f(ps, gboolean i, ...) { ... } // ... and now convert all call sites @@ identifier r.f; expression list [r.n] es; @@ f(es, ( - FALSE + false | - TRUE + true ) ,...) // Figure out which function signature will to be fixed... // when we have the declaration only @r2@ type T; identifier f; parameter list[n] ps; identifier i; @@ T f(ps, gboolean i, ...); // ... and now convert all call sites @@ identifier r2.f; expression list [r.n] es; @@ f(es, ( - FALSE + false | - TRUE + true ) ,...) // A handfull of the GLib hooks we can't change. Let's remember // all ther positions. // 1. timeouts @k1@ identifier f; position p; typedef gpointer; identifier ptr; @@ static gboolean@p f(gpointer ptr); @k2@ identifier f; position p; identifier ptr; @@ static gboolean@p f(gpointer ptr) { ... } // hash map iterator functions @k3@ identifier f; position p; identifier p1, p2, p3; @@ static gboolean@p f(gpointer p1, gpointer p2, gpointer p3) { ... } // 2. GIOChannel @k4@ identifier f; position p; typedef GIOChannel, GIOCondition; identifier ptr; identifier ch, cn; @@ static gboolean@p f(GIOChannel *ch, GIOCondition cn, gpointer ptr); @k5@ identifier f; position p; identifier ptr; identifier ch, cn; @@ static gboolean@p f(GIOChannel *ch, GIOCondition cn, gpointer ptr) { ... } // 3. GSourceFuncs @k6@ identifier f; position p; typedef GSource; identifier src; @@ static gboolean@p f(GSource *src, ...) { ... } // gdbus functions @k7@ identifier f; position p; typedef DBusConnection; identifier con; @@ static gboolean@p f(DBusConnection *con, ...) { ... } // Now convert all gboolean which are are not used for interactin // with GLib // Note here happens the magic! @@ typedef bool; position p != {k1.p,k2.p,k3.p,k4.p,k5.p,k6.p,k7.p}; @@ - gboolean@p + bool // Update all return types @@ identifier f; @@ bool f(...) { <... - return TRUE; + return true; ...> } @@ identifier f; @@ bool f(...) { <... - return FALSE; + return false; ...> } //// Last last rule is to fixup all missed call sites. In theory we should //// fixed them with some rules above but somehow coccinelle does not //// match. @@ identifier f =~ "^(__)?connman_.*" ; @@ f(..., ( - FALSE + false | - TRUE + true ) ,...)
-rw-r--r--tools/dbus-test.c2
-rw-r--r--tools/iptables-test.c2
-rw-r--r--tools/iptables-unit.c14
-rw-r--r--tools/manager-api.c14
-rw-r--r--tools/polkit-test.c2
-rw-r--r--tools/private-network-test.c2
-rw-r--r--tools/resolv-test.c6
-rw-r--r--tools/session-api.c28
-rw-r--r--tools/session-test.c16
-rw-r--r--tools/session-test.h2
-rw-r--r--tools/session-utils.c4
-rw-r--r--tools/stats-tool.c24
-rw-r--r--tools/supplicant-dbus.c13
-rw-r--r--tools/supplicant-test.c2
-rw-r--r--tools/supplicant.c69
-rw-r--r--tools/web-test.c12
-rw-r--r--tools/wispr.c74
-rw-r--r--tools/wpad-test.c6
18 files changed, 140 insertions, 152 deletions
diff --git a/tools/dbus-test.c b/tools/dbus-test.c
index 94d94f02..114a296b 100644
--- a/tools/dbus-test.c
+++ b/tools/dbus-test.c
@@ -60,7 +60,7 @@ int main(int argc, char *argv[])
conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, &err);
if (conn == NULL) {
- if (dbus_error_is_set(&err) == TRUE) {
+ if (dbus_error_is_set(&err)) {
fprintf(stderr, "%s\n", err.message);
dbus_error_free(&err);
} else
diff --git a/tools/iptables-test.c b/tools/iptables-test.c
index 1d964b9a..3e9f879a 100644
--- a/tools/iptables-test.c
+++ b/tools/iptables-test.c
@@ -129,7 +129,7 @@ out:
err = __connman_iptables_flush_chain(table, chain);
break;
case IPTABLES_COMMAND_DUMP:
- __connman_log_init(argv[0], "*", FALSE, FALSE,
+ __connman_log_init(argv[0], "*", false, false,
"iptables-test", "1");
err = __connman_iptables_dump(table);
break;
diff --git a/tools/iptables-unit.c b/tools/iptables-unit.c
index 8ddd9198..4675e39b 100644
--- a/tools/iptables-unit.c
+++ b/tools/iptables-unit.c
@@ -27,7 +27,7 @@
#include "../src/connman.h"
-static connman_bool_t assert_rule(const char *table_name, const char *rule)
+static bool assert_rule(const char *table_name, const char *rule)
{
char *cmd, *output, **lines;
GError **error = NULL;
@@ -48,9 +48,9 @@ static connman_bool_t assert_rule(const char *table_name, const char *rule)
g_strfreev(lines);
if (lines[i] == NULL)
- return FALSE;
+ return false;
- return TRUE;
+ return true;
}
static void assert_rule_exists(const char *table_name, const char *rule)
@@ -483,7 +483,7 @@ static void test_firewall_basic2(void)
static gchar *option_debug = NULL;
-static gboolean parse_debug(const char *key, const char *value,
+static bool parse_debug(const char *key, const char *value,
gpointer user_data, GError **error)
{
if (value)
@@ -491,7 +491,7 @@ static gboolean parse_debug(const char *key, const char *value,
else
option_debug = g_strdup("*");
- return TRUE;
+ return true;
}
static GOptionEntry options[] = {
@@ -512,7 +512,7 @@ int main(int argc, char *argv[])
context = g_option_context_new(NULL);
g_option_context_add_main_entries(context, options, NULL);
- if (g_option_context_parse(context, &argc, &argv, &error) == FALSE) {
+ if (!g_option_context_parse(context, &argc, &argv, &error)) {
if (error != NULL) {
g_printerr("%s\n", error->message);
g_error_free(error);
@@ -523,7 +523,7 @@ int main(int argc, char *argv[])
g_option_context_free(context);
- __connman_log_init(argv[0], option_debug, FALSE, FALSE,
+ __connman_log_init(argv[0], option_debug, false, false,
"Unit Tests Connection Manager", VERSION);
__connman_iptables_init();
diff --git a/tools/manager-api.c b/tools/manager-api.c
index cdf8fe79..5e8c9dd2 100644
--- a/tools/manager-api.c
+++ b/tools/manager-api.c
@@ -49,7 +49,7 @@ static DBusMessage *set_property(DBusConnection *connection,
reply = dbus_connection_send_with_reply_and_block(connection,
message, -1, &error);
if (reply == NULL) {
- if (dbus_error_is_set(&error) == TRUE) {
+ if (dbus_error_is_set(&error)) {
LOG("%s", error.message);
dbus_error_free(&error);
} else {
@@ -81,7 +81,7 @@ DBusMessage *manager_get_services(DBusConnection *connection)
reply = dbus_connection_send_with_reply_and_block(connection,
message, -1, &error);
if (reply == NULL) {
- if (dbus_error_is_set(&error) == TRUE) {
+ if (dbus_error_is_set(&error)) {
LOG("%s", error.message);
dbus_error_free(&error);
} else {
@@ -113,7 +113,7 @@ DBusMessage *manager_get_properties(DBusConnection *connection)
reply = dbus_connection_send_with_reply_and_block(connection,
message, -1, &error);
if (reply == NULL) {
- if (dbus_error_is_set(&error) == TRUE) {
+ if (dbus_error_is_set(&error)) {
LOG("%s", error.message);
dbus_error_free(&error);
} else {
@@ -159,7 +159,7 @@ DBusMessage *manager_create_session(DBusConnection *connection,
reply = dbus_connection_send_with_reply_and_block(connection,
message, -1, &error);
if (reply == NULL) {
- if (dbus_error_is_set(&error) == TRUE) {
+ if (dbus_error_is_set(&error)) {
LOG("%s", error.message);
dbus_error_free(&error);
} else {
@@ -198,7 +198,7 @@ DBusMessage *manager_destroy_session(DBusConnection *connection,
reply = dbus_connection_send_with_reply_and_block(connection,
message, -1, &error);
if (reply == NULL) {
- if (dbus_error_is_set(&error) == TRUE) {
+ if (dbus_error_is_set(&error)) {
LOG("%s", error.message);
dbus_error_free(&error);
} else {
@@ -214,7 +214,7 @@ DBusMessage *manager_destroy_session(DBusConnection *connection,
}
DBusMessage *manager_set_session_mode(DBusConnection *connection,
- connman_bool_t enable)
+ bool enable)
{
dbus_bool_t val = enable;
@@ -242,7 +242,7 @@ int manager_parse_properties(DBusMessage *msg,
switch (dbus_message_iter_get_arg_type(&value)) {
case DBUS_TYPE_STRING:
- if (g_str_equal(key, "State") == TRUE) {
+ if (g_str_equal(key, "State")) {
const char *val;
dbus_message_iter_get_basic(&value, &val);
diff --git a/tools/polkit-test.c b/tools/polkit-test.c
index 45e6eb80..ea1d24ae 100644
--- a/tools/polkit-test.c
+++ b/tools/polkit-test.c
@@ -142,7 +142,7 @@ static int check_authorization(DBusConnection *conn)
return -EIO;
}
- if (dbus_message_has_signature(reply, "(bba{ss})") == TRUE) {
+ if (dbus_message_has_signature(reply, "(bba{ss})")) {
dbus_message_iter_init(reply, &iter);
print_arguments(&iter);
}
diff --git a/tools/private-network-test.c b/tools/private-network-test.c
index 24f9234c..3dd115ba 100644
--- a/tools/private-network-test.c
+++ b/tools/private-network-test.c
@@ -101,7 +101,7 @@ static void request_private_network(DBusConnection *conn, int *out_fd,
return;
}
- if (dbus_message_iter_init(reply, &array) == FALSE)
+ if (!dbus_message_iter_init(reply, &array))
goto done;
if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_UNIX_FD)
diff --git a/tools/resolv-test.c b/tools/resolv-test.c
index 9867a4bb..a245c4c7 100644
--- a/tools/resolv-test.c
+++ b/tools/resolv-test.c
@@ -88,7 +88,7 @@ static void resolv_result(GResolvResultStatus status,
g_main_loop_quit(main_loop);
}
-static gboolean option_debug = FALSE;
+static bool option_debug = false;
static GOptionEntry options[] = {
{ "debug", 'd', 0, G_OPTION_ARG_NONE, &option_debug,
@@ -107,7 +107,7 @@ int main(int argc, char *argv[])
context = g_option_context_new(NULL);
g_option_context_add_main_entries(context, options, NULL);
- if (g_option_context_parse(context, &argc, &argv, &error) == FALSE) {
+ if (!g_option_context_parse(context, &argc, &argv, &error)) {
if (error != NULL) {
g_printerr("%s\n", error->message);
g_error_free(error);
@@ -129,7 +129,7 @@ int main(int argc, char *argv[])
return 1;
}
- if (option_debug == TRUE)
+ if (option_debug)
g_resolv_set_debug(resolv, resolv_debug, "RESOLV");
main_loop = g_main_loop_new(NULL, FALSE);
diff --git a/tools/session-api.c b/tools/session-api.c
index 72c0b09d..5aebfc31 100644
--- a/tools/session-api.c
+++ b/tools/session-api.c
@@ -128,7 +128,7 @@ static DBusMessage *notify_update(DBusConnection *conn,
switch (dbus_message_iter_get_arg_type(&value)) {
case DBUS_TYPE_ARRAY:
- if (g_str_equal(key, "AllowedBearers") == TRUE) {
+ if (g_str_equal(key, "AllowedBearers")) {
allowed_bearers = session_parse_allowed_bearers(&value);
g_slist_foreach(info->allowed_bearers,
@@ -137,10 +137,10 @@ static DBusMessage *notify_update(DBusConnection *conn,
info->allowed_bearers = allowed_bearers;
- } else if (g_str_equal(key, "IPv4") == TRUE) {
+ } else if (g_str_equal(key, "IPv4")) {
/* XXX */
- } else if (g_str_equal(key, "IPv6") == TRUE) {
+ } else if (g_str_equal(key, "IPv6")) {
/* XXX */
} else {
@@ -149,12 +149,12 @@ static DBusMessage *notify_update(DBusConnection *conn,
}
break;
case DBUS_TYPE_STRING:
- if (g_str_equal(key, "State") == TRUE) {
+ if (g_str_equal(key, "State")) {
const char *val;
dbus_message_iter_get_basic(&value, &val);
info->state = string2state(val);
- } else if (g_str_equal(key, "Bearer") == TRUE) {
+ } else if (g_str_equal(key, "Bearer")) {
const char *val;
dbus_message_iter_get_basic(&value, &val);
@@ -163,7 +163,7 @@ static DBusMessage *notify_update(DBusConnection *conn,
info->bearer = g_strdup(val);
- } else if (g_str_equal(key, "Name") == TRUE) {
+ } else if (g_str_equal(key, "Name")) {
const char *val;
dbus_message_iter_get_basic(&value, &val);
@@ -172,7 +172,7 @@ static DBusMessage *notify_update(DBusConnection *conn,
info->name = g_strdup(val);
- } else if (g_str_equal(key, "Interface") == TRUE) {
+ } else if (g_str_equal(key, "Interface")) {
const char *val;
dbus_message_iter_get_basic(&value, &val);
@@ -182,7 +182,7 @@ static DBusMessage *notify_update(DBusConnection *conn,
info->interface = g_strdup(val);
} else if (g_str_equal(key, "ConnectionType")
- == TRUE) {
+ ) {
const char *val;
dbus_message_iter_get_basic(&value, &val);
@@ -216,10 +216,7 @@ static const GDBusMethodTable notify_methods[] = {
int session_notify_register(struct test_session *session,
const char *notify_path)
{
- if (g_dbus_register_interface(session->connection, notify_path,
- CONNMAN_NOTIFICATION_INTERFACE,
- notify_methods, NULL, NULL,
- session, NULL) == FALSE) {
+ if (!g_dbus_register_interface(session->connection, notify_path, CONNMAN_NOTIFICATION_INTERFACE, notify_methods, NULL, NULL, session, NULL)) {
return -EINVAL;
}
@@ -229,8 +226,7 @@ int session_notify_register(struct test_session *session,
int session_notify_unregister(struct test_session *session,
const char *notify_path)
{
- if (g_dbus_unregister_interface(session->connection, notify_path,
- CONNMAN_NOTIFICATION_INTERFACE) == FALSE) {
+ if (!g_dbus_unregister_interface(session->connection, notify_path, CONNMAN_NOTIFICATION_INTERFACE)) {
return -EINVAL;
}
@@ -281,7 +277,7 @@ DBusMessage *session_connect(DBusConnection *connection,
reply = dbus_connection_send_with_reply_and_block(connection,
message, -1, &error);
if (reply == NULL) {
- if (dbus_error_is_set(&error) == TRUE) {
+ if (dbus_error_is_set(&error)) {
LOG("%s", error.message);
dbus_error_free(&error);
} else {
@@ -314,7 +310,7 @@ DBusMessage *session_disconnect(DBusConnection *connection,
reply = dbus_connection_send_with_reply_and_block(connection,
message, -1, &error);
if (reply == NULL) {
- if (dbus_error_is_set(&error) == TRUE) {
+ if (dbus_error_is_set(&error)) {
LOG("%s", error.message);
dbus_error_free(&error);
} else {
diff --git a/tools/session-test.c b/tools/session-test.c
index 04389b90..5efaa498 100644
--- a/tools/session-test.c
+++ b/tools/session-test.c
@@ -194,7 +194,7 @@ static void test_session_create_many(struct test_fix *fix)
}
static void set_session_mode(struct test_fix *fix,
- connman_bool_t enable)
+ bool enable)
{
DBusMessage *msg;
@@ -610,25 +610,25 @@ static void test_session_policy(struct test_fix *fix)
set_session_state(session, TEST_SESSION_STATE_0);
}
-static connman_bool_t is_online(struct test_fix *fix)
+static bool is_online(struct test_fix *fix)
{
if (g_strcmp0(fix->manager.state, "online") == 0)
- return TRUE;
+ return true;
- return FALSE;
+ return false;
}
static void enable_session_mode(struct test_fix *fix)
{
- set_session_mode(fix, TRUE);
+ set_session_mode(fix, true);
- if (is_online(fix) == FALSE)
+ if (!is_online(fix))
util_idle_call(fix, util_quit_loop, NULL);
}
static void manager_state_changed(struct test_fix *fix)
{
- if (is_online(fix) == FALSE) {
+ if (!is_online(fix)) {
fix->manager_changed = NULL;
util_idle_call(fix, util_quit_loop, NULL);
}
@@ -636,7 +636,7 @@ static void manager_state_changed(struct test_fix *fix)
static void disable_session_mode(struct test_fix *fix)
{
- set_session_mode(fix, FALSE);
+ set_session_mode(fix, false);
}
static void setup_cb(struct test_fix *fix)
diff --git a/tools/session-test.h b/tools/session-test.h
index be313f33..5e6d196a 100644
--- a/tools/session-test.h
+++ b/tools/session-test.h
@@ -125,7 +125,7 @@ DBusMessage *manager_create_session(DBusConnection *connection,
DBusMessage *manager_destroy_session(DBusConnection *connection,
const char *notifier_path);
DBusMessage *manager_set_session_mode(DBusConnection *connection,
- connman_bool_t enable);
+ bool enable);
int manager_parse_properties(DBusMessage *msg,
struct test_manager *manager);
diff --git a/tools/session-utils.c b/tools/session-utils.c
index 1866acb8..3bad5815 100644
--- a/tools/session-utils.c
+++ b/tools/session-utils.c
@@ -117,7 +117,7 @@ static void manager_changed(struct test_fix *fix,
dbus_message_iter_get_basic(&iter, &value);
- if (g_str_equal(key, "State") == TRUE) {
+ if (g_str_equal(key, "State")) {
LOG("State %s", value);
if (fix->manager.state != NULL)
@@ -202,7 +202,7 @@ static void run_test_cb(gconstpointer data)
g_main_loop_run(fix->main_loop);
#if ENABLE_WRAPPER
- if (g_test_trap_fork(60 * 1000 * 1000, 0) == TRUE) {
+ if (g_test_trap_fork(60 * 1000 * 1000, 0)) {
util_call(fix, cbd->func, NULL);
g_main_loop_run(fix->main_loop);
exit(0);
diff --git a/tools/stats-tool.c b/tools/stats-tool.c
index 42551151..50886755 100644
--- a/tools/stats-tool.c
+++ b/tools/stats-tool.c
@@ -100,23 +100,23 @@ struct stats_iter {
static gint option_create = 0;
static gint option_interval = 3;
-static gboolean option_dump = FALSE;
-static gboolean option_summary = FALSE;
+static bool option_dump = false;
+static bool option_summary = false;
static char *option_info_file_name = NULL;
static time_t option_start_ts = -1;
static char *option_last_file_name = NULL;
-static gboolean parse_start_ts(const char *key, const char *value,
+static bool parse_start_ts(const char *key, const char *value,
gpointer user_data, GError **error)
{
GTimeVal time_val;
- if (g_time_val_from_iso8601(value, &time_val) == FALSE)
- return FALSE;
+ if (!g_time_val_from_iso8601(value, &time_val))
+ return false;
option_start_ts = time_val.tv_sec;
- return TRUE;
+ return true;
}
static GOptionEntry options[] = {
@@ -605,7 +605,7 @@ static int stats_create(struct stats_file *file, unsigned int nr,
set_end(file, next);
if ((rand() % 50) == 0)
- roaming = roaming == TRUE? FALSE : TRUE;
+ roaming = roaming ? FALSE : TRUE;
}
@@ -674,7 +674,7 @@ static struct stats_record *process_file(struct stats_iter *iter,
append = FALSE;
- if (cur->roaming == TRUE)
+ if (cur->roaming)
roaming = cur;
else
home = cur;
@@ -703,7 +703,7 @@ static struct stats_record *process_file(struct stats_iter *iter,
append = TRUE;
}
- if (append == TRUE) {
+ if (append) {
if (home != NULL) {
append_record(temp_file, home);
home = NULL;
@@ -845,7 +845,7 @@ int main(int argc, char *argv[])
context = g_option_context_new(NULL);
g_option_context_add_main_entries(context, options, NULL);
- if (g_option_context_parse(context, &argc, &argv, &error) == FALSE) {
+ if (!g_option_context_parse(context, &argc, &argv, &error)) {
if (error != NULL) {
g_printerr("%s\n", error->message);
g_error_free(error);
@@ -896,10 +896,10 @@ int main(int argc, char *argv[])
stats_hdr_info(data_file);
- if (option_dump == TRUE)
+ if (option_dump)
stats_print_entries(data_file);
- if (option_summary == TRUE)
+ if (option_summary)
stats_print_diff(data_file);
if (option_info_file_name != NULL)
diff --git a/tools/supplicant-dbus.c b/tools/supplicant-dbus.c
index 028a2753..ee0e5ba5 100644
--- a/tools/supplicant-dbus.c
+++ b/tools/supplicant-dbus.c
@@ -114,7 +114,7 @@ static void property_get_all_reply(DBusPendingCall *call, void *user_data)
if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR)
goto done;
- if (dbus_message_iter_init(reply, &iter) == FALSE)
+ if (!dbus_message_iter_init(reply, &iter))
goto done;
supplicant_dbus_property_foreach(&iter, data->function,
@@ -158,8 +158,7 @@ int supplicant_dbus_property_get_all(const char *path, const char *interface,
dbus_message_append_args(message, DBUS_TYPE_STRING, &interface, NULL);
- if (dbus_connection_send_with_reply(connection, message,
- &call, TIMEOUT) == FALSE) {
+ if (!dbus_connection_send_with_reply(connection, message, &call, TIMEOUT)) {
dbus_message_unref(message);
dbus_free(data);
return -EIO;
@@ -201,7 +200,7 @@ static void property_set_reply(DBusPendingCall *call, void *user_data)
else
error = NULL;
- if (dbus_message_iter_init(reply, &iter) == FALSE)
+ if (!dbus_message_iter_init(reply, &iter))
goto done;
if (data->function != NULL)
@@ -255,8 +254,7 @@ int supplicant_dbus_property_set(const char *path, const char *interface,
setup(&value, user_data);
dbus_message_iter_close_container(&iter, &value);
- if (dbus_connection_send_with_reply(connection, message,
- &call, TIMEOUT) == FALSE) {
+ if (!dbus_connection_send_with_reply(connection, message, &call, TIMEOUT)) {
dbus_message_unref(message);
dbus_free(data);
return -EIO;
@@ -342,8 +340,7 @@ int supplicant_dbus_method_call(const char *path,
if (setup != NULL)
setup(&iter, user_data);
- if (dbus_connection_send_with_reply(connection, message,
- &call, TIMEOUT) == FALSE) {
+ if (!dbus_connection_send_with_reply(connection, message, &call, TIMEOUT)) {
dbus_message_unref(message);
dbus_free(data);
return -EIO;
diff --git a/tools/supplicant-test.c b/tools/supplicant-test.c
index 9b33275b..5e77f98b 100644
--- a/tools/supplicant-test.c
+++ b/tools/supplicant-test.c
@@ -157,7 +157,7 @@ int main(int argc, char *argv[])
conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, &err);
if (conn == NULL) {
- if (dbus_error_is_set(&err) == TRUE) {
+ if (dbus_error_is_set(&err)) {
fprintf(stderr, "%s\n", err.message);
dbus_error_free(&err);
} else
diff --git a/tools/supplicant.c b/tools/supplicant.c
index 1c96823a..070c972f 100644
--- a/tools/supplicant.c
+++ b/tools/supplicant.c
@@ -187,9 +187,9 @@ static enum supplicant_mode string2mode(const char *mode)
if (mode == NULL)
return SUPPLICANT_MODE_UNKNOWN;
- if (g_str_equal(mode, "infrastructure") == TRUE)
+ if (g_str_equal(mode, "infrastructure"))
return SUPPLICANT_MODE_INFRA;
- else if (g_str_equal(mode, "ad-hoc") == TRUE)
+ else if (g_str_equal(mode, "ad-hoc"))
return SUPPLICANT_MODE_IBSS;
return SUPPLICANT_MODE_UNKNOWN;
@@ -232,25 +232,25 @@ static enum supplicant_state string2state(const char *state)
if (state == NULL)
return SUPPLICANT_STATE_UNKNOWN;
- if (g_str_equal(state, "unknown") == TRUE)
+ if (g_str_equal(state, "unknown"))
return SUPPLICANT_STATE_UNKNOWN;
- else if (g_str_equal(state, "disconnected") == TRUE)
+ else if (g_str_equal(state, "disconnected"))
return SUPPLICANT_STATE_DISCONNECTED;
- else if (g_str_equal(state, "inactive") == TRUE)
+ else if (g_str_equal(state, "inactive"))
return SUPPLICANT_STATE_INACTIVE;
- else if (g_str_equal(state, "scanning") == TRUE)
+ else if (g_str_equal(state, "scanning"))
return SUPPLICANT_STATE_SCANNING;
- else if (g_str_equal(state, "authenticating") == TRUE)
+ else if (g_str_equal(state, "authenticating"))
return SUPPLICANT_STATE_AUTHENTICATING;
- else if (g_str_equal(state, "associating") == TRUE)
+ else if (g_str_equal(state, "associating"))
return SUPPLICANT_STATE_ASSOCIATING;
- else if (g_str_equal(state, "associated") == TRUE)
+ else if (g_str_equal(state, "associated"))
return SUPPLICANT_STATE_ASSOCIATED;
- else if (g_str_equal(state, "group_handshake") == TRUE)
+ else if (g_str_equal(state, "group_handshake"))
return SUPPLICANT_STATE_GROUP_HANDSHAKE;
- else if (g_str_equal(state, "4way_handshake") == TRUE)
+ else if (g_str_equal(state, "4way_handshake"))
return SUPPLICANT_STATE_4WAY_HANDSHAKE;
- else if (g_str_equal(state, "completed") == TRUE)
+ else if (g_str_equal(state, "completed"))
return SUPPLICANT_STATE_COMPLETED;
return SUPPLICANT_STATE_UNKNOWN;
@@ -258,7 +258,7 @@ static enum supplicant_state string2state(const char *state)
static void callback_system_ready(void)
{
- if (system_ready == TRUE)
+ if (system_ready)
return;
system_ready = TRUE;
@@ -918,11 +918,11 @@ static void bss_property(const char *key, DBusMessageIter *iter,
return;
if (key == NULL) {
- if (bss->ieee8021x == TRUE)
+ if (bss->ieee8021x)
bss->security = SUPPLICANT_SECURITY_IEEE8021X;
- else if (bss->psk == TRUE)
+ else if (bss->psk)
bss->security = SUPPLICANT_SECURITY_PSK;
- else if (bss->privacy == TRUE)
+ else if (bss->privacy)
bss->security = SUPPLICANT_SECURITY_WEP;
else
bss->security = SUPPLICANT_SECURITY_NONE;
@@ -1140,8 +1140,8 @@ static void interface_property(const char *key, DBusMessageIter *iter,
dbus_message_iter_get_basic(iter, &scanning);
interface->scanning = scanning;
- if (interface->ready == TRUE) {
- if (interface->scanning == TRUE)
+ if (interface->ready) {
+ if (interface->scanning)
callback_scan_started(interface);
else
callback_scan_finished(interface);
@@ -1390,7 +1390,7 @@ static void signal_scan_done(const char *path, DBusMessageIter *iter)
if (interface->scan_callback != NULL) {
int result = 0;
- if (success == FALSE)
+ if (!success)
result = -EIO;
interface->scan_callback(result, interface->scan_data);
@@ -1500,16 +1500,14 @@ static DBusHandlerResult supplicant_filter(DBusConnection *conn,
if (path == NULL)
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- if (dbus_message_iter_init(message, &iter) == FALSE)
+ if (!dbus_message_iter_init(message, &iter))
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
for (i = 0; signal_map[i].interface != NULL; i++) {
- if (dbus_message_has_interface(message,
- signal_map[i].interface) == FALSE)
+ if (!dbus_message_has_interface(message, signal_map[i].interface))
continue;
- if (dbus_message_has_member(message,
- signal_map[i].member) == FALSE)
+ if (!dbus_message_has_member(message, signal_map[i].member))
continue;
signal_map[i].function(path, &iter);
@@ -1544,8 +1542,7 @@ int supplicant_register(const struct supplicant_callbacks *callbacks)
if (connection == NULL)
return -EIO;
- if (dbus_connection_add_filter(connection,
- supplicant_filter, NULL, NULL) == FALSE) {
+ if (!dbus_connection_add_filter(connection, supplicant_filter, NULL, NULL)) {
dbus_connection_unref(connection);
connection = NULL;
return -EIO;
@@ -1572,7 +1569,7 @@ int supplicant_register(const struct supplicant_callbacks *callbacks)
dbus_connection_flush(connection);
if (dbus_bus_name_has_owner(connection,
- SUPPLICANT_SERVICE, NULL) == TRUE) {
+ SUPPLICANT_SERVICE, NULL)) {
system_available = TRUE;
supplicant_bootstrap();
}
@@ -1606,7 +1603,7 @@ void supplicant_unregister(const struct supplicant_callbacks *callbacks)
interface_table = NULL;
}
- if (system_available == TRUE)
+ if (system_available)
callback_system_killed();
if (connection != NULL) {
@@ -1640,7 +1637,7 @@ static void debug_level_params(DBusMessageIter *iter, void *user_data)
void supplicant_set_debug_level(unsigned int level)
{
- if (system_available == FALSE)
+ if (!system_available)
return;
supplicant_dbus_property_set(SUPPLICANT_PATH, SUPPLICANT_INTERFACE,
@@ -1691,7 +1688,7 @@ static void interface_create_result(const char *error,
goto done;
}
- if (system_available == FALSE) {
+ if (!system_available) {
err = -EFAULT;
goto done;
}
@@ -1766,7 +1763,7 @@ static void interface_get_result(const char *error,
return;
create:
- if (system_available == FALSE) {
+ if (!system_available) {
err = -EFAULT;
goto done;
}
@@ -1802,7 +1799,7 @@ int supplicant_interface_create(const char *ifname, const char *driver,
if (ifname == NULL)
return -EINVAL;
- if (system_available == FALSE)
+ if (!system_available)
return -EFAULT;
data = dbus_malloc0(sizeof(*data));
@@ -1828,7 +1825,7 @@ int supplicant_interface_remove(struct supplicant_interface *interface,
if (interface == NULL)
return -EINVAL;
- if (system_available == FALSE)
+ if (!system_available)
return -EFAULT;
return 0;
@@ -1878,10 +1875,10 @@ int supplicant_interface_scan(struct supplicant_interface *interface,
if (interface == NULL)
return -EINVAL;
- if (system_available == FALSE)
+ if (!system_available)
return -EFAULT;
- if (interface->scanning == TRUE)
+ if (interface->scanning)
return -EALREADY;
data = dbus_malloc0(sizeof(*data));
@@ -1926,7 +1923,7 @@ int supplicant_interface_disconnect(struct supplicant_interface *interface,
if (interface == NULL)
return -EINVAL;
- if (system_available == FALSE)
+ if (!system_available)
return -EFAULT;
data = dbus_malloc0(sizeof(*data));
diff --git a/tools/web-test.c b/tools/web-test.c
index a5073974..bf0fb0cd 100644
--- a/tools/web-test.c
+++ b/tools/web-test.c
@@ -43,7 +43,7 @@ static void sig_term(int sig)
g_main_loop_quit(main_loop);
}
-static gboolean web_result(GWebResult *result, gpointer user_data)
+static bool web_result(GWebResult *result, gpointer user_data)
{
const guint8 *chunk;
gsize length;
@@ -54,7 +54,7 @@ static gboolean web_result(GWebResult *result, gpointer user_data)
if (length > 0) {
printf("%s\n", (char *) chunk);
- return TRUE;
+ return true;
}
status = g_web_result_get_status(result);
@@ -67,10 +67,10 @@ static gboolean web_result(GWebResult *result, gpointer user_data)
g_main_loop_quit(main_loop);
- return FALSE;
+ return false;
}
-static gboolean option_debug = FALSE;
+static bool option_debug = false;
static gchar *option_proxy = NULL;
static gchar *option_nameserver = NULL;
static gchar *option_user_agent = NULL;
@@ -101,7 +101,7 @@ int main(int argc, char *argv[])
context = g_option_context_new(NULL);
g_option_context_add_main_entries(context, options, NULL);
- if (g_option_context_parse(context, &argc, &argv, &error) == FALSE) {
+ if (!g_option_context_parse(context, &argc, &argv, &error)) {
if (error != NULL) {
g_printerr("%s\n", error->message);
g_error_free(error);
@@ -123,7 +123,7 @@ int main(int argc, char *argv[])
return 1;
}
- if (option_debug == TRUE)
+ if (option_debug)
g_web_set_debug(web, web_debug, "WEB");
main_loop = g_main_loop_new(NULL, FALSE);
diff --git a/tools/wispr.c b/tools/wispr.c
index 122bea50..c1966ef1 100644
--- a/tools/wispr.c
+++ b/tools/wispr.c
@@ -100,7 +100,7 @@ static const char *response_code_to_string(int response_code)
}
struct wispr_msg {
- gboolean has_error;
+ bool has_error;
const char *current_element;
int message_type;
int response_code;
@@ -114,7 +114,7 @@ struct wispr_msg {
static inline void wispr_msg_init(struct wispr_msg *msg)
{
- msg->has_error = FALSE;
+ msg->has_error = false;
msg->current_element = NULL;
msg->message_type = -1;
@@ -216,8 +216,7 @@ static void text_handler(GMarkupParseContext *context,
return;
for (i = 0; wispr_element_map[i].str; i++) {
- if (g_str_equal(wispr_element_map[i].str,
- msg->current_element) == FALSE)
+ if (!g_str_equal(wispr_element_map[i].str, msg->current_element))
continue;
switch (wispr_element_map[i].element) {
@@ -266,7 +265,7 @@ static void error_handler(GMarkupParseContext *context,
{
struct wispr_msg *msg = user_data;
- msg->has_error = TRUE;
+ msg->has_error = true;
}
static const GMarkupParser wispr_parser = {
@@ -281,7 +280,7 @@ static void parser_callback(const char *str, gpointer user_data)
{
struct wispr_session *wispr = user_data;
GMarkupParseContext *context;
- gboolean result;
+ bool result;
//printf("%s\n", str);
@@ -289,7 +288,7 @@ static void parser_callback(const char *str, gpointer user_data)
G_MARKUP_TREAT_CDATA_AS_TEXT, &wispr->msg, NULL);
result = g_markup_parse_context_parse(context, str, strlen(str), NULL);
- if (result == TRUE)
+ if (result)
g_markup_parse_context_end_parse(context, NULL);
g_markup_parse_context_free(context);
@@ -301,7 +300,7 @@ struct user_input_data {
GString *str;
user_input_cb cb;
gpointer user_data;
- gboolean hidden;
+ bool hidden;
int fd;
struct termios saved_termios;
};
@@ -310,7 +309,7 @@ static void user_callback(struct user_input_data *data)
{
char *value;
- if (data->hidden == TRUE) {
+ if (data->hidden) {
ssize_t len;
len = write(data->fd, "\n", 1);
@@ -351,13 +350,13 @@ static gboolean keyboard_input(GIOChannel *channel, GIOCondition condition,
g_string_append_c(data->str, buf[0]);
- if (data->hidden == TRUE)
+ if (data->hidden)
len = write(data->fd, "*", 1);
return TRUE;
}
-static gboolean user_input(const char *label, gboolean hidden,
+static bool user_input(const char *label, bool hidden,
user_input_cb func, gpointer user_data)
{
struct user_input_data *data;
@@ -368,7 +367,7 @@ static gboolean user_input(const char *label, gboolean hidden,
data = g_try_new0(struct user_input_data, 1);
if (data == NULL)
- return FALSE;
+ return false;
data->str = g_string_sized_new(32);
data->cb = func;
@@ -385,7 +384,7 @@ static gboolean user_input(const char *label, gboolean hidden,
}
new_termios = data->saved_termios;
- if (data->hidden == TRUE)
+ if (data->hidden)
new_termios.c_lflag &= ~(ICANON|ECHO);
else
new_termios.c_lflag &= ~ICANON;
@@ -411,13 +410,13 @@ static gboolean user_input(const char *label, gboolean hidden,
if (len < 0)
goto error;
- return TRUE;
+ return true;
error:
g_string_free(data->str, TRUE);
g_free(data);
- return FALSE;
+ return false;
}
static void password_callback(const char *value, gpointer user_data)
@@ -440,7 +439,7 @@ static void username_callback(const char *value, gpointer user_data)
wispr->username = g_strdup(value);
if (wispr->password == NULL) {
- user_input("Password", TRUE, password_callback, wispr);
+ user_input("Password", true, password_callback, wispr);
return;
}
@@ -449,7 +448,7 @@ static void username_callback(const char *value, gpointer user_data)
execute_login(wispr);
}
-static gboolean wispr_input(const guint8 **data, gsize *length,
+static bool wispr_input(const guint8 **data, gsize *length,
gpointer user_data)
{
struct wispr_session *wispr = user_data;
@@ -473,10 +472,10 @@ static gboolean wispr_input(const guint8 **data, gsize *length,
*data = (guint8 *) wispr->formdata;
*length = count;
- return FALSE;
+ return false;
}
-static gboolean wispr_route(const char *addr, int ai_family, int if_index,
+static bool wispr_route(const char *addr, int ai_family, int if_index,
gpointer user_data)
{
char *family = "unknown";
@@ -489,12 +488,12 @@ static gboolean wispr_route(const char *addr, int ai_family, int if_index,
printf("Route request: %s %s index %d\n", family, addr, if_index);
if (ai_family != AF_INET && ai_family != AF_INET6)
- return FALSE;
+ return false;
- return TRUE;
+ return true;
}
-static gboolean wispr_result(GWebResult *result, gpointer user_data)
+static bool wispr_result(GWebResult *result, gpointer user_data)
{
struct wispr_session *wispr = user_data;
const guint8 *chunk;
@@ -507,7 +506,7 @@ static gboolean wispr_result(GWebResult *result, gpointer user_data)
if (length > 0) {
//printf("%s\n", (char *) chunk);
g_web_parser_feed_data(wispr->parser, chunk, length);
- return TRUE;
+ return true;
}
g_web_parser_end_data(wispr->parser);
@@ -526,8 +525,7 @@ static gboolean wispr_result(GWebResult *result, gpointer user_data)
if (status != 302)
goto done;
- if (g_web_result_get_header(result, "Location",
- &redirect) == FALSE)
+ if (!g_web_result_get_header(result, "Location", &redirect))
goto done;
printf("Redirect URL: %s\n", redirect);
@@ -536,7 +534,7 @@ static gboolean wispr_result(GWebResult *result, gpointer user_data)
wispr->request = g_web_request_get(wispr->web, redirect,
wispr_result, wispr_route, wispr);
- return FALSE;
+ return false;
}
printf("Message type: %s (%d)\n",
@@ -564,17 +562,18 @@ static gboolean wispr_result(GWebResult *result, gpointer user_data)
if (wispr->msg.message_type == 100) {
if (wispr->username == NULL) {
- user_input("Username", FALSE, username_callback, wispr);
- return FALSE;
+ user_input("Username", false,
+ username_callback, wispr);
+ return false;
}
if (wispr->password == NULL) {
- user_input("Password", TRUE, password_callback, wispr);
- return FALSE;
+ user_input("Password", true, password_callback, wispr);
+ return false;
}
g_idle_add(execute_login, wispr);
- return FALSE;
+ return false;
} else if (wispr->msg.message_type == 120 ||
wispr->msg.message_type == 140) {
int code = wispr->msg.response_code;
@@ -585,8 +584,7 @@ static gboolean wispr_result(GWebResult *result, gpointer user_data)
if (status == 302) {
const char *redirect;
- if (g_web_result_get_header(result, "Location",
- &redirect) == FALSE)
+ if (!g_web_result_get_header(result, "Location", &redirect))
goto done;
printf("\n");
@@ -596,13 +594,13 @@ static gboolean wispr_result(GWebResult *result, gpointer user_data)
wispr->request = g_web_request_get(wispr->web, redirect,
wispr_result, NULL, wispr);
- return FALSE;
+ return false;
}
done:
g_main_loop_quit(main_loop);
- return FALSE;
+ return false;
}
static gboolean execute_login(gpointer user_data)
@@ -618,7 +616,7 @@ static gboolean execute_login(gpointer user_data)
return FALSE;
}
-static gboolean option_debug = FALSE;
+static bool option_debug = false;
static gchar *option_nameserver = NULL;
static gchar *option_username = NULL;
static gchar *option_password = NULL;
@@ -649,7 +647,7 @@ int main(int argc, char *argv[])
context = g_option_context_new(NULL);
g_option_context_add_main_entries(context, options, NULL);
- if (g_option_context_parse(context, &argc, &argv, &error) == FALSE) {
+ if (!g_option_context_parse(context, &argc, &argv, &error)) {
if (error != NULL) {
g_printerr("%s\n", error->message);
g_error_free(error);
@@ -669,7 +667,7 @@ int main(int argc, char *argv[])
return 1;
}
- if (option_debug == TRUE)
+ if (option_debug)
g_web_set_debug(wispr.web, web_debug, "WEB");
main_loop = g_main_loop_new(NULL, FALSE);
diff --git a/tools/wpad-test.c b/tools/wpad-test.c
index a6cc7926..a95382af 100644
--- a/tools/wpad-test.c
+++ b/tools/wpad-test.c
@@ -126,7 +126,7 @@ quit:
g_main_loop_quit(main_loop);
}
-static gboolean option_debug = FALSE;
+static bool option_debug = false;
static gchar *option_search = NULL;
static GOptionEntry options[] = {
@@ -147,7 +147,7 @@ int main(int argc, char *argv[])
context = g_option_context_new(NULL);
g_option_context_add_main_entries(context, options, NULL);
- if (g_option_context_parse(context, &argc, &argv, &error) == FALSE) {
+ if (!g_option_context_parse(context, &argc, &argv, &error)) {
if (error != NULL) {
g_printerr("%s\n", error->message);
g_error_free(error);
@@ -164,7 +164,7 @@ int main(int argc, char *argv[])
return 1;
}
- if (option_debug == TRUE)
+ if (option_debug)
g_resolv_set_debug(resolv, resolv_debug, "RESOLV");
main_loop = g_main_loop_new(NULL, FALSE);