From: Antonio Ospite Date: Tue, 24 Jan 2012 14:39:24 +0000 (+0100) Subject: Dump the data only in DEBUG builds X-Git-Tag: v0.1.0~17 X-Git-Url: https://git.ao2.it/libam7xxx.git/commitdiff_plain/a083bf6cc5c360d21f357c410142b3e9f12da79c?ds=sidebyside Dump the data only in DEBUG builds Also use -Werror only in DEBUG builds, otherwise normal builds fail with: src/am7xxx.c:42:13: error: ‘dump_header’ defined but not used [-Werror=unused-function] src/am7xxx.c:73:13: error: ‘dump_buffer’ defined but not used [-Werror=unused-function] --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c9b1c1..be8e4e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,6 @@ if (CMAKE_COMPILER_IS_GNUCC) add_flags(CMAKE_C_FLAGS -fno-common -Wall - -Werror -Wextra -Wformat=2 -Winit-self @@ -72,7 +71,7 @@ if (CMAKE_COMPILER_IS_GNUCC) ) endif() -set(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG=1") +set(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG=1 -Werror") set(CMAKE_C_FLAGS_RELEASE "-O2") set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g") diff --git a/src/am7xxx.c b/src/am7xxx.c index 182ea27..397dc97 100644 --- a/src/am7xxx.c +++ b/src/am7xxx.c @@ -99,7 +99,10 @@ static int send_data(am7xxx_device dev, uint8_t *buffer, unsigned int len) int ret; int transferred; +#if DEBUG dump_buffer(buffer, len); + printf("\n"); +#endif ret = libusb_bulk_transfer(dev, 1, buffer, len, &transferred, 0); if (ret != 0 || (unsigned int)transferred != len) { @@ -131,6 +134,11 @@ static int send_header(am7xxx_device dev, struct am7xxx_header *h) uint8_t *buffer; int ret; +#if DEBUG + dump_header(h); + printf("\n"); +#endif + buffer = calloc(AM7XXX_HEADER_WIRE_SIZE, 1); if (buffer == NULL) { perror("calloc buffer"); @@ -204,12 +212,6 @@ int am7xxx_send_image(am7xxx_device dev, }, }; - dump_header(&h); - printf("\n"); - - printf("Dump Buffers\n"); - dump_buffer(reference_image_header, sizeof(struct am7xxx_header)); - ret = send_header(dev, &h); if (ret < 0) return ret;