From c27250f52fcfb936d4f0410d1199fe24c04b9713 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Fri, 28 Oct 2022 17:14:32 +1100 Subject: [PATCH] Add -Wall to build-example.sh --- build-example.sh | 4 ++-- example/cbor-to-json/cbor-to-json.cc | 6 ++---- example/json-to-cbor/json-to-cbor.cc | 6 ++---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/build-example.sh b/build-example.sh index 6f512f7c..c428d8ac 100755 --- a/build-example.sh +++ b/build-example.sh @@ -28,8 +28,8 @@ LDFLAGS=${LDFLAGS:-} # The "-fdata-sections -ffunction-sections -Wl,--gc-sections" produces smaller # binaries. See commit 41fce8a8 "Strip examples of unused data and functions". -CFLAGS=${CFLAGS:--O3 -fdata-sections -ffunction-sections -Wl,--gc-sections} -CXXFLAGS=${CXXFLAGS:--O3 -fdata-sections -ffunction-sections -Wl,--gc-sections} +CFLAGS=${CFLAGS:--O3 -fdata-sections -ffunction-sections -Wall -Wl,--gc-sections} +CXXFLAGS=${CXXFLAGS:--O3 -fdata-sections -ffunction-sections -Wall -Wl,--gc-sections} mkdir -p gen/bin diff --git a/example/cbor-to-json/cbor-to-json.cc b/example/cbor-to-json/cbor-to-json.cc index e23b8cdc..02b540cb 100644 --- a/example/cbor-to-json/cbor-to-json.cc +++ b/example/cbor-to-json/cbor-to-json.cc @@ -385,10 +385,8 @@ flush_dst() { if (n == 0) { break; } - ssize_t i = fwrite(g_dst.reader_pointer(), 1, n, stdout); - if (i >= 0) { - g_dst.meta.ri += i; - } + size_t i = fwrite(g_dst.reader_pointer(), 1, n, stdout); + g_dst.meta.ri += i; if (i < n) { return "main: error writing to stdout"; } diff --git a/example/json-to-cbor/json-to-cbor.cc b/example/json-to-cbor/json-to-cbor.cc index cb045041..30f806ec 100644 --- a/example/json-to-cbor/json-to-cbor.cc +++ b/example/json-to-cbor/json-to-cbor.cc @@ -215,10 +215,8 @@ flush_dst() { if (n == 0) { break; } - ssize_t i = fwrite(g_dst.reader_pointer(), 1, n, stdout); - if (i >= 0) { - g_dst.meta.ri += i; - } + size_t i = fwrite(g_dst.reader_pointer(), 1, n, stdout); + g_dst.meta.ri += i; if (i < n) { return "main: error writing to stdout"; }