]> git.sesse.net Git - bmusb/commitdiff
Move to -Wall, and fix all -Wall warnings.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 17 Sep 2015 20:06:02 +0000 (22:06 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 17 Sep 2015 20:06:02 +0000 (22:06 +0200)
Makefile
bmusb.cpp

index d8c53994e5339551d52370cf726ee3f0e5f795e1..3489104e9ed806d67373e79ea0e4e7289b17f4a2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-CXXFLAGS := -std=gnu++14 -O2 -g $(shell pkg-config libusb-1.0 --cflags) -pthread
+CXXFLAGS := -std=gnu++14 -O2 -Wall -g $(shell pkg-config libusb-1.0 --cflags) -pthread
 LDFLAGS := $(shell pkg-config libusb-1.0 --libs) -pthread
 
 main: bmusb.o main.o
index 04b54a6a9c2ac6bd582098a24cd2e8cd69aa37e1..ac73432b2fc7816802c1f9e5b377074994622ada 100644 (file)
--- a/bmusb.cpp
+++ b/bmusb.cpp
@@ -234,10 +234,11 @@ void start_new_audio_block(const uint8_t *start)
        current_audio_frame = audio_frame_allocator->alloc_frame();
 }
 
+#if 0
 static void dump_pack(const libusb_transfer *xfr, int offset, const libusb_iso_packet_descriptor *pack)
 {
        //      printf("ISO pack%u length:%u, actual_length:%u, offset:%u\n", i, pack->length, pack->actual_length, offset);
-       for (int j = 0; j < pack->actual_length; j++) {
+       for (unsigned j = 0; j < pack->actual_length; j++) {
        //for (int j = 0; j < min(pack->actual_length, 16u); j++) {
                printf("%02x", xfr->buffer[j + offset]);
                if ((j % 16) == 15)
@@ -248,6 +249,7 @@ static void dump_pack(const libusb_transfer *xfr, int offset, const libusb_iso_p
                        printf(" ");
        }
 }
+#endif
 
 void add_to_frame(FrameAllocator::Frame *current_frame, const char *frame_type_name, const uint8_t *start, const uint8_t *end)
 {
@@ -259,7 +261,8 @@ void add_to_frame(FrameAllocator::Frame *current_frame, const char *frame_type_n
 
        int bytes = end - start;
        if (current_frame->len + bytes > current_frame->size) {
-               printf("%d bytes overflow after last %s frame\n", current_frame->len + bytes - current_frame->size, frame_type_name);
+               printf("%d bytes overflow after last %s frame\n",
+                       int(current_frame->len + bytes - current_frame->size), frame_type_name);
                //dump_frame();
        } else {
                memcpy(current_frame->data + current_frame->len, start, bytes);
@@ -275,7 +278,7 @@ void decode_packs(const libusb_transfer *xfr,
                   function<void(const uint8_t *start)> start_callback)
 {
        int offset = 0;
-       for (unsigned i = 0; i < xfr->num_iso_packets; i++) {
+       for (int i = 0; i < xfr->num_iso_packets; i++) {
                const libusb_iso_packet_descriptor *pack = &xfr->iso_packet_desc[i];
 
                if (pack->status != LIBUSB_TRANSFER_COMPLETED) {
@@ -285,7 +288,7 @@ void decode_packs(const libusb_transfer *xfr,
                }
 
                const unsigned char *iso_start = xfr->buffer + offset;
-               for (int iso_offset = 0; iso_offset < pack->actual_length; ) {  // Usually runs only one iteration.
+               for (unsigned iso_offset = 0; iso_offset < pack->actual_length; ) {  // Usually runs only one iteration.
                        const unsigned char* start_next_frame = (const unsigned char *)memmem(iso_start + iso_offset, pack->actual_length - iso_offset, sync_pattern, sync_length);
                        if (start_next_frame == nullptr) {
                                // add the rest of the buffer
@@ -326,7 +329,7 @@ static void cb_xfr(struct libusb_transfer *xfr)
                }
        }
        if (xfr->type == LIBUSB_TRANSFER_TYPE_CONTROL) {
-               const libusb_control_setup *setup = libusb_control_transfer_get_setup(xfr);
+               //const libusb_control_setup *setup = libusb_control_transfer_get_setup(xfr);
                uint8_t *buf = libusb_control_transfer_get_data(xfr);
 #if 0
                if (setup->wIndex == 44) {
@@ -365,7 +368,6 @@ static void cb_xfr(struct libusb_transfer *xfr)
        }
 #endif
 
-end:
        if (libusb_submit_transfer(xfr) < 0) {
                fprintf(stderr, "error re-submitting URB\n");
                exit(1);
@@ -654,7 +656,7 @@ void start_bm_capture()
 #endif
        };
 
-       for (int req = 0; req < sizeof(ctrls) / sizeof(ctrls[0]); ++req) {
+       for (unsigned req = 0; req < sizeof(ctrls) / sizeof(ctrls[0]); ++req) {
                uint32_t flipped = htonl(ctrls[req].data);
                static uint8_t value[4];
                memcpy(value, &flipped, sizeof(flipped));