From: Antonio Ospite Date: Sat, 27 Jul 2013 18:55:48 +0000 (+0200) Subject: examples: silence a couple of clang warnings X-Git-Tag: v0.1.4~16 X-Git-Url: https://git.ao2.it/libam7xxx.git/commitdiff_plain/48cd69fbef6ecdac1fe874ff5f2564e88dbc022b?ds=sidebyside examples: silence a couple of clang warnings Silence a couple of warnings given when compiling with clang: ../examples/am7xxx-play.c:764:28: warning: will never be executed [-Wunreachable-code] AM7XXX_ZOOM_ORIGINAL, AM7XXX_ZOOM_TEST); ^~~~~~~~~~~~~~~~ ../examples/am7xxx-play.c:748:24: warning: will never be executed [-Wunreachable-code] AM7XXX_POWER_OFF, AM7XXX_POWER_TURBO); 2 warnings generated. ../examples/picoproj.c:142:28: warning: will never be executed [-Wunreachable-code] AM7XXX_ZOOM_ORIGINAL, AM7XXX_ZOOM_TEST); ^~~~~~~~~~~~~~~~ ../examples/picoproj.c:127:24: warning: will never be executed [-Wunreachable-code] AM7XXX_POWER_OFF, AM7XXX_POWER_TURBO); 2 warnings generated. The warnings refer to the default case of a switch statement over an enum variable, clang fails to understand that the default case can still be reached because any integer value can be assigned to the enum variables via the atoi() function. Work around the warning. The behavior is also documented here: http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-September/024174.html In general assigning arbitrary values to enum variables will just be weird; using enums in read mode is always safe tho. --- diff --git a/examples/am7xxx-play.c b/examples/am7xxx-play.c index 4506358..4550495 100644 --- a/examples/am7xxx-play.c +++ b/examples/am7xxx-play.c @@ -635,8 +635,8 @@ int main(int argc, char *argv[]) unsigned int quality = 95; int log_level = AM7XXX_LOG_INFO; int device_index = 0; - am7xxx_power_mode power_mode = AM7XXX_POWER_LOW; - am7xxx_zoom_mode zoom = AM7XXX_ZOOM_ORIGINAL; + int power_mode = AM7XXX_POWER_LOW; + int zoom = AM7XXX_ZOOM_ORIGINAL; int format = AM7XXX_IMAGE_FORMAT_JPEG; am7xxx_context *ctx; am7xxx_device *dev; diff --git a/examples/picoproj.c b/examples/picoproj.c index d6d1c59..5d95b3a 100644 --- a/examples/picoproj.c +++ b/examples/picoproj.c @@ -68,8 +68,8 @@ int main(int argc, char *argv[]) am7xxx_device *dev; int log_level = AM7XXX_LOG_INFO; int device_index = 0; - am7xxx_power_mode power_mode = AM7XXX_POWER_LOW; - am7xxx_zoom_mode zoom = AM7XXX_ZOOM_ORIGINAL; + int power_mode = AM7XXX_POWER_LOW; + int zoom = AM7XXX_ZOOM_ORIGINAL; int format = AM7XXX_IMAGE_FORMAT_JPEG; int width = 800; int height = 480;