diff options
author | Daniel Wagner <daniel.wagner@bmw-carit.de> | 2013-08-14 09:27:53 +0200 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2013-08-20 11:05:30 +0200 |
commit | 826ac6bb2b7af69d06a339bb5564cdb54a67e697 (patch) | |
tree | 7baaf006e8e40d5fadcdc1239a2c243296b10ab4 /tools | |
parent | 49885b7d8574c9a55016114387bcb54db1b1b13a (diff) | |
download | neard-826ac6bb2b7af69d06a339bb5564cdb54a67e697.tar.gz neard-826ac6bb2b7af69d06a339bb5564cdb54a67e697.tar.bz2 neard-826ac6bb2b7af69d06a339bb5564cdb54a67e697.zip |
tools: Use stdbool instead gboolean or near_bool_t
This patch has been created via coccinelle:
// Rule set 1
f(es,
(
- FALSE
+ false
|
- TRUE
+ true
)
,...)
@r2@
type T;
identifier f;
parameter list[n] ps;
identifier i;
@@
T f(ps, near_bool_t i, ...);
@@
identifier r2.f;
expression list [r.n] es;
@@
f(es,
(
- FALSE
+ false
|
- TRUE
+ true
)
,...)
@@
typedef bool;
@@
- near_bool_t
+ bool
// Rule set 2
// This is not a beautiful script but it does the job.
// Improvemtents are welcome.
// Fix all assigments but do not convert yet the type
@@
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;
...>
}
// Rule set 3
@@
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
)
Diffstat (limited to 'tools')
-rw-r--r-- | tools/nfctool/main.c | 60 | ||||
-rw-r--r-- | tools/nfctool/ndef-decode.c | 2 | ||||
-rw-r--r-- | tools/nfctool/netlink.c | 4 | ||||
-rw-r--r-- | tools/nfctool/netlink.h | 2 | ||||
-rw-r--r-- | tools/nfctool/nfctool.h | 20 | ||||
-rw-r--r-- | tools/nfctool/sniffer.c | 2 | ||||
-rw-r--r-- | tools/nfctool/sniffer.h | 2 |
7 files changed, 46 insertions, 46 deletions
diff --git a/tools/nfctool/main.c b/tools/nfctool/main.c index ba9a83d..c6a05af 100644 --- a/tools/nfctool/main.c +++ b/tools/nfctool/main.c @@ -46,7 +46,7 @@ static GMainLoop *main_loop = NULL; static int nfctool_poll_cb(guint8 cmd, guint32 idx, gpointer data); static int nfctool_snl_cb(guint8 cmd, guint32 idx, gpointer data); -static void nfctool_quit(gboolean force); +static void nfctool_quit(bool force); static gchar *nfctool_poll_mode_str(int mode) { @@ -135,7 +135,7 @@ static int nfctool_snl_send_request(struct nfc_adapter *adapter) return err; } -static int nfctool_set_powered(gboolean powered) +static int nfctool_set_powered(bool powered) { struct nfc_adapter *adapter; int err; @@ -177,9 +177,9 @@ static int nfctool_dep_link_down_cb(guint8 cmd, guint32 idx, gpointer data) printf("Link is DOWN for adapter nfc%d\n\n", idx); - opts.snl = FALSE; + opts.snl = false; - nfctool_quit(FALSE); + nfctool_quit(false); return 0; } @@ -206,7 +206,7 @@ static int nfctool_snl(void) if (adapter->rf_mode == NFC_RF_NONE) { print_error("Can't send SNL request: No active link"); - opts.snl = FALSE; + opts.snl = false; return -ENOLINK; } @@ -271,7 +271,7 @@ static int nfctool_poll_cb(guint8 cmd, guint32 idx, gpointer data) break; } - nfctool_quit(FALSE); + nfctool_quit(false); return err; } @@ -307,8 +307,8 @@ static int nfctool_snl_cb(guint8 cmd, guint32 idx, gpointer data) printf("\n"); if (opts.snl_list == NULL) { - opts.snl = FALSE; - nfctool_quit(FALSE); + opts.snl = false; + nfctool_quit(false); } return 0; @@ -346,7 +346,7 @@ static void sig_term(int sig) DBG("Terminating"); - nfctool_quit(TRUE); + nfctool_quit(true); } struct nfctool_options opts = { @@ -373,10 +373,10 @@ struct nfctool_options opts = { .pcap_filename = NULL, }; -static gboolean opt_parse_poll_arg(const gchar *option_name, const gchar *value, +static bool opt_parse_poll_arg(const gchar *option_name, const gchar *value, gpointer data, GError **error) { - opts.poll = TRUE; + opts.poll = true; opts.poll_mode = POLLING_MODE_INITIATOR; @@ -387,17 +387,17 @@ static gboolean opt_parse_poll_arg(const gchar *option_name, const gchar *value, opts.poll_mode = POLLING_MODE_BOTH; } - return TRUE; + return true; } -static gboolean opt_parse_set_param_arg(const gchar *option_name, +static bool opt_parse_set_param_arg(const gchar *option_name, const gchar *value, gpointer data, GError **error) { gchar **params = NULL, **keyval = NULL; gchar *end; gint i, intval; - gboolean result; + bool result; params = g_strsplit(value, ",", -1); @@ -406,13 +406,13 @@ static gboolean opt_parse_set_param_arg(const gchar *option_name, keyval = g_strsplit(params[i], "=", 2); if (keyval[0] == NULL || keyval[1] == NULL) { - result = FALSE; + result = false; goto exit; } intval = strtol(keyval[1], &end, 10); if (keyval[1] == end) { - result = FALSE; + result = false; goto exit; } @@ -420,7 +420,7 @@ static gboolean opt_parse_set_param_arg(const gchar *option_name, if (intval < 0 || intval > LLCP_MAX_LTO) { print_error("Bad value: max lto value is %d", LLCP_MAX_LTO); - result = FALSE; + result = false; goto exit; } @@ -429,7 +429,7 @@ static gboolean opt_parse_set_param_arg(const gchar *option_name, if (intval < 0 || intval > LLCP_MAX_RW) { print_error("Bad value: max rw value is %d", LLCP_MAX_RW); - result = FALSE; + result = false; goto exit; } @@ -438,17 +438,17 @@ static gboolean opt_parse_set_param_arg(const gchar *option_name, if (intval < 0 || intval > LLCP_MAX_MIUX) { print_error("Bad value: max miux value is %d", LLCP_MAX_MIUX); - result = FALSE; + result = false; goto exit; } opts.miux = intval; } else { - result = FALSE; + result = false; goto exit; } - opts.set_param = TRUE; + opts.set_param = true; g_strfreev(keyval); keyval = NULL; @@ -456,7 +456,7 @@ static gboolean opt_parse_set_param_arg(const gchar *option_name, i++; } - result = TRUE; + result = true; exit: if (params) @@ -468,7 +468,7 @@ exit: return result; } -static gboolean opt_parse_show_timestamp_arg(const gchar *option_name, +static bool opt_parse_show_timestamp_arg(const gchar *option_name, const gchar *value, gpointer data, GError **error) { @@ -477,21 +477,21 @@ static gboolean opt_parse_show_timestamp_arg(const gchar *option_name, else opts.show_timestamp = SNIFFER_SHOW_TIMESTAMP_DELTA; - return TRUE; + return true; } -static gboolean opt_parse_snl_arg(const gchar *option_name, const gchar *value, +static bool opt_parse_snl_arg(const gchar *option_name, const gchar *value, gpointer data, GError **error) { gchar *uri; - opts.snl = TRUE; + opts.snl = true; uri = g_strdup(value); opts.snl_list = g_slist_prepend(opts.snl_list, uri); - return TRUE; + return true; } static GOptionEntry option_entries[] = { @@ -575,10 +575,10 @@ static int nfctool_options_parse(int argc, char **argv) } if (opts.enable_dev || opts.disable_dev) - opts.list = TRUE; + opts.list = true; if (opts.poll) - opts.enable_dev = TRUE; + opts.enable_dev = true; opts.need_netlink = opts.list || opts.poll || opts.set_param || opts.snl; @@ -637,7 +637,7 @@ static void nfctool_main_loop_clean(void) g_main_loop_unref(main_loop); } -static void nfctool_quit(gboolean force) +static void nfctool_quit(bool force) { if (force || (!opts.sniff && !opts.snl)) g_main_loop_quit(main_loop); diff --git a/tools/nfctool/ndef-decode.c b/tools/nfctool/ndef-decode.c index bc891ae..e4146e7 100644 --- a/tools/nfctool/ndef-decode.c +++ b/tools/nfctool/ndef-decode.c @@ -211,7 +211,7 @@ static void ndef_print_wsc_oob(guint8 *oob_data, guint32 oob_length) int ndef_print_records(guint8 *data, guint32 data_len) { - gboolean mb, me, cf, sr, il; + bool mb, me, cf, sr, il; enum record_tnf tnf; char *mime_string; guint8 type_len; diff --git a/tools/nfctool/netlink.c b/tools/nfctool/netlink.c index 18c48a6..7c2560f 100644 --- a/tools/nfctool/netlink.c +++ b/tools/nfctool/netlink.c @@ -556,7 +556,7 @@ nla_put_failure: return err; } -int nl_set_powered(struct nfc_adapter *adapter, gboolean powered) +int nl_set_powered(struct nfc_adapter *adapter, bool powered) { struct nl_msg *msg; void *hdr; @@ -569,7 +569,7 @@ int nl_set_powered(struct nfc_adapter *adapter, gboolean powered) if (msg == NULL) return -ENOMEM; - if (powered == TRUE) + if (powered) cmd = NFC_CMD_DEV_UP; else cmd = NFC_CMD_DEV_DOWN; diff --git a/tools/nfctool/netlink.h b/tools/nfctool/netlink.h index 651a8aa..ce51910 100644 --- a/tools/nfctool/netlink.h +++ b/tools/nfctool/netlink.h @@ -46,6 +46,6 @@ int nl_get_params(struct nfc_adapter *adapter); int nl_send_sdreq(struct nfc_adapter *adapter, GSList *uris); -int nl_set_powered(struct nfc_adapter *adapter, gboolean powered); +int nl_set_powered(struct nfc_adapter *adapter, bool powered); #endif /* __NETLINK_H */ diff --git a/tools/nfctool/nfctool.h b/tools/nfctool/nfctool.h index 447a744..7c93210 100644 --- a/tools/nfctool/nfctool.h +++ b/tools/nfctool/nfctool.h @@ -59,24 +59,24 @@ #define SNIFFER_SHOW_TIMESTAMP_ABS 2 struct nfctool_options { - gboolean show_version; - gboolean list; - gboolean poll; + bool show_version; + bool list; + bool poll; guint8 poll_mode; gchar *device_name; guint32 adapter_idx; - gboolean enable_dev; - gboolean disable_dev; - gboolean set_param; + bool enable_dev; + bool disable_dev; + bool set_param; gint32 lto; gint32 rw; gint32 miux; - gboolean need_netlink; - gboolean snl; + bool need_netlink; + bool snl; GSList *snl_list; - gboolean sniff; + bool sniff; gsize snap_len; - gboolean dump_symm; + bool dump_symm; guint8 show_timestamp; guint8 snep_sap; guint8 handover_sap; diff --git a/tools/nfctool/sniffer.c b/tools/nfctool/sniffer.c index 7102e1a..aba06ec 100644 --- a/tools/nfctool/sniffer.c +++ b/tools/nfctool/sniffer.c @@ -158,7 +158,7 @@ static void pcap_file_cleanup(void) * */ void sniffer_print_hexdump(FILE *file, guint8 *data, guint32 len, - guint8 indent, gboolean print_len) + guint8 indent, bool print_len) { guint8 digits; guint32 offset; diff --git a/tools/nfctool/sniffer.h b/tools/nfctool/sniffer.h index 9fdafe8..887c305 100644 --- a/tools/nfctool/sniffer.h +++ b/tools/nfctool/sniffer.h @@ -60,6 +60,6 @@ int sniffer_init(void); void sniffer_cleanup(void); void sniffer_print_hexdump(FILE *file, guint8 *data, guint32 len, - guint8 indent, gboolean print_len); + guint8 indent, bool print_len); #endif /* __SNIFFER_H */ |