Dump the data only in DEBUG builds
authorAntonio Ospite <ospite@studenti.unina.it>
Tue, 24 Jan 2012 14:39:24 +0000 (15:39 +0100)
committerAntonio Ospite <ospite@studenti.unina.it>
Wed, 25 Jan 2012 14:57:30 +0000 (15:57 +0100)
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]

CMakeLists.txt
src/am7xxx.c

index 8c9b1c1..be8e4e7 100644 (file)
@@ -45,7 +45,6 @@ if (CMAKE_COMPILER_IS_GNUCC)
   add_flags(CMAKE_C_FLAGS
     -fno-common
     -Wall
   add_flags(CMAKE_C_FLAGS
     -fno-common
     -Wall
-    -Werror
     -Wextra
     -Wformat=2
     -Winit-self
     -Wextra
     -Wformat=2
     -Winit-self
@@ -72,7 +71,7 @@ if (CMAKE_COMPILER_IS_GNUCC)
     )
 endif()
 
     )
 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")
 
 set(CMAKE_C_FLAGS_RELEASE "-O2")
 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
 
index 182ea27..397dc97 100644 (file)
@@ -99,7 +99,10 @@ static int send_data(am7xxx_device dev, uint8_t *buffer, unsigned int len)
        int ret;
        int transferred;
 
        int ret;
        int transferred;
 
+#if DEBUG
        dump_buffer(buffer, len);
        dump_buffer(buffer, len);
+       printf("\n");
+#endif
 
        ret = libusb_bulk_transfer(dev, 1, buffer, len, &transferred, 0);
        if (ret != 0 || (unsigned int)transferred != len) {
 
        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;
 
        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");
        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;
        ret = send_header(dev, &h);
        if (ret < 0)
                return ret;