Compare commits

...

3 Commits

Author SHA1 Message Date
Simon Bruder 002ef8d707 CMake: Enable warnings
Not every exercise has the same levels,
but they now have at least some warnings.
2023-05-20 12:35:45 +02:00
Simon Bruder 329aa0b455 u03: Fix warnings by -Wextra
This does not fix one instance of -Wdeprecated-copy, because I don’t
know how to resolve it.

The only other warnings still existing are for the unimplemented tool.
2023-05-20 12:35:45 +02:00
Simon Bruder 0958009b4c u03/terrain: Make helpers call-by-reference 2023-05-20 12:35:45 +02:00
2 changed files with 9 additions and 4 deletions

View File

@ -7,6 +7,11 @@ set(CMAKE_CXX_STANDARD 17)
# On GNU this has the effect of passing -std=c++11 instead of -std=gnu++11
set(CMAKE_CXX_EXTENSIONS no)
# Enable all compiler warnings (and make them errors) on GNU/Clang platforms
if(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang)$")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Werror")
endif()
add_library(tree node.cpp)
add_executable(main main.cpp)
target_link_libraries(main tree)

View File

@ -427,7 +427,7 @@ void BMP_GetPixelRGB( BMP* bmp, UINT x, UINT y, UCHAR* r, UCHAR* g, UCHAR* b )
UINT bytes_per_row;
UCHAR bytes_per_pixel;
if ( bmp == NULL || x < 0 || x >= bmp->Header.Width || y < 0 || y >= bmp->Header.Height )
if ( bmp == NULL || x >= bmp->Header.Width || y >= bmp->Header.Height )
{
BMP_LAST_ERROR_CODE = BMP_INVALID_ARGUMENT;
}
@ -467,7 +467,7 @@ void BMP_SetPixelRGB( BMP* bmp, UINT x, UINT y, UCHAR r, UCHAR g, UCHAR b )
UINT bytes_per_row;
UCHAR bytes_per_pixel;
if ( bmp == NULL || x < 0 || x >= bmp->Header.Width || y < 0 || y >= bmp->Header.Height )
if ( bmp == NULL || x >= bmp->Header.Width || y >= bmp->Header.Height )
{
BMP_LAST_ERROR_CODE = BMP_INVALID_ARGUMENT;
}
@ -505,7 +505,7 @@ void BMP_GetPixelIndex( BMP* bmp, UINT x, UINT y, UCHAR* val )
UCHAR* pixel;
UINT bytes_per_row;
if ( bmp == NULL || x < 0 || x >= bmp->Header.Width || y < 0 || y >= bmp->Header.Height )
if ( bmp == NULL || x >= bmp->Header.Width || y >= bmp->Header.Height )
{
BMP_LAST_ERROR_CODE = BMP_INVALID_ARGUMENT;
}
@ -539,7 +539,7 @@ void BMP_SetPixelIndex( BMP* bmp, UINT x, UINT y, UCHAR val )
UCHAR* pixel;
UINT bytes_per_row;
if ( bmp == NULL || x < 0 || x >= bmp->Header.Width || y < 0 || y >= bmp->Header.Height )
if ( bmp == NULL || x >= bmp->Header.Width || y >= bmp->Header.Height )
{
BMP_LAST_ERROR_CODE = BMP_INVALID_ARGUMENT;
}