From c86913aed1ca0734e873137f8b2bda870710198b Mon Sep 17 00:00:00 2001 From: Kees Jongenburger Date: Tue, 29 Dec 2009 11:38:02 +0100 Subject: [PATCH] Intenting the code --- main.c | 4 ++-- slogic.c | 12 +++++++----- slogic.h | 6 +++--- usbutil.c | 12 ++++++------ usbutil.h | 2 +- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/main.c b/main.c index e9feda9..4555830 100644 --- a/main.c +++ b/main.c @@ -117,7 +117,7 @@ bool parse_args(int argc, char **argv) libusb_debug_level = strtol(optarg, &endptr, 10); if (*endptr != '\0' || libusb_debug_level < 0 || libusb_debug_level > 3) { short_usage("Invalid libusb debug level, must be a positive integer between " - "0 and 3: %s", optarg); + "0 and 3: %s", optarg); return false; } break; @@ -147,7 +147,7 @@ bool parse_args(int argc, char **argv) int count = 0; int sum = 0; -bool on_data_callback(uint8_t *data, size_t size, void *user_data) +bool on_data_callback(uint8_t * data, size_t size, void *user_data) { bool more = sum < 24 * 1024 * 1024; fprintf(stderr, "Got sample: size: %zu, #samples: %d, aggregate size: %d, more: %d\n", size, count, sum, more); diff --git a/slogic.c b/slogic.c index b3abfe8..2fc96b1 100644 --- a/slogic.c +++ b/slogic.c @@ -54,7 +54,7 @@ struct slogic_sample_rate sample_rates[] = { static const int n_sample_rates = sizeof(sample_rates) / sizeof(struct slogic_sample_rate); -void slogic_available_sample_rates(struct slogic_sample_rate **sample_rates_out, size_t *size) +void slogic_available_sample_rates(struct slogic_sample_rate **sample_rates_out, size_t * size) { *sample_rates_out = sample_rates; *size = n_sample_rates; @@ -149,7 +149,7 @@ void slogic_close(struct slogic_handle *handle) free(handle); } -void slogic_tune(struct slogic_handle *handle, FILE *debug_file, size_t transfer_buffer_size, +void slogic_tune(struct slogic_handle *handle, FILE * debug_file, size_t transfer_buffer_size, unsigned int n_transfer_buffers, unsigned int transfer_timeout, int libusb_debug_level) { assert(handle); @@ -305,7 +305,8 @@ void slogic_read_samples_callback(struct libusb_transfer *transfer) internal_recording->done = true; - fprintf(internal_recording->recording->debug_file, "Transfer failed: %s\n", libusb_transfer_status_to_string(transfer->status)); + fprintf(internal_recording->recording->debug_file, "Transfer failed: %s\n", + libusb_transfer_status_to_string(transfer->status)); switch (transfer->status) { default: @@ -431,7 +432,8 @@ void slogic_execute_recording(struct slogic_handle *handle, struct slogic_record } if (internal_recording->recording->recording_state != COMPLETED_SUCCESSFULLY) { - fprintf(recording->debug_file, "FAIL! recording_state=%d\n", internal_recording->recording->recording_state); + fprintf(recording->debug_file, "FAIL! recording_state=%d\n", + internal_recording->recording->recording_state); } else { fprintf(recording->debug_file, "SUCCESS!\n"); } @@ -441,7 +443,7 @@ void slogic_execute_recording(struct slogic_handle *handle, struct slogic_record int sec = end.tv_sec - start.tv_sec; int usec = (end.tv_usec - start.tv_usec) / 1000; - if(usec < 0) { + if (usec < 0) { sec--; usec = 1 - usec; } diff --git a/slogic.h b/slogic.h index 1cc7187..8bf81bc 100644 --- a/slogic.h +++ b/slogic.h @@ -45,7 +45,7 @@ enum slogic_recording_state { * - Trygve */ -void slogic_available_sample_rates(struct slogic_sample_rate **sample_rates_out, size_t *size); +void slogic_available_sample_rates(struct slogic_sample_rate **sample_rates_out, size_t * size); struct slogic_sample_rate *slogic_parse_sample_rate(const char *str); @@ -66,13 +66,13 @@ void slogic_close(struct slogic_handle *handle); * struct slogic_tunable with a set of unions for each tunable. */ void slogic_tune(struct slogic_handle *handle, - FILE *debug_file, + FILE * debug_file, size_t transfer_buffer_size, unsigned int n_transfer_buffers, unsigned int transfer_timeout, int libusb_debug_level); int slogic_readbyte(struct slogic_handle *handle, unsigned char *out); -typedef bool(*slogic_on_data_callback) (uint8_t *data, size_t size, void *user_data); +typedef bool(*slogic_on_data_callback) (uint8_t * data, size_t size, void *user_data); struct slogic_recording { struct slogic_sample_rate *sample_rate; diff --git a/usbutil.c b/usbutil.c index e0c2729..5d62777 100644 --- a/usbutil.c +++ b/usbutil.c @@ -7,7 +7,7 @@ * Data structure debugging. */ -static void dump_endpoint_descriptor(FILE *file, int i, const struct libusb_endpoint_descriptor *endpoint_descriptor) +static void dump_endpoint_descriptor(FILE * file, int i, const struct libusb_endpoint_descriptor *endpoint_descriptor) { char *direction = ((endpoint_descriptor->bEndpointAddress & 0x80) == LIBUSB_ENDPOINT_IN) ? "in" : "out"; @@ -20,7 +20,7 @@ static void dump_endpoint_descriptor(FILE *file, int i, const struct libusb_endp fprintf(file, " Sync address: %d\n", endpoint_descriptor->bSynchAddress); } -static void dump_interface(FILE *file, int i, const struct libusb_interface *interface) +static void dump_interface(FILE * file, int i, const struct libusb_interface *interface) { fprintf(file, " Interface #%d: Descriptors: (%d)\n", i, interface->num_altsetting); const struct libusb_interface_descriptor *interface_descriptor = interface->altsetting; @@ -39,7 +39,7 @@ static void dump_interface(FILE *file, int i, const struct libusb_interface *int } } -void usbutil_dump_config_descriptor(FILE *file, struct libusb_config_descriptor *config_descriptor) +void usbutil_dump_config_descriptor(FILE * file, struct libusb_config_descriptor *config_descriptor) { /* TODO: Decode bytes to strings */ fprintf(file, "Configuration descriptor:\n"); @@ -53,7 +53,7 @@ void usbutil_dump_config_descriptor(FILE *file, struct libusb_config_descriptor } } -void usbutil_dump_device_descriptor(FILE *file, struct libusb_device_descriptor *device_descriptor) +void usbutil_dump_device_descriptor(FILE * file, struct libusb_device_descriptor *device_descriptor) { /* TODO: Decode bytes to strings */ fprintf(file, "Device descriptor:\n"); @@ -72,7 +72,7 @@ void usbutil_dump_device_descriptor(FILE *file, struct libusb_device_descriptor /* * This method looks if the kernel already has a driver attached to the device. if so I will take over the device. */ -static enum libusb_error claim_device(libusb_device_handle *dev, int interface) +static enum libusb_error claim_device(libusb_device_handle * dev, int interface) { enum libusb_error err; if (libusb_kernel_driver_active(dev, interface)) { @@ -109,7 +109,7 @@ static enum libusb_error claim_device(libusb_device_handle *dev, int interface) * Iterates over the usb devices on the usb busses and returns a handle to the * first device found that matches the predefined vendor and product id */ -libusb_device_handle *open_device(libusb_context *ctx, int vendor_id, int product_id) +libusb_device_handle *open_device(libusb_context * ctx, int vendor_id, int product_id) { // discover devices libusb_device **list; diff --git a/usbutil.h b/usbutil.h index 630a81d..74097eb 100644 --- a/usbutil.h +++ b/usbutil.h @@ -5,7 +5,7 @@ * Iterates over the usb devices on the usb busses and returns a handle to the * first device found that matches the predefined vendor and product id */ -libusb_device_handle *open_device(libusb_context *ctx, int vendor_id, int product_id); +libusb_device_handle *open_device(libusb_context * ctx, int vendor_id, int product_id); const char *libusb_transfer_status_to_string(enum libusb_transfer_status transfer_status);