diff options
author | Thomas Haller <thaller@redhat.com> | 2018-07-11 07:40:19 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-07-11 12:02:06 +0200 |
commit | e1c7a2b5d0b142a3d4347ec6f1934f53c4b402a9 (patch) | |
tree | f61f41729ed8844d566eb68c69d9550a07564215 /libnm-glib | |
parent | 7e98b4cad2ff9934d8b5855b291c2baaa7543801 (diff) |
all: don't use gchar/gshort/gint/glong but C types
We commonly don't use the glib typedefs for char/short/int/long,
but their C types directly.
$ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
587
$ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
21114
One could argue that using the glib typedefs is preferable in
public API (of our glib based libnm library) or where it clearly
is related to glib, like during
g_object_set (obj, PROPERTY, (gint) value, NULL);
However, that argument does not seem strong, because in practice we don't
follow that argument today, and seldomly use the glib typedefs.
Also, the style guide for this would be hard to formalize, because
"using them where clearly related to a glib" is a very loose suggestion.
Also note that glib typedefs will always just be typedefs of the
underlying C types. There is no danger of glib changing the meaning
of these typedefs (because that would be a major API break of glib).
A simple style guide is instead: don't use these typedefs.
No manual actions, I only ran the bash script:
FILES=($(git ls-files '*.[hc]'))
sed -i \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\> /\1 /g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
"${FILES[@]}"
Diffstat (limited to 'libnm-glib')
-rw-r--r-- | libnm-glib/libnm-glib-test.c | 2 | ||||
-rw-r--r-- | libnm-glib/nm-access-point.c | 4 | ||||
-rw-r--r-- | libnm-glib/nm-access-point.h | 2 | ||||
-rw-r--r-- | libnm-glib/nm-device-wimax.c | 12 | ||||
-rw-r--r-- | libnm-glib/nm-device-wimax.h | 6 | ||||
-rw-r--r-- | libnm-glib/nm-object.c | 2 | ||||
-rw-r--r-- | libnm-glib/nm-vpn-plugin-utils.c | 2 |
7 files changed, 15 insertions, 15 deletions
diff --git a/libnm-glib/libnm-glib-test.c b/libnm-glib/libnm-glib-test.c index c4723c954..3b1866c58 100644 --- a/libnm-glib/libnm-glib-test.c +++ b/libnm-glib/libnm-glib-test.c @@ -68,7 +68,7 @@ test_get_state (NMClient *client) return TRUE; } -static gchar * +static char * ip4_address_as_string (guint32 ip) { char buf[INET_ADDRSTRLEN+1]; diff --git a/libnm-glib/nm-access-point.c b/libnm-glib/nm-access-point.c index 592818fad..a0cacfde4 100644 --- a/libnm-glib/nm-access-point.c +++ b/libnm-glib/nm-access-point.c @@ -51,7 +51,7 @@ typedef struct { NM80211Mode mode; guint32 max_bitrate; guint8 strength; - gint last_seen; + int last_seen; } NMAccessPointPrivate; enum { @@ -277,7 +277,7 @@ nm_access_point_get_strength (NMAccessPoint *ap) * * Since: 1.2 **/ -gint +int nm_access_point_get_last_seen (NMAccessPoint *ap) { g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), -1); diff --git a/libnm-glib/nm-access-point.h b/libnm-glib/nm-access-point.h index e9a3fc6b5..d25de5417 100644 --- a/libnm-glib/nm-access-point.h +++ b/libnm-glib/nm-access-point.h @@ -81,7 +81,7 @@ NM80211Mode nm_access_point_get_mode (NMAccessPoint *ap); guint32 nm_access_point_get_max_bitrate (NMAccessPoint *ap); guint8 nm_access_point_get_strength (NMAccessPoint *ap); NM_AVAILABLE_IN_1_2 -gint nm_access_point_get_last_seen (NMAccessPoint *ap); +int nm_access_point_get_last_seen (NMAccessPoint *ap); GSList * nm_access_point_filter_connections (NMAccessPoint *ap, const GSList *connections); diff --git a/libnm-glib/nm-device-wimax.c b/libnm-glib/nm-device-wimax.c index cda360167..3465475a4 100644 --- a/libnm-glib/nm-device-wimax.c +++ b/libnm-glib/nm-device-wimax.c @@ -48,9 +48,9 @@ typedef struct { GPtrArray *nsps; guint center_freq; - gint rssi; - gint cinr; - gint tx_power; + int rssi; + int cinr; + int tx_power; char *bsid; } NMDeviceWimaxPrivate; @@ -299,7 +299,7 @@ nm_device_wimax_get_center_frequency (NMDeviceWimax *self) * * Deprecated: 1.2: WiMAX is no longer supported. **/ -gint +int nm_device_wimax_get_rssi (NMDeviceWimax *self) { g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0); @@ -320,7 +320,7 @@ nm_device_wimax_get_rssi (NMDeviceWimax *self) * * Deprecated: 1.2: WiMAX is no longer supported. **/ -gint +int nm_device_wimax_get_cinr (NMDeviceWimax *self) { g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0); @@ -341,7 +341,7 @@ nm_device_wimax_get_cinr (NMDeviceWimax *self) * * Deprecated: 1.2: WiMAX is no longer supported. **/ -gint +int nm_device_wimax_get_tx_power (NMDeviceWimax *self) { g_return_val_if_fail (NM_IS_DEVICE_WIMAX (self), 0); diff --git a/libnm-glib/nm-device-wimax.h b/libnm-glib/nm-device-wimax.h index 24e46348e..21d28117b 100644 --- a/libnm-glib/nm-device-wimax.h +++ b/libnm-glib/nm-device-wimax.h @@ -96,11 +96,11 @@ const GPtrArray *nm_device_wimax_get_nsps (NMDeviceWimax *wimax); NM_DEPRECATED_IN_1_2 guint nm_device_wimax_get_center_frequency (NMDeviceWimax *self); NM_DEPRECATED_IN_1_2 -gint nm_device_wimax_get_rssi (NMDeviceWimax *self); +int nm_device_wimax_get_rssi (NMDeviceWimax *self); NM_DEPRECATED_IN_1_2 -gint nm_device_wimax_get_cinr (NMDeviceWimax *self); +int nm_device_wimax_get_cinr (NMDeviceWimax *self); NM_DEPRECATED_IN_1_2 -gint nm_device_wimax_get_tx_power (NMDeviceWimax *self); +int nm_device_wimax_get_tx_power (NMDeviceWimax *self); NM_DEPRECATED_IN_1_2 const char * nm_device_wimax_get_bsid (NMDeviceWimax *self); diff --git a/libnm-glib/nm-object.c b/libnm-glib/nm-object.c index 5956b344e..e2c96d62b 100644 --- a/libnm-glib/nm-object.c +++ b/libnm-glib/nm-object.c @@ -551,7 +551,7 @@ deferred_notify_cb (gpointer data) for (iter = props; iter; iter = g_slist_next (iter)) { NotifyItem *item = iter->data; char buf[50]; - gint ret = 0; + int ret = 0; switch (item->pending) { case NOTIFY_SIGNAL_PENDING_ADDED: diff --git a/libnm-glib/nm-vpn-plugin-utils.c b/libnm-glib/nm-vpn-plugin-utils.c index d53c98345..ca652d1be 100644 --- a/libnm-glib/nm-vpn-plugin-utils.c +++ b/libnm-glib/nm-vpn-plugin-utils.c @@ -66,7 +66,7 @@ nm_vpn_plugin_utils_read_vpn_details (int fd, gboolean success = FALSE; char *key = NULL, *val = NULL; GString *line; - gchar c; + char c; if (out_data) g_return_val_if_fail (*out_data == NULL, FALSE); |