summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLi Xiaoming <lixm.fnst@cn.fujitsu.com>2019-09-06 11:39:23 +0800
committerLi Xiaoming <lixm.fnst@cn.fujitsu.com>2019-09-06 11:39:23 +0800
commit7a5420276bb28ae5ab42110afb4cb3a537781cf5 (patch)
treeb210dd77b2d985f62097427c650dab83a200bc03
parent97b2f0e9ce99a64e3d34461e939a2de72088dab0 (diff)
fix: Remove -Wformat= & -Woverflow warning
/work/agl-service-bluetooth-map/binding/bluetooth-map-bmessage.c:206:11: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 7 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=] AFB_INFO("Parsing incoming bMessage of length %lu", strlen(bmessage)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~ /work/agl-service-bluetooth-map/binding/bluetooth-map-bmessage.c: In function ‘bmessage_encoder’: /work/agl-service-bluetooth-map/binding/bluetooth-map-bmessage.c:293:34: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=] tmp = g_strdup_printf("LENGTH:%lu", ~~^ %u strlen(BEGINMSG) + msg->len + strlen(ENDMSG)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ 33%] Building C object binding/CMakeFiles/bluetooth-map-binding.dir/ bluetooth-map-util.c.o /work/agl-service-bluetooth-map/binding/bluetooth-map-util.c: In function ‘simple_gvariant_to_json’: /work/agl-service-bluetooth-map/binding/bluetooth-map-util.c:170:14: warning: integer overflow in expression ‘-2147483648’ of type ‘long int’ results in ‘-2147483648’ [-Woverflow] if (i64 >= -(1L << 31) && i64 < (1L << 31)) ^ In file included from /xdt/sdk/sysroots/armv7vet2hf-neon-vfpv4-agl-linux -gnueabi/usr/include/afb/afb-binding.h:116, from /work/agl-service-bluetooth-map/binding/bluetooth -map-util.c:36: /work/agl-service-bluetooth-map/binding/bluetooth-map-util.c:291:16: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 7 has type ‘gsize’ {aka ‘unsigned int’} [-Wformat=] AFB_WARNING("Can't handle variants with more than one children (%lu)" ,nitems); Bug-AGL: SPEC-2422 Change-Id: Icebf98f1857ee02abe80f3d2b42099dcd7c702cc Signed-off-by: Li Xiaoming <lixm.fnst@cn.fujitsu.com>
-rw-r--r--binding/bluetooth-map-bmessage.c4
-rw-r--r--binding/bluetooth-map-util.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/binding/bluetooth-map-bmessage.c b/binding/bluetooth-map-bmessage.c
index 282669c..ba59678 100644
--- a/binding/bluetooth-map-bmessage.c
+++ b/binding/bluetooth-map-bmessage.c
@@ -203,7 +203,7 @@ json_object *bmessage_parse(const gchar *bmessage)
if (!bmessage || !strlen(bmessage))
return NULL;
- AFB_INFO("Parsing incoming bMessage of length %lu", strlen(bmessage));
+ AFB_INFO("Parsing incoming bMessage of length %zu", strlen(bmessage));
msg = g_strsplit(bmessage, "\n", -1);
sanitize_msg(msg);
@@ -290,7 +290,7 @@ GString *bmessage_encoder(afb_req_t request)
body_append(body, "BEGIN:BBODY");
body_append(body, "CHARSET:UTF-8");
- tmp = g_strdup_printf("LENGTH:%lu",
+ tmp = g_strdup_printf("LENGTH:%zu",
strlen(BEGINMSG) + msg->len + strlen(ENDMSG));
body_append(body, tmp);
diff --git a/binding/bluetooth-map-util.c b/binding/bluetooth-map-util.c
index 420c7d2..a1417e7 100644
--- a/binding/bluetooth-map-util.c
+++ b/binding/bluetooth-map-util.c
@@ -167,7 +167,7 @@ json_object *simple_gvariant_to_json(GVariant *var, json_object *parent,
break;
case G_VARIANT_CLASS_INT64:
i64 = g_variant_get_int64(var);
- if (i64 >= -(1L << 31) && i64 < (1L << 31))
+ if (i64 >= -(1LL << 31) && i64 < (1LL << 31))
obj = json_object_new_int((int)i64);
else
obj = json_object_new_int64(i64);
@@ -288,7 +288,7 @@ json_object *simple_gvariant_to_json(GVariant *var, json_object *parent,
g_variant_iter_init(&iter, var);
nitems = g_variant_iter_n_children(&iter);
if (nitems != 1) {
- AFB_WARNING("Can't handle variants with more than one children (%lu)", nitems);
+ AFB_WARNING("Can't handle variants with more than one children (%zu)", nitems);
break;
}