diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2009-07-14 06:06:46 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2009-07-14 06:06:46 +0200 |
commit | feb36e2d5b0edb882e152c1fd958166e22eb0cbd (patch) | |
tree | 7a7aed1aa5757d7b0925e6303e03efffa3a6e361 /src | |
parent | 3d1dd9d452e341e65a4a96c5ed77cc693dcdc673 (diff) | |
download | ofono-feb36e2d5b0edb882e152c1fd958166e22eb0cbd.tar.bz2 |
Fix stupid false positive warnings about uninitialized variables
The GCC check for uninitialized variables is so useful that dealing
with the false positives is just a minor inconvenience.
The following GCC trick helps to silence them:
#define uninitialized_var(x) x = x
This way no code obfuscation is needed to compile smoothly and the
code stays readable. And the author has to actually think about it.
Diffstat (limited to 'src')
-rw-r--r-- | src/sms.c | 4 | ||||
-rw-r--r-- | src/smsutil.c | 23 |
2 files changed, 17 insertions, 10 deletions
@@ -40,6 +40,8 @@ #include "sim.h" #include "smsutil.h" +#define uninitialized_var(x) x = x + #define SMS_MANAGER_INTERFACE "org.ofono.SmsManager" #define SMS_MANAGER_FLAG_CACHED 0x1 @@ -522,7 +524,7 @@ static void sms_dispatch(struct ofono_modem *modem, GSList *sms_list) { GSList *l; const struct sms *sms; - enum sms_charset old_charset; + enum sms_charset uninitialized_var(old_charset); enum sms_class cls; int srcport = -1; int dstport = -1; diff --git a/src/smsutil.c b/src/smsutil.c index 292a3fe9..ad38ed98 100644 --- a/src/smsutil.c +++ b/src/smsutil.c @@ -31,6 +31,8 @@ #include "util.h" #include "smsutil.h" +#define uninitialized_var(x) x = x + void extract_bcd_number(const unsigned char *buf, int len, char *out) { static const char digit_lut[] = "0123456789*#abc\0"; @@ -1435,10 +1437,10 @@ const guint8 *sms_extract_common(const struct sms *sms, gboolean *out_udhi, guint8 *out_max) { const guint8 *ud = NULL; - guint8 udl; - guint8 max; - gboolean udhi; - guint8 dcs; + guint8 uninitialized_var(udl); + guint8 uninitialized_var(max); + gboolean uninitialized_var(udhi); + guint8 uninitialized_var(dcs); switch (sms->type) { case SMS_TYPE_DELIVER: @@ -1752,7 +1754,7 @@ static gboolean extract_app_port_common(struct sms_udh_iter *iter, int *dst, guint8 addr_hdr[4]; int srcport = -1; int dstport = -1; - gboolean is_addr_8bit; + gboolean uninitialized_var(is_addr_8bit); /* According to the specification, we have to use the last * useable header. Also, we have to ignore ports that are reserved: @@ -1838,8 +1840,8 @@ gboolean sms_extract_concatenation(const struct sms *sms, guint16 *ref_num, struct sms_udh_iter iter; enum sms_iei iei; guint8 concat_hdr[4]; - guint16 rn; - guint8 max, seq; + guint16 uninitialized_var(rn); + guint8 uninitialized_var(max), uninitialized_var(seq); gboolean concatenated = FALSE; /* We must ignore the entire user_data header here: @@ -2699,13 +2701,16 @@ char *cbs_decode_text(GSList *cbs_list, char *iso639_lang) { GSList *l; const struct cbs *cbs = cbs_list->data; - enum sms_charset charset; + enum sms_charset uninitialized_var(charset); enum cbs_language lang; - gboolean iso639; + gboolean uninitialized_var(iso639); int bufsize = 0; unsigned char *buf; char *utf8; + if (cbs_list == NULL) + return NULL; + /* CBS can only come from the network, so we're much less lenient * on what we support. Namely we require the same charset to be * used across all pages. |