evmgr: Fix a "maybe uninitialized" issue 67/20867/1
authorJosé Bollo <jose.bollo@iot.bzh>
Tue, 2 Apr 2019 07:48:50 +0000 (09:48 +0200)
committerJosé Bollo <jose.bollo@iot.bzh>
Tue, 2 Apr 2019 07:53:18 +0000 (09:53 +0200)
The warning maybe-uninitialized is emited only
when the optimisation level is greater than 0.
For this reason, the error was not discovered
development process. The build config is tuned
to detect that error and the error is fixed.

Change-Id: I14c8ffe6daa3d498268cfadeab20300895b3360e
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
CMakeLists.txt
src/evmgr.c

index dfbdadf..f564630 100644 (file)
@@ -61,12 +61,12 @@ add_compile_options(-Werror=maybe-uninitialized)
 add_compile_options(-Werror=implicit-function-declaration)
 add_compile_options(-ffunction-sections -fdata-sections)
 add_compile_options(-fPIC)
-add_compile_options(-g)
+add_compile_options(-g -O2)
 set (CMAKE_CXX_STANDARD 14)
 
-set(CMAKE_C_FLAGS_PROFILING    "-g -O2 -pg -Wp,-U_FORTIFY_SOURCE")
-set(CMAKE_C_FLAGS_DEBUG        "-g -ggdb -Wp,-U_FORTIFY_SOURCE")
-set(CMAKE_C_FLAGS_RELEASE      "-g -O2")
+set(CMAKE_C_FLAGS_PROFILING    "-g -O2 -pg -U_FORTIFY_SOURCE")
+set(CMAKE_C_FLAGS_DEBUG        "-g -O2 -ggdb -U_FORTIFY_SOURCE")
+set(CMAKE_C_FLAGS_RELEASE      "-g -O3")
 set(CMAKE_C_FLAGS_CCOV         "-g -O2 --coverage")
 
 ###########################################################################
index 2dc35e4..557a9f3 100644 (file)
@@ -185,13 +185,14 @@ int evmgr_create(struct evmgr **result)
        /* creates the eventfd for waking up polls */
        evmgr->efd = eventfd(0, EFD_CLOEXEC|EFD_SEMAPHORE);
        if (evmgr->efd < 0) {
-               ERROR("can't make eventfd for events");
                rc = -errno;
+               ERROR("can't make eventfd for events");
                goto error1;
        }
        /* create the systemd event loop */
        evmgr->sdev = systemd_get_event_loop();
        if (!evmgr->sdev) {
+               rc = -errno;
                ERROR("can't make new event loop");
                goto error2;
        }