From f0f54487c6a146af523d6eb19fcce63422e3f0f1 Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Fri, 20 Mar 2015 19:38:33 +0100 Subject: [PATCH] Minor cosmetics, whitespace- and consistency fixes. --- anykey.c | 1 + decode.c | 18 ++++++++---------- device.c | 1 - input.c | 7 +++---- options.c | 12 ++++++++---- parsers.c | 7 ++++--- session.c | 19 ++++++++++++------- show.c | 14 +++++++++----- sigrok-cli.h | 2 +- 9 files changed, 46 insertions(+), 35 deletions(-) diff --git a/anykey.c b/anykey.c index 4126518..8933586 100644 --- a/anykey.c +++ b/anykey.c @@ -38,6 +38,7 @@ static struct termios term_orig; static int received_anykey(int fd, int revents, void *cb_data) { struct sr_session *session; + (void)fd; (void)revents; diff --git a/decode.c b/decode.c index 2e831f7..09b43f9 100644 --- a/decode.c +++ b/decode.c @@ -17,10 +17,10 @@ * along with this program. If not, see . */ -#include -#include #include "sigrok-cli.h" #include "config.h" +#include +#include #include #ifdef HAVE_SRD @@ -109,7 +109,8 @@ static GHashTable *extract_channel_map(struct srd_decoder *dec, GHashTable *hash return channel_map; } -/* Register the given PDs for this session. +/* + * Register the given PDs for this session. * Accepts a string of the form: "spi:sck=3:sdata=4,spi:sck=3:sdata=5" * That will instantiate two SPI decoders on the clock but different data * lines. @@ -180,7 +181,8 @@ int register_pds(const char *opt_pds, char *opt_pd_annotations) channels = NULL; } - /* If no annotation list was specified, add them all in now. + /* + * If no annotation list was specified, add them all in now. * This will be pared down later to leave only the last PD * in the stack. */ @@ -305,7 +307,8 @@ int setup_pd_stack(char *opt_pds, char *opt_pd_stack, char *opt_pd_annotations) if ((ret = srd_inst_stack(srd_sess, di_from, di_to)) != SRD_OK) return 1; - /* Don't show annotation from this PD. Only the last PD in + /* + * Don't show annotation from this PD. Only the last PD in * the stack will be left on the annotation list (unless * the annotation list was specifically provided). */ @@ -453,7 +456,6 @@ void show_pd_annotations(struct srd_proto_data *pdata, void *cb_data) char **ann_descr; gboolean show; - /* 'cb_data' is not used in this specific callback. */ (void)cb_data; if (!pd_ann_visible) @@ -500,8 +502,6 @@ void show_pd_annotations(struct srd_proto_data *pdata, void *cb_data) void show_pd_meta(struct srd_proto_data *pdata, void *cb_data) { - - /* 'cb_data' is not used in this specific callback. */ (void)cb_data; if (!g_hash_table_lookup_extended(pd_meta_visible, @@ -523,7 +523,6 @@ void show_pd_binary(struct srd_proto_data *pdata, void *cb_data) gpointer classp; int class; - /* 'cb_data' is not used in this specific callback. */ (void)cb_data; if (!g_hash_table_lookup_extended(pd_binary_visible, @@ -542,4 +541,3 @@ void show_pd_binary(struct srd_proto_data *pdata, void *cb_data) fflush(stdout); } #endif - diff --git a/device.c b/device.c index 2a5d14a..48646b5 100644 --- a/device.c +++ b/device.c @@ -86,4 +86,3 @@ struct sr_channel_group *select_channel_group(struct sr_dev_inst *sdi) return NULL; } - diff --git a/input.c b/input.c index 4f51e11..9d7bf62 100644 --- a/input.c +++ b/input.c @@ -28,7 +28,7 @@ #include #include -#define BUFSIZE 16384 +#define BUFSIZE (16 * 1024) static void load_input_file_module(void) { @@ -111,7 +111,7 @@ static void load_input_file_module(void) sr_session_datafeed_callback_add(session, &datafeed_in, NULL); got_sdi = FALSE; - while(TRUE) { + while (TRUE) { g_string_truncate(buf, 0); len = read(fd, buf->str, BUFSIZE); if (len < 0) @@ -124,7 +124,7 @@ static void load_input_file_module(void) break; sdi = sr_input_dev_inst_get(in); - if(!got_sdi && sdi) { + if (!got_sdi && sdi) { /* First time we got a valid sdi. */ if (select_channels(sdi) != SR_OK) return; @@ -135,7 +135,6 @@ static void load_input_file_module(void) } got_sdi = TRUE; } - } sr_input_end(in); sr_input_free(in); diff --git a/options.c b/options.c index 9a0bce6..32787e5 100644 --- a/options.c +++ b/options.c @@ -49,8 +49,10 @@ gchar *opt_continuous = NULL; gchar *opt_get = NULL; gchar *opt_set = NULL; -/* defines a callback function that generates - an error if an option occurs twice */ +/* + * Defines a callback function that generates an error if an + * option occurs twice. + */ #define CHECK_ONCE(option) \ static gboolean check_ ## option \ (const gchar *option_name, const gchar *value, \ @@ -151,8 +153,10 @@ static const GOptionEntry optargs[] = { {NULL, 0, 0, 0, NULL, NULL, NULL} }; -/* Parses the command line and sets all the 'opt_...' variables. - Returns zero on success, non-zero otherwise. */ +/* + * Parses the command line and sets all the 'opt_...' variables. + * Returns zero on success, non-zero otherwise. + */ int parse_options(int argc, char **argv) { GError *error = NULL; diff --git a/parsers.c b/parsers.c index 35545e0..f0e2a7f 100644 --- a/parsers.c +++ b/parsers.c @@ -67,10 +67,12 @@ GSList *parse_channelstring(struct sr_dev_inst *sdi, const char *channelstring) break; } if (strchr(tokens[i], '-')) { - /* A range of channels in the form a-b. This will only work + /* + * A range of channels in the form a-b. This will only work * if the channels are named as numbers -- so every channel * in the range must exist as a channel name string in the - * device. */ + * device. + */ range = g_strsplit(tokens[i], "-", 2); if (!range[0] || !range[1] || range[2]) { /* Need exactly two arguments. */ @@ -447,4 +449,3 @@ int parse_driver(char *arg, struct sr_dev_driver **driver, GSList **drvopts) return TRUE; } - diff --git a/session.c b/session.c index 090fdce..aa30266 100644 --- a/session.c +++ b/session.c @@ -308,8 +308,10 @@ void datafeed_in(const struct sr_dev_inst *sdi, if (!out || (out->len == 0 && !opt_output_format && packet->type == SR_DF_ANALOG)) { - /* The user didn't specify an output module, - * but needs to see this analog data. */ + /* + * The user didn't specify an output module, + * but needs to see this analog data. + */ sr_output_send(oa, packet, &out); } if (out && out->len > 0) { @@ -321,8 +323,10 @@ void datafeed_in(const struct sr_dev_inst *sdi, } } - /* SR_DF_END needs to be handled after the output module's receive() - * is called, so it can properly clean up that module. */ + /* + * SR_DF_END needs to be handled after the output module's receive() + * is called, so it can properly clean up that module. + */ if (packet->type == SR_DF_END) { g_debug("cli: Received SR_DF_END."); @@ -611,8 +615,10 @@ void run_session(void) } if (maybe_config_list(driver, sdi, NULL, SR_CONF_LIMIT_SAMPLES, &gvar) == SR_OK) { - /* The device has no compression, or compression is turned - * off, and publishes its sample memory size. */ + /* + * The device has no compression, or compression is turned + * off, and publishes its sample memory size. + */ g_variant_get(gvar, "(tt)", &min_samples, &max_samples); g_variant_unref(gvar); if (limit_samples < min_samples) { @@ -667,4 +673,3 @@ void run_session(void) sr_session_destroy(session); } - diff --git a/show.c b/show.c index d43c716..f0dbbf4 100644 --- a/show.c +++ b/show.c @@ -308,8 +308,10 @@ void show_dev_detail(void) return; } - /* Selected channels and channel group may affect which options are - * returned, or which values for them. */ + /* + * Selected channels and channel group may affect which options are + * returned, or which values for them. + */ select_channels(sdi); channel_group = select_channel_group(sdi); @@ -356,7 +358,7 @@ void show_dev_detail(void) &num_elements, sizeof(int32_t)); printf(" Supported triggers: "); for (i = 0; i < num_elements; i++) { - switch(int32[i]) { + switch (int32[i]) { case SR_TRIGGER_ZERO: c = '0'; break; @@ -390,12 +392,14 @@ void show_dev_detail(void) } else if (key == SR_CONF_LIMIT_SAMPLES && config_key_has_cap(driver, sdi, NULL, key, SR_CONF_LIST)) { - /* If implemented in config_list(), this denotes the + /* + * If implemented in config_list(), this denotes the * maximum number of samples a device can send. This * really applies only to logic analyzers, and then * only to those that don't support compression, or * have it turned off by default. The values returned - * are the low/high limits. */ + * are the low/high limits. + */ if (sr_config_list(driver, sdi, channel_group, key, &gvar) == SR_OK) { g_variant_get(gvar, "(tt)", &low, &high); diff --git a/sigrok-cli.h b/sigrok-cli.h index 897d5b4..d7b9d9c 100644 --- a/sigrok-cli.h +++ b/sigrok-cli.h @@ -28,7 +28,7 @@ #include #define DEFAULT_OUTPUT_FORMAT "bits:width=64" -#define SAVE_CHUNK_SIZE 524288 +#define SAVE_CHUNK_SIZE (512 * 1024) /* main.c */ int select_channels(struct sr_dev_inst *sdi); -- 2.30.2