Skip to content

Use -Werror when building in CI#17781

Merged
ret2libc merged 13 commits intoradareorg:masterfrom
ret2libc:werror-ci
Oct 13, 2020
Merged

Use -Werror when building in CI#17781
ret2libc merged 13 commits intoradareorg:masterfrom
ret2libc:werror-ci

Conversation

@ret2libc
Copy link
Contributor

Closing issues

Closes #17780

@ret2libc ret2libc requested a review from trufae as a code owner October 12, 2020 09:26
@ret2libc ret2libc requested a review from XVilka October 12, 2020 09:26
@ret2libc ret2libc marked this pull request as draft October 12, 2020 09:27
@trufae
Copy link
Collaborator

trufae commented Oct 12, 2020

Will you fix the current warnings in this PR before merging it?

@ret2libc
Copy link
Contributor Author

Will you fix the current warnings in this PR before merging it?

Yes sure, otherwise it would be red. Done.

@XVilka
Copy link
Contributor

XVilka commented Oct 12, 2020

p/../arch/8051/8051_disas.c:64:14: error: ‘r_8051_disas’ defined but not used [-Werror=unused-function]
 static char *r_8051_disas(ut64 pc, const ut8 *buf, int len, int *olen) {
              ^~~~~~~~~~~~
cc1: all warnings being treated as errors
make[3]: *** [p/../arch/8051/8051_disas.o] Error 1

@github-actions github-actions bot added infrastructure Issues related to the radare2/cutter infrastructure r2r Regression tests RAnal RBin labels Oct 12, 2020
@codecov-io
Copy link

codecov-io commented Oct 12, 2020

Codecov Report

Merging #17781 into master will increase coverage by 0.00%.
The diff coverage is 53.84%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #17781   +/-   ##
=======================================
  Coverage   40.19%   40.19%           
=======================================
  Files        1130     1130           
  Lines      357315   357313    -2     
=======================================
+ Hits       143616   143624    +8     
+ Misses     213699   213689   -10     
Impacted Files Coverage Δ
libr/asm/arch/tms320/c55x_plus/hashtable.c 7.93% <ø> (ø)
libr/bin/mangling/microsoft_demangle.c 74.39% <ø> (-0.05%) ⬇️
libr/io/io_desc.c 69.76% <0.00%> (ø)
libr/socket/run.c 28.79% <ø> (ø)
test/unit/test_pdb.c 0.00% <ø> (ø)
libr/anal/p/anal_mips_gnu.c 29.51% <50.00%> (ø)
libr/reg/profile.c 71.95% <100.00%> (ø)
libr/core/task.c 61.22% <0.00%> (+2.67%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6c89716...d69f4ff. Read the comment docs.

@XVilka
Copy link
Contributor

XVilka commented Oct 13, 2020

Should fix the capstone compilation error: capstone-engine/capstone#1695

@ret2libc
Copy link
Contributor Author

Should fix the capstone compilation error: aquynh/capstone#1695

Until that is not merged, I removed the -Werror from acr builds (as those pass the cflags to capstone as well) so we can merge this and extend it once capstone fix lands upstream.

@ret2libc ret2libc marked this pull request as ready for review October 13, 2020 08:10
@XVilka
Copy link
Contributor

XVilka commented Oct 13, 2020

Unrelated to this PR, but some useful warnings from MSVC:

c:\projects\radare2\libr\asm\arch\xtensa\gnu\xtensa-modules.c(4130): warning C4146: unary minus operator applied to unsigned type, result still unsigned [C:\projects\radare2\build\libr\anal\04634f8@@r_anal@sta.vcxproj]
c:\projects\radare2\libr\debug\p\debug_gdb.c(539): warning C4133: 'initializing': incompatible types - from 'RDebugReasonType (__cdecl *)(RDebug *,int)' to 'int (__cdecl *)(RDebug *,int)' [C:\projects\radare2\build\libr\debug\e931636@@r_debug@sta.vcxproj]
c:\projects\radare2\libr\debug\p\debug_native.c(1596): warning C4133: 'initializing': incompatible types - from 'RDebugReasonType (__cdecl *)(RDebug *,int)' to 'int (__cdecl *)(RDebug *,int)' [C:\projects\radare2\build\libr\debug\e931636@@r_debug@sta.vcxproj]
c:\projects\radare2\libr\debug\p\debug_winkd.c(268): warning C4133: 'initializing': incompatible types - from 'RDebugReasonType (__cdecl *)(RDebug *,int)' to 'int (__cdecl *)(RDebug *,int)' [C:\projects\radare2\build\libr\debug\e931636@@r_debug@sta.vcxproj]
cl : Command line warning D9002: ignoring unknown option '-std=c99' [C:\projects\radare2\build\libr\core\f105261@@r_core@sta.vcxproj]
cl : Command line warning D9002: ignoring unknown option '-std=c99' [C:\projects\radare2\build\libr\core\f105261@@r_core@sta.vcxproj]
cl : Command line warning D9002: ignoring unknown option '-std=c99' [C:\projects\radare2\build\libr\core\f105261@@r_core@sta.vcxproj]
cl : Command line warning D9002: ignoring unknown option '-std=c99' [C:\projects\radare2\build\libr\core\f105261@@r_core@sta.vcxproj]
cl : Command line warning D9002: ignoring unknown option '-std=c99' [C:\projects\radare2\build\libr\core\f105261@@r_core@sta.vcxproj]
cl : Command line warning D9002: ignoring unknown option '-std=c99' [C:\projects\radare2\build\libr\core\f105261@@r_core@sta.vcxproj]
cl : Command line warning D9002: ignoring unknown option '-std=c99' [C:\projects\radare2\build\libr\core\f105261@@r_core@sta.vcxproj]
cl : Command line warning D9002: ignoring unknown option '-std=c99' [C:\projects\radare2\build\libr\core\f105261@@r_core@sta.vcxproj]

And some from clang-cl:

In file included from ../test/unit/test_r2r.c:3:
../test/unit/../../binr/r2r/r2r.c(117,6): warning: implicit declaration of function 'chdir' is invalid in C99 [-Wimplicit-function-declaration]
        if (chdir (abs_test_path) == -1) {
            ^
../test/unit/../../binr/r2r/r2r.c(259,7): warning: implicit declaration of function 'chdir' is invalid in C99 [-Wimplicit-function-declaration]
                if (chdir (r2r_dir) == -1) {
                    ^
In file included from ../test/unit/test_r2r.c:5:
../test/unit/../../binr/r2r/run.c(144,57): warning: passing 'char **' to parameter of type 'const char **' discards qualifiers in nested pointer types [-Wincompatible-pointer-types-discards-qualifiers]
        char *cmdline = r_str_format_msvc_argv (args_size + 1, argv);
                                                               ^~~~
..\libr\include/r_util/r_str.h(162,62): note: passing argument to parameter 'argv' here
R_API char *r_str_format_msvc_argv(size_t argc, const char **argv);
                                                             ^
In file included from ../test/unit/test_r2r.c:5:
../test/unit/../../binr/r2r/run.c(305,23): warning: passing 'unsigned char [1280]' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
                        r_str_remove_char (stdout_buf, '\r');
                                           ^~~~~~~~~~
..\libr\include/r_util/r_str.h(70,36): note: passing argument to parameter 'str' here
R_API void r_str_remove_char(char *str, char c);
                                   ^
In file included from ../test/unit/test_r2r.c:5:
../test/unit/../../binr/r2r/run.c(319,23): warning: passing 'unsigned char [1280]' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
                        r_str_remove_char (stderr_buf, '\r');
                                           ^~~~~~~~~~
..\libr\include/r_util/r_str.h(70,36): note: passing argument to parameter 'str' here
R_API void r_str_remove_char(char *str, char c);
                                   ^
In file included from ../test/unit/test_r2r.c:5:
../test/unit/../../binr/r2r/run.c(810,40): warning: expression result unused [-Wunused-value]
                                                for (; c = *cmds, c && c != '}'; *cmds++) {
                                                                                 ^~~~~~~
6 warnings generated.
In file included from ../libr/bin/mangling/cxx.c:5:
In file included from ..\libr\bin\mangling/./cxx/demangle.h:32:
..\libr\bin\mangling/./cxx/libiberty.h(342,9): warning: 'alloca' macro redefined [-Wmacro-redefined]
#define alloca(x) _alloca(x)
        ^
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\malloc.h(176,13): note: previous definition is here
    #define alloca _alloca
            ^
1 warning generated.
[1016/1543] Compiling C object libr/bin/r_bin.dll.p/mangling_cxx_cp-demangle.c.obj
../libr/bin/mangling/cxx/cp-demangle.c(121,14): warning: incompatible redeclaration of library function 'alloca' [-Wincompatible-library-redeclaration]
extern char *alloca ();
             ^
../libr/bin/mangling/cxx/cp-demangle.c(121,14): note: 'alloca' is a builtin with type 'void *(unsigned long long)'
1 warning generated.
../libr/bin/pdb/pdb_downloader.c(34,9): warning: passing 'LPCWSTR' (aka 'const unsigned short *') to parameter of type 'void *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
                free (origin);
                      ^~~~~~
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(90,42): note: passing argument to parameter '_Block' here
    _Pre_maybenull_ _Post_invalid_ void* _Block
                                         ^
../libr/bin/pdb/pdb_downloader.c(35,9): warning: passing 'LPCWSTR' (aka 'const unsigned short *') to parameter of type 'void *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
                free (dest);
                      ^~~~
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(90,42): note: passing argument to parameter '_Block' here
    _Pre_maybenull_ _Post_invalid_ void* _Block
                                         ^
2 warnings generated.
../binr/r2r/run.c(144,57): warning: passing 'char **' to parameter of type 'const char **' discards qualifiers in nested pointer types [-Wincompatible-pointer-types-discards-qualifiers]
        char *cmdline = r_str_format_msvc_argv (args_size + 1, argv);
                                                               ^~~~
..\libr\include/r_util/r_str.h(162,62): note: passing argument to parameter 'argv' here
R_API char *r_str_format_msvc_argv(size_t argc, const char **argv);
                                                             ^
../binr/r2r/run.c(305,23): warning: passing 'unsigned char [1280]' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
                        r_str_remove_char (stdout_buf, '\r');
                                           ^~~~~~~~~~
..\libr\include/r_util/r_str.h(70,36): note: passing argument to parameter 'str' here
R_API void r_str_remove_char(char *str, char c);
                                   ^
../binr/r2r/run.c(319,23): warning: passing 'unsigned char [1280]' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
                        r_str_remove_char (stderr_buf, '\r');
                                           ^~~~~~~~~~
..\libr\include/r_util/r_str.h(70,36): note: passing argument to parameter 'str' here
R_API void r_str_remove_char(char *str, char c);
                                   ^
../binr/r2r/run.c(810,40): warning: expression result unused [-Wunused-value]
                                                for (; c = *cmds, c && c != '}'; *cmds++) {
                                                                                 ^~~~~~~
4 warnings generated.
[798/1543] Compiling C object test/unit/test_anal_block.exe.p/test_anal_block.c.obj
[799/1543] Compiling C object binr/r2r/r2r.exe.p/r2r.c.obj
../binr/r2r/r2r.c(117,6): warning: implicit declaration of function 'chdir' is invalid in C99 [-Wimplicit-function-declaration]
        if (chdir (abs_test_path) == -1) {
            ^
../binr/r2r/r2r.c(259,7): warning: implicit declaration of function 'chdir' is invalid in C99 [-Wimplicit-function-declaration]
                if (chdir (r2r_dir) == -1) {
                    ^
2 warnings generated.

@XVilka
Copy link
Contributor

XVilka commented Oct 13, 2020

And one in WinDbg code cc @GustavoLCR @yossizap

../libr/debug/p/debug_windbg.c(74,10): warning: implicit declaration of function 'windbg_wait' is invalid in C99 [-Wimplicit-function-declaration]
                return windbg_wait (dbg, dbg->pid) != R_DEBUG_REASON_ERROR;
                       ^
../libr/debug/p/debug_windbg.c(82,25): warning: unused variable 'Qualifier' [-Wunused-variable]
        ULONG Id = tid, Class, Qualifier;
                               ^
../libr/debug/p/debug_windbg.c(82,18): warning: unused variable 'Class' [-Wunused-variable]
        ULONG Id = tid, Class, Qualifier;
                        ^
../libr/debug/p/debug_windbg.c(165,52): warning: incompatible pointer types passing 'int *' to parameter of type 'PULONG' (aka 'unsigned long *') [-Wincompatible-pointer-types]
                ITHISCALL (dbgSysObj, GetCurrentProcessSystemId, &dbg->pid);
                                                                 ^~~~~~~~~
../libr/debug/p/debug_windbg.c(27,88): note: expanded from macro 'ITHISCALL'
#define ITHISCALL(dbginterface, function, ...) THISCALL (idbg->dbginterface, function, __VA_ARGS__)
                                                                                       ^~~~~~~~~~~
../libr/debug/p/debug_windbg.c(26,93): note: expanded from macro 'THISCALL'
#define THISCALL(dbginterface, function, ...) dbginterface->lpVtbl->function (dbginterface, __VA_ARGS__)
                                                                                            ^~~~~~~~~~~
../libr/debug/p/debug_windbg.c(166,51): warning: incompatible pointer types passing 'int *' to parameter of type 'PULONG' (aka 'unsigned long *') [-Wincompatible-pointer-types]
                ITHISCALL (dbgSysObj, GetCurrentThreadSystemId, &dbg->tid);
                                                                ^~~~~~~~~
../libr/debug/p/debug_windbg.c(27,88): note: expanded from macro 'ITHISCALL'
#define ITHISCALL(dbginterface, function, ...) THISCALL (idbg->dbginterface, function, __VA_ARGS__)
                                                                                       ^~~~~~~~~~~
../libr/debug/p/debug_windbg.c(26,93): note: expanded from macro 'THISCALL'
#define THISCALL(dbginterface, function, ...) dbginterface->lpVtbl->function (dbginterface, __VA_ARGS__)
                                                                                            ^~~~~~~~~~~
../libr/debug/p/debug_windbg.c(220,40): warning: incompatible pointer types passing 'int *' to parameter of type 'volatile long *' [-Wincompatible-pointer-types]
                        b->internal = InterlockedIncrement (&bp_idx);
                                                            ^~~~~~~
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um\winnt.h(3019,50): note: passing argument to parameter 'Addend' here
    _Inout_ _Interlocked_operand_ LONG volatile *Addend
                                                 ^
../libr/debug/p/debug_windbg.c(248,39): warning: incompatible pointer types passing 'int *' to parameter of type 'PULONG' (aka 'unsigned long *') [-Wincompatible-pointer-types]
        THISCALL (bkpt, GetCurrentPassCount, &b->togglehits);
                                             ^~~~~~~~~~~~~~
../libr/debug/p/debug_windbg.c(26,93): note: expanded from macro 'THISCALL'
#define THISCALL(dbginterface, function, ...) dbginterface->lpVtbl->function (dbginterface, __VA_ARGS__)
                                                                                            ^~~~~~~~~~~
../libr/debug/p/debug_windbg.c(279,89): warning: incompatible pointer types passing 'int *' to parameter of type 'PULONG' (aka 'unsigned long *') [-Wincompatible-pointer-types]
        if (!idbg || !idbg->initialized || FAILED (ITHISCALL (dbgCtrl, GetActualProcessorType, &type))) {
                                                                                               ^~~~~
../libr/debug/p/debug_windbg.c(27,88): note: expanded from macro 'ITHISCALL'
#define ITHISCALL(dbginterface, function, ...) THISCALL (idbg->dbginterface, function, __VA_ARGS__)
                                                                                       ^~~~~~~~~~~
../libr/debug/p/debug_windbg.c(26,93): note: expanded from macro 'THISCALL'
#define THISCALL(dbginterface, function, ...) dbginterface->lpVtbl->function (dbginterface, __VA_ARGS__)
                                                                                            ^~~~~~~~~~~
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared\winerror.h(28988,32): note: expanded from macro 'FAILED'
#define FAILED(hr) (((HRESULT)(hr)) < 0)
                               ^~
8 warnings generated.
[664/1543] Compiling C object libr/debug/r_debug.dll.p/p_native_maps_windows_maps.c.obj
[665/1543] Compiling C object libr/core/r_core.dll.p/casm.c.obj
[666/1543] Compiling C object libr/debug/r_debug.dll.p/p_debug_winkd.c.obj
[667/1543] Compiling C object libr/debug/r_debug.dll.p/p_native_windows_windows_debug.c.obj
../libr/debug/p/native/windows/windows_debug.c(1482,34): warning: cast to 'HANDLE' (aka 'void *') from smaller integer type 'USHORT' (aka 'unsigned short') [-Wint-to-void-pointer-cast]
                if (w32_NtDuplicateObject (ph, (HANDLE)handle.Handle, GetCurrentProcess (), &dupHandle, 0, 0, 0)) {
                                               ^
1 warning generated.
../libr/socket/socket.c(304,56): warning: incompatible pointer types passing 'int *' to parameter of type 'const char *' [-Wincompatible-pointer-types]
                                ret = setsockopt (s->fd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof (flag));
                                                                                   ^~~~~
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um\winsock2.h(2131,51): note: passing argument to parameter 'optval' here
    _In_reads_bytes_opt_(optlen) const char FAR * optval,
                                                  ^
../libr/socket/socket.c(261,21): warning: unused variable 'sa' [-Wunused-variable]
        struct sockaddr_in sa;
                           ^
../libr/socket/socket.c(794,23): warning: passing 'unsigned char *' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
        int r = recv (s->fd, buf, len, 0);
                             ^~~
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um\winsock2.h(2004,78): note: passing argument to parameter 'buf' here
    _Out_writes_bytes_to_(len, return) __out_data_source(NETWORK) char FAR * buf,
                                                                             ^
3 warnings generated.

@ret2libc ret2libc merged commit 741d22e into radareorg:master Oct 13, 2020
@trufae
Copy link
Collaborator

trufae commented Oct 13, 2020

🎉

@XVilka
Copy link
Contributor

XVilka commented Oct 14, 2020

It broke Capstone 3 builds. Maybe we should just silently skip instead of emitting a #warning?

FAILED: libr/asm/8a8d21f@@r_asm@sha/p_asm_m68k_cs.c.o 
gcc -Ilibr/asm/8a8d21f@@r_asm@sha -I. -I../ -I../libr/include -Ilibr/asm/../../shlr -I../libr/asm/../../shlr -I../libr/asm/arch/include -I../libr/asm/arch -I../libr/asm/arch/h8300 -I../libr/asm/arch/hexagon -I../libr/asm/arch/msp430 -I../libr/asm/arch/rsp -I../libr/asm/arch/mcore -I../libr/asm/arch/v850 -I../libr/asm/arch/propeller -I../libr/asm/arch/ebc -I../libr/asm/arch/cr16 -I../libr/asm/arch/8051 -I../libr/asm/arch/v810 -I../libr/asm/arch/or1k -I../shlr/spp -I../shlr/sdb/src -I../shlr/zip/zlib -I../shlr/capstone/include -I../shlr/java -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -g -fvisibility=hidden -Werror -fPIC -pthread -DR2_PLUGIN_INCORE=1 -MD -MQ 'libr/asm/8a8d21f@@r_asm@sha/p_asm_m68k_cs.c.o' -MF 'libr/asm/8a8d21f@@r_asm@sha/p_asm_m68k_cs.c.o.d' -o 'libr/asm/8a8d21f@@r_asm@sha/p_asm_m68k_cs.c.o' -c ../libr/asm/p/asm_m68k_cs.c
../libr/asm/p/asm_m68k_cs.c:14:2: error: #warning Cannot find capstone-m68k support [-Werror=cpp]
 #warning Cannot find capstone-m68k support
  ^~~~~~~
cc1: all warnings being treated as errors
[733/1528] Compiling C object 'libr/asm/8
``

@ret2libc
Copy link
Contributor Author

We could try -Wno-cpp (C, Objective-C, C++, Objective-C++ and Fortran only) Suppress warning messages emitted by #warning directives. (according to GCC pages). I will do this in a separate pr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infrastructure Issues related to the radare2/cutter infrastructure r2r Regression tests RAnal RBin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use -Werror for CI builds to catch new warnings

5 participants

Comments