include: Use stdbool instead gboolean or near_bool_t
authorDaniel Wagner <daniel.wagner@bmw-carit.de>
Wed, 14 Aug 2013 07:27:50 +0000 (09:27 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 20 Aug 2013 09:05:30 +0000 (11:05 +0200)
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
)

include/ndef.h
include/setting.h
include/snep.h
include/tag.h

index b554a79..5abdf34 100644 (file)
@@ -61,9 +61,9 @@ near_ndef_prepare_smartposter_record(uint8_t uri_identifier,
                                        uint32_t uri_field_length,
                                        uint8_t *uri_field);
 
-near_bool_t near_ndef_record_cmp_id(struct near_ndef_record *rec1,
+bool near_ndef_record_cmp_id(struct near_ndef_record *rec1,
                                                struct near_ndef_record *rec2);
-near_bool_t near_ndef_record_cmp_mime(struct near_ndef_record *rec1,
+bool near_ndef_record_cmp_mime(struct near_ndef_record *rec1,
                                                struct near_ndef_record *rec2);
 
 
index d287432..31a0426 100644 (file)
@@ -28,7 +28,7 @@
 extern "C" {
 #endif
 
-near_bool_t near_setting_get_bool(const char *key);
+bool near_setting_get_bool(const char *key);
 
 #ifdef __cplusplus
 }
index 4ce6b9c..c908387 100644 (file)
@@ -64,7 +64,7 @@
  * from lower layers */
 #define NEAR_SNEP_REQ_MAX_FRAGMENT_LENGTH 128
 
-typedef near_bool_t (*near_server_io) (int client_fd, void *snep_data);
+typedef bool (*near_server_io) (int client_fd, void *snep_data);
 
 struct p2p_snep_data {
        uint8_t *nfc_data;
@@ -73,13 +73,13 @@ struct p2p_snep_data {
        uint8_t *nfc_data_ptr;
        uint32_t adapter_idx;
        uint32_t target_idx;
-       gboolean respond_continue;
+       bool respond_continue;
        uint8_t request;
        near_tag_io_cb cb;
        struct p2p_snep_put_req_data *req;
 };
 
-near_bool_t near_snep_core_read(int client_fd,
+bool near_snep_core_read(int client_fd,
                                uint32_t adapter_idx, uint32_t target_idx,
                                near_tag_io_cb cb,
                                near_server_io req_get,
index 412bc70..9c1330e 100644 (file)
@@ -78,9 +78,9 @@ struct near_tag_driver {
 struct near_tag;
 
 struct near_tag *near_tag_get_tag(uint32_t adapter_idx, uint32_t target_idx);
-void near_tag_set_ro(struct near_tag *tag, near_bool_t readonly);
-void near_tag_set_blank(struct near_tag *tag, near_bool_t blank);
-near_bool_t near_tag_get_blank(struct near_tag *tag);
+void near_tag_set_ro(struct near_tag *tag, bool readonly);
+void near_tag_set_blank(struct near_tag *tag, bool blank);
+bool near_tag_get_blank(struct near_tag *tag);
 int near_tag_add_data(uint32_t adapter_idx, uint32_t target_idx,
                        uint8_t *data, size_t data_length);
 int near_tag_add_records(struct near_tag *tag, GList *records,