From: Steinar H. Gunderson Date: Thu, 17 Sep 2015 20:06:02 +0000 (+0200) Subject: Move to -Wall, and fix all -Wall warnings. X-Git-Tag: 0.4~80 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=9edcf108cdd3dc856158b70aa399e6a875c61f0f;p=bmusb Move to -Wall, and fix all -Wall warnings. --- diff --git a/Makefile b/Makefile index d8c5399..3489104 100644 --- 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 diff --git a/bmusb.cpp b/bmusb.cpp index 04b54a6..ac73432 100644 --- 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 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));