Create the UNEXPECTED() macro

There are several points in swupd that we find conditions that should never
happen, but we try to correct them anyway to be more reliable. Because of that
we may hide programming mistakes that are corrected later.

So, to make sure we are going to catch those problems in debug mode in our development
machines and test environment, I am suggesting a UNEXPECTED() macro that aborts swupd
if --enable-debug was used to build swupd.

I am adding some examples on what we could do with that.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
This commit is contained in:
Otavio Pontes
2020-04-13 11:18:31 -07:00
parent e77c270ad8
commit c019e11cc0
3 changed files with 21 additions and 1 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ sudo ln -s /usr/share/docutils/scripts/python3/rst2man /usr/bin/rst2man.py
# Build Swupd
autoreconf --verbose --warnings=none --install --force
./configure CFLAGS="$CFLAGS -fsanitize=address -Werror" --prefix=/usr --with-fallback-capaths="$PWD"/swupd_test_certificates --with-systemdsystemunitdir=/usr/lib/systemd/system --with-config-file-path="$PWD"/testconfig
./configure CFLAGS="$CFLAGS -fsanitize=address -Werror" --prefix=/usr --with-fallback-capaths="$PWD"/swupd_test_certificates --with-systemdsystemunitdir=/usr/lib/systemd/system --with-config-file-path="$PWD"/testconfig --enable-debug
make -j$CORES
# Needed to initialize the host for auto-update. Without these steps auto-update