From 6433156c3275df933e4bf6dcfb020c91fca0ae86 Mon Sep 17 00:00:00 2001 From: Daniel Elstner Date: Sun, 13 Sep 2015 02:29:38 +0200 Subject: [PATCH] Fix log varargs bugs indicated by -Wformat A few of these were pretty serious, like missing arguments, passing integers where a string was expected, and so on. In some places, change the types used by the code rather than just the format strings. --- src/dmm/fs9922.c | 4 +- src/dmm/vc870.c | 5 ++- src/hardware/baylibre-acme/api.c | 2 +- src/hardware/baylibre-acme/gpio.c | 2 +- src/hardware/baylibre-acme/protocol.c | 2 +- src/hardware/brymen-bm86x/protocol.c | 2 +- src/hardware/brymen-dmm/protocol.c | 10 +++-- src/hardware/fx2lafw/dslogic.c | 7 ++-- src/hardware/gmc-mh-1x-2x/protocol.c | 6 +-- src/hardware/hantek-dso/api.c | 2 +- src/hardware/hung-chang-dso-2100/protocol.c | 2 +- src/hardware/motech-lps-30x/protocol.c | 5 ++- src/hardware/pipistrello-ols/api.c | 2 +- src/hardware/pipistrello-ols/protocol.c | 8 +++- src/hardware/rigol-ds/protocol.c | 3 +- src/hardware/saleae-logic16/protocol.c | 4 +- src/hwdriver.c | 2 +- src/input/csv.c | 42 ++++++++++----------- src/input/input.c | 12 ++++-- src/output/output.c | 6 ++- src/scpi/scpi.c | 6 +-- src/scpi/scpi_tcp.c | 2 +- src/scpi/scpi_vxi.c | 8 ++-- src/serial.c | 14 +++---- src/transform/transform.c | 6 ++- 25 files changed, 92 insertions(+), 72 deletions(-) diff --git a/src/dmm/fs9922.c b/src/dmm/fs9922.c index 698e1184..d2f6c6bf 100644 --- a/src/dmm/fs9922.c +++ b/src/dmm/fs9922.c @@ -112,7 +112,9 @@ static int parse_value(const uint8_t *buf, float *result) } else if (!isdigit(buf[1]) || !isdigit(buf[2]) || !isdigit(buf[3]) || !isdigit(buf[4])) { sr_dbg("Value contained invalid digits: %02x %02x %02x %02x (" - "%c %c %c %c).", buf[1], buf[2], buf[3], buf[4]); + "%c %c %c %c).", + buf[1], buf[2], buf[3], buf[4], + buf[1], buf[2], buf[3], buf[4]); return SR_ERR; } intval = 0; diff --git a/src/dmm/vc870.c b/src/dmm/vc870.c index 8b7f191f..c50e24d7 100644 --- a/src/dmm/vc870.c +++ b/src/dmm/vc870.c @@ -70,8 +70,9 @@ static int parse_value(const uint8_t *buf, struct vc870_info *info, } else if (!isdigit(buf[3]) || !isdigit(buf[4]) || !isdigit(buf[5]) || !isdigit(buf[6]) || !isdigit(buf[7])) { sr_dbg("Invalid digits: %02x %02x %02x %02x %02X " - "(%c %c %c %c %c).", buf[3], buf[4], buf[5], buf[6], - buf[7]); + "(%c %c %c %c %c).", + buf[3], buf[4], buf[5], buf[6], buf[7], + buf[3], buf[4], buf[5], buf[6], buf[7]); return SR_ERR; } diff --git a/src/hardware/baylibre-acme/api.c b/src/hardware/baylibre-acme/api.c index b1884b62..6b3b43e4 100644 --- a/src/hardware/baylibre-acme/api.c +++ b/src/hardware/baylibre-acme/api.c @@ -421,7 +421,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) sr_session_send(sdi, &packet); if (devc->samples_missed > 0) - sr_warn("%d samples missed", devc->samples_missed); + sr_warn("%" PRIu64 " samples missed", devc->samples_missed); return SR_OK; } diff --git a/src/hardware/baylibre-acme/gpio.c b/src/hardware/baylibre-acme/gpio.c index c2e6da9d..93daff7b 100644 --- a/src/hardware/baylibre-acme/gpio.c +++ b/src/hardware/baylibre-acme/gpio.c @@ -125,7 +125,7 @@ SR_PRIV int sr_gpio_get_value(int gpio) status = fscanf(fd, "%d", &ret); fclose(fd); if (status != 1) { - sr_err("Error reading from %s: %s", path, g_strerror(errno)); + sr_err("Error reading from %s: %s", path->str, g_strerror(errno)); g_string_free(path, TRUE); return -1; } diff --git a/src/hardware/baylibre-acme/protocol.c b/src/hardware/baylibre-acme/protocol.c index a50c2219..cba1f7c0 100644 --- a/src/hardware/baylibre-acme/protocol.c +++ b/src/hardware/baylibre-acme/protocol.c @@ -507,7 +507,7 @@ static float read_sample(struct sr_channel *ch) len = read(fd, buf, sizeof(buf)); if (len < 0) { - sr_err("Error reading from channel %s (hwmon: %s): %s", + sr_err("Error reading from channel %s (hwmon: %d): %s", ch->name, chp->probe->hwmon_num, g_strerror(errno)); ch->enabled = FALSE; return -1.0; diff --git a/src/hardware/brymen-bm86x/protocol.c b/src/hardware/brymen-bm86x/protocol.c index 4de8a74c..74101518 100644 --- a/src/hardware/brymen-bm86x/protocol.c +++ b/src/hardware/brymen-bm86x/protocol.c @@ -293,7 +293,7 @@ static int brymen_bm86x_read_interrupt(const struct sr_dev_inst *sdi) } if (transferred != sizeof(buf)) { - sr_err("Short packet: received %d/%d bytes.", transferred, sizeof(buf)); + sr_err("Short packet: received %d/%zu bytes.", transferred, sizeof(buf)); return SR_ERR; } diff --git a/src/hardware/brymen-dmm/protocol.c b/src/hardware/brymen-dmm/protocol.c index 5fb5ec29..02e14d31 100644 --- a/src/hardware/brymen-dmm/protocol.c +++ b/src/hardware/brymen-dmm/protocol.c @@ -179,7 +179,9 @@ SR_PRIV int brymen_stream_detect(struct sr_serial_dev_inst *serial, { int64_t start, time, byte_delay_us; size_t ibuf, i, maxlen; - int status, len, packet_len, stream_len; + ssize_t len, stream_len; + int packet_len; + int status; maxlen = *buflen; @@ -195,7 +197,7 @@ SR_PRIV int brymen_stream_detect(struct sr_serial_dev_inst *serial, len = serial_read_nonblocking(serial, &buf[ibuf], maxlen - ibuf); if (len > 0) { ibuf += len; - sr_spew("Read %d bytes.", len); + sr_spew("Read %zd bytes.", len); } time = g_get_monotonic_time() - start; @@ -247,14 +249,14 @@ SR_PRIV int brymen_stream_detect(struct sr_serial_dev_inst *serial, if (time >= (int64_t)timeout_ms) { /* Timeout */ - sr_dbg("Detection timed out after %dms.", time); + sr_dbg("Detection timed out after %" PRIi64 "ms.", time); break; } g_usleep(byte_delay_us); } *buflen = ibuf; - sr_err("Didn't find a valid packet (read %d bytes).", ibuf); + sr_err("Didn't find a valid packet (read %zu bytes).", ibuf); return SR_ERR; } diff --git a/src/hardware/fx2lafw/dslogic.c b/src/hardware/fx2lafw/dslogic.c index b1cbac09..5d543ada 100644 --- a/src/hardware/fx2lafw/dslogic.c +++ b/src/hardware/fx2lafw/dslogic.c @@ -38,7 +38,7 @@ int dslogic_fpga_firmware_upload(const struct sr_dev_inst *sdi, const char *filename) { FILE *fw; - struct stat st; + GStatBuf st; struct sr_usb_dev_inst *usb; int chunksize, result, ret; unsigned char *buf; @@ -48,7 +48,7 @@ int dslogic_fpga_firmware_upload(const struct sr_dev_inst *sdi, sr_dbg("Uploading FPGA firmware at %s.", filename); usb = sdi->conn; - if (stat(filename, &st) < 0) { + if (g_stat(filename, &st) < 0) { sr_err("Unable to upload FPGA firmware: %s", g_strerror(errno)); return SR_ERR; } @@ -85,7 +85,8 @@ int dslogic_fpga_firmware_upload(const struct sr_dev_inst *sdi, break; } sum += transferred; - sr_spew("Uploaded %d/%d bytes.", sum, st.st_size); + sr_spew("Uploaded %d/%" PRIu64 " bytes.", + sum, (uint64_t)st.st_size); if (transferred != chunksize) { sr_err("Short transfer while uploading FPGA firmware."); diff --git a/src/hardware/gmc-mh-1x-2x/protocol.c b/src/hardware/gmc-mh-1x-2x/protocol.c index 63ed2572..6cd8694f 100644 --- a/src/hardware/gmc-mh-1x-2x/protocol.c +++ b/src/hardware/gmc-mh-1x-2x/protocol.c @@ -856,7 +856,7 @@ static void process_msg_inf_13(struct sr_dev_inst *sdi) devc->value += pow(10.0, cnt) * dgt; } sr_spew("process_msg_inf_13() value=%f scale=%f scale1000=%d mq=%d " - "unit=%d mqflags=0x%02llx", devc->value, devc->scale, + "unit=%d mqflags=0x%02" PRIx64, devc->value, devc->scale, devc->scale1000, devc->mq, devc->unit, devc->mqflags); if (devc->value != NAN) devc->value *= devc->scale * pow(1000.0, devc->scale1000); @@ -1002,7 +1002,7 @@ SR_PRIV int process_msg14(struct sr_dev_inst *sdi) sr_spew("Cmd %d unimplemented!", devc->buf[3]); break; case 3: /* Read firmware version and status */ - sr_spew("Cmd 3, Read firmware and status", devc->buf[3]); + sr_spew("Cmd 3, Read firmware and status"); switch (devc->cmd_idx) { case 0: devc->fw_ver_maj = devc->buf[5]; @@ -1073,7 +1073,7 @@ SR_PRIV int process_msg14(struct sr_dev_inst *sdi) devc->value += pow(10.0, cnt) * dgt; } sr_spew("process_msg14() value=%f scale=%f scale1000=%d mq=%d " - "unit=%d mqflags=0x%02llx", devc->value, devc->scale, + "unit=%d mqflags=0x%02" PRIx64, devc->value, devc->scale, devc->scale1000, devc->mq, devc->unit, devc->mqflags); if (devc->value != NAN) devc->value *= devc->scale * pow(1000.0, devc->scale1000); diff --git a/src/hardware/hantek-dso/api.c b/src/hardware/hantek-dso/api.c index b871ddaf..90706065 100644 --- a/src/hardware/hantek-dso/api.c +++ b/src/hardware/hantek-dso/api.c @@ -394,7 +394,7 @@ static int dev_open(struct sr_dev_inst *sdi) timediff_ms = timediff_us / 1000; sr_spew("Waited %" PRIi64 " ms.", timediff_ms); } - sr_info("Device came back after %d ms.", timediff_ms); + sr_info("Device came back after %" PRIi64 " ms.", timediff_ms); } else { err = dso_open(sdi); } diff --git a/src/hardware/hung-chang-dso-2100/protocol.c b/src/hardware/hung-chang-dso-2100/protocol.c index 6f997db0..022fac7e 100644 --- a/src/hardware/hung-chang-dso-2100/protocol.c +++ b/src/hardware/hung-chang-dso-2100/protocol.c @@ -434,7 +434,7 @@ SR_PRIV int hung_chang_dso_2100_poll(int fd, int revents, void *cb_data) return TRUE; if (state != 0x03) { - sr_err("Unexpected state 0x%X while checking for trigger"); + sr_err("Unexpected state 0x%X while checking for trigger", state); return FALSE; } diff --git a/src/hardware/motech-lps-30x/protocol.c b/src/hardware/motech-lps-30x/protocol.c index 751d2d26..c7f65e10 100644 --- a/src/hardware/motech-lps-30x/protocol.c +++ b/src/hardware/motech-lps-30x/protocol.c @@ -193,9 +193,10 @@ SR_PRIV int motech_lps_30x_receive_data(int fd, int revents, void *cb_data) return TRUE; if (devc->acq_req_pending) { - gint64 elapsed_us = g_get_monotonic_time() - devc->req_sent_at; + int64_t elapsed_us = g_get_monotonic_time() - devc->req_sent_at; if (elapsed_us > (REQ_TIMEOUT_MS * 1000)) { - sr_spew("Request timeout: req=%d t=%lldus", (int)devc->acq_req, elapsed_us); + sr_spew("Request timeout: req=%d t=%" PRIi64 "us", + (int)devc->acq_req, elapsed_us); devc->acq_req_pending = 0; } } diff --git a/src/hardware/pipistrello-ols/api.c b/src/hardware/pipistrello-ols/api.c index 03cda60b..c5c53ce8 100644 --- a/src/hardware/pipistrello-ols/api.c +++ b/src/hardware/pipistrello-ols/api.c @@ -576,7 +576,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, * buffer. */ sr_dbg("max_samples = %d", devc->max_samples); - sr_dbg("limit_samples = %d", devc->limit_samples); + sr_dbg("limit_samples = %" PRIu64, devc->limit_samples); samplecount = MIN(devc->max_samples, devc->limit_samples); sr_dbg("Samplecount = %d", samplecount); diff --git a/src/hardware/pipistrello-ols/protocol.c b/src/hardware/pipistrello-ols/protocol.c index ec588b41..3db3aa4b 100644 --- a/src/hardware/pipistrello-ols/protocol.c +++ b/src/hardware/pipistrello-ols/protocol.c @@ -505,7 +505,9 @@ SR_PRIV int p_ols_receive_data(int fd, int revents, void *cb_data) } /* Clear out the most significant bit of the sample */ devc->tmp_sample[devc->num_bytes - 1] &= 0x7f; - sr_spew("Expanded sample 1: 0x%.8x.", devc->tmp_sample); + sr_spew("Expanded sample 1: 0x%.2x%.2x%.2x%.2x.", + devc->tmp_sample[3], devc->tmp_sample[2], + devc->tmp_sample[1], devc->tmp_sample[0]); /* expand second sample */ memset(devc->tmp_sample2, 0, 4); @@ -521,7 +523,9 @@ SR_PRIV int p_ols_receive_data(int fd, int revents, void *cb_data) } /* Clear out the most significant bit of the sample */ devc->tmp_sample2[devc->num_bytes - 1] &= 0x7f; - sr_spew("Expanded sample 2: 0x%.8x.", devc->tmp_sample2); + sr_spew("Expanded sample 2: 0x%.2x%.2x%.2x%.2x.", + devc->tmp_sample2[3], devc->tmp_sample2[2], + devc->tmp_sample2[1], devc->tmp_sample2[0]); /* * OLS sends its sample buffer backwards. diff --git a/src/hardware/rigol-ds/protocol.c b/src/hardware/rigol-ds/protocol.c index 35ec6184..06dc1a3e 100644 --- a/src/hardware/rigol-ds/protocol.c +++ b/src/hardware/rigol-ds/protocol.c @@ -712,7 +712,8 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data) } devc->num_block_read = 0; } else { - sr_dbg("%d of %d block bytes read", devc->num_block_read, devc->num_block_bytes); + sr_dbg("%" PRIu64 " of %" PRIu64 " block bytes read", + devc->num_block_read, devc->num_block_bytes); } devc->num_channel_bytes += len; diff --git a/src/hardware/saleae-logic16/protocol.c b/src/hardware/saleae-logic16/protocol.c index 5e43c3bd..6858215c 100644 --- a/src/hardware/saleae-logic16/protocol.c +++ b/src/hardware/saleae-logic16/protocol.c @@ -214,7 +214,7 @@ static int do_ep1_command(const struct sr_dev_inst *sdi, } if (xfer != cmd_len) { sr_dbg("Failed to send EP1 command 0x%02x: incorrect length " - "%d != %d.", xfer, cmd_len); + "%d != %d.", command[0], xfer, cmd_len); return SR_ERR; } @@ -230,7 +230,7 @@ static int do_ep1_command(const struct sr_dev_inst *sdi, } if (xfer != reply_len) { sr_dbg("Failed to receive reply to EP1 command 0x%02x: " - "incorrect length %d != %d.", xfer, reply_len); + "incorrect length %d != %d.", command[0], xfer, reply_len); return SR_ERR; } diff --git a/src/hwdriver.c b/src/hwdriver.c index fe8ac457..0700276c 100644 --- a/src/hwdriver.c +++ b/src/hwdriver.c @@ -602,7 +602,7 @@ static int check_key(const struct sr_dev_driver *driver, if (sr_config_list(driver, sdi, cg, SR_CONF_DEVICE_OPTIONS, &gvar_opts) != SR_OK) { /* Driver publishes no options. */ - sr_err("No options available%s.", srci->id, suffix); + sr_err("No options available%s.", suffix); return SR_ERR_ARG; } opts = g_variant_get_fixed_array(gvar_opts, &num_opts, sizeof(uint32_t)); diff --git a/src/input/csv.c b/src/input/csv.c index cc09045a..0a2d7276 100644 --- a/src/input/csv.c +++ b/src/input/csv.c @@ -80,7 +80,7 @@ struct context { uint64_t samplerate; /* Number of channels. */ - gsize num_channels; + unsigned int num_channels; /* Column delimiter character(s). */ GString *delimiter; @@ -95,23 +95,23 @@ struct context { gboolean multi_column_mode; /* Column number of the sample data in single column mode. */ - gsize single_column; + unsigned int single_column; /* * Number of the first column to parse. Equivalent to the number of the * first channel in multi column mode and the single column number in * single column mode. */ - gsize first_column; + unsigned int first_column; /* * Column number of the first channel in multi column mode and position of * the bit for the first channel in single column mode. */ - gsize first_channel; + unsigned int first_channel; /* Line number to start processing. */ - gsize start_line; + size_t start_line; /* * Determines if the first line should be treated as header and used for @@ -123,13 +123,13 @@ struct context { int format; /* Size of the sample buffer. */ - gsize sample_buffer_size; + size_t sample_buffer_size; /* Buffer to store sample data. */ uint8_t *sample_buffer; /* Current line number. */ - gsize line_number; + size_t line_number; }; static int format_match(GHashTable *metadata) @@ -161,7 +161,7 @@ static int parse_binstr(const char *str, struct context *inc) length = strlen(str); if (!length) { - sr_err("Column %zu in line %zu is empty.", inc->single_column, + sr_err("Column %u in line %zu is empty.", inc->single_column, inc->line_number); return SR_ERR; } @@ -175,7 +175,7 @@ static int parse_binstr(const char *str, struct context *inc) if (str[length - i - 1] == '1') { inc->sample_buffer[j / 8] |= (1 << (j % 8)); } else if (str[length - i - 1] != '0') { - sr_err("Invalid value '%s' in column %zu in line %zu.", + sr_err("Invalid value '%s' in column %u in line %zu.", str, inc->single_column, inc->line_number); return SR_ERR; } @@ -193,7 +193,7 @@ static int parse_hexstr(const char *str, struct context *inc) length = strlen(str); if (!length) { - sr_err("Column %zu in line %zu is empty.", inc->single_column, + sr_err("Column %u in line %zu is empty.", inc->single_column, inc->line_number); return SR_ERR; } @@ -208,7 +208,7 @@ static int parse_hexstr(const char *str, struct context *inc) c = str[length - i - 1]; if (!g_ascii_isxdigit(c)) { - sr_err("Invalid value '%s' in column %zu in line %zu.", + sr_err("Invalid value '%s' in column %u in line %zu.", str, inc->single_column, inc->line_number); return SR_ERR; } @@ -237,7 +237,7 @@ static int parse_octstr(const char *str, struct context *inc) length = strlen(str); if (!length) { - sr_err("Column %zu in line %zu is empty.", inc->single_column, + sr_err("Column %u in line %zu is empty.", inc->single_column, inc->line_number); return SR_ERR; } @@ -252,7 +252,7 @@ static int parse_octstr(const char *str, struct context *inc) c = str[length - i - 1]; if (c < '0' || c > '7') { - sr_err("Invalid value '%s' in column %zu in line %zu.", + sr_err("Invalid value '%s' in column %u in line %zu.", str, inc->single_column, inc->line_number); return SR_ERR; } @@ -437,7 +437,7 @@ static int init(struct sr_input *in, GHashTable *options) inc->start_line = g_variant_get_int32(g_hash_table_lookup(options, "startline")); if (inc->start_line < 1) { - sr_err("Invalid start line %d.", inc->start_line); + sr_err("Invalid start line %zu.", inc->start_line); return SR_ERR_ARG; } @@ -473,8 +473,8 @@ static int initial_parse(const struct sr_input *in, GString *buf) { struct context *inc; GString *channel_name; - gsize num_columns, l, i; - unsigned int line_number; + unsigned int num_columns, i; + size_t line_number, l; int ret; char **lines, **columns; @@ -522,7 +522,7 @@ static int initial_parse(const struct sr_input *in, GString *buf) /* Ensure that the first column is not out of bounds. */ if (!num_columns) { - sr_err("Column %zu in line %zu is out of bounds.", + sr_err("Column %u in line %zu is out of bounds.", inc->first_column, line_number); ret = SR_ERR; goto out; @@ -535,7 +535,7 @@ static int initial_parse(const struct sr_input *in, GString *buf) */ if (!inc->num_channels) { inc->num_channels = num_columns; - sr_dbg("Number of auto-detected channels: %zu.", + sr_dbg("Number of auto-detected channels: %u.", inc->num_channels); } @@ -553,10 +553,10 @@ static int initial_parse(const struct sr_input *in, GString *buf) channel_name = g_string_sized_new(64); for (i = 0; i < inc->num_channels; i++) { - if (inc->header && inc->multi_column_mode && strlen(columns[i])) + if (inc->header && inc->multi_column_mode && columns[i][0] != '\0') g_string_assign(channel_name, columns[i]); else - g_string_printf(channel_name, "%zu", i); + g_string_printf(channel_name, "%u", i); sr_channel_new(in->sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_name->str); } g_string_free(channel_name, TRUE); @@ -679,7 +679,7 @@ static int process_buffer(struct sr_input *in) } num_columns = g_strv_length(columns); if (!num_columns) { - sr_err("Column %zu in line %zu is out of bounds.", + sr_err("Column %u in line %zu is out of bounds.", inc->first_column, inc->line_number); g_strfreev(columns); return SR_ERR; diff --git a/src/input/input.c b/src/input/input.c index 71604658..9bae0970 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -263,7 +263,8 @@ SR_API struct sr_input *sr_input_new(const struct sr_input_module *imod, /* Option not given: insert the default value. */ gvt = g_variant_get_type(mod_opts[i].def); if (!g_variant_is_of_type(value, gvt)) { - sr_err("Invalid type for '%s' option.", key); + sr_err("Invalid type for '%s' option.", + (char *)key); g_free(in); return NULL; } @@ -281,7 +282,8 @@ SR_API struct sr_input *sr_input_new(const struct sr_input_module *imod, g_hash_table_iter_init(&iter, options); while (g_hash_table_iter_next(&iter, &key, &value)) { if (!g_hash_table_lookup(new_opts, key)) { - sr_err("Input module '%s' has no option '%s'", imod->id, key); + sr_err("Input module '%s' has no option '%s'", + imod->id, (char *)key); g_hash_table_destroy(new_opts); g_free(in); return NULL; @@ -549,7 +551,8 @@ SR_API struct sr_dev_inst *sr_input_dev_inst_get(const struct sr_input *in) */ SR_API int sr_input_send(const struct sr_input *in, GString *buf) { - sr_spew("Sending %d bytes to %s module.", buf->len, in->module->id); + sr_spew("Sending %" G_GSIZE_FORMAT " bytes to %s module.", + buf->len, in->module->id); return in->module->receive((struct sr_input *)in, buf); } @@ -583,7 +586,8 @@ SR_API void sr_input_free(const struct sr_input *in) sr_dev_inst_free(in->sdi); if (in->buf->len > 64) { /* That seems more than just some sub-unitsize leftover... */ - sr_warn("Found %d unprocessed bytes at free time.", in->buf->len); + sr_warn("Found %" G_GSIZE_FORMAT + " unprocessed bytes at free time.", in->buf->len); } g_string_free(in->buf, TRUE); g_free(in->priv); diff --git a/src/output/output.c b/src/output/output.c index 0a9e7f88..df22b222 100644 --- a/src/output/output.c +++ b/src/output/output.c @@ -283,7 +283,8 @@ SR_API const struct sr_output *sr_output_new(const struct sr_output_module *omod /* Pass option along. */ gvt = g_variant_get_type(mod_opts[i].def); if (!g_variant_is_of_type(value, gvt)) { - sr_err("Invalid type for '%s' option.", key); + sr_err("Invalid type for '%s' option.", + (char *)key); g_free(op); return NULL; } @@ -301,7 +302,8 @@ SR_API const struct sr_output *sr_output_new(const struct sr_output_module *omod g_hash_table_iter_init(&iter, options); while (g_hash_table_iter_next(&iter, &key, &value)) { if (!g_hash_table_lookup(new_opts, key)) { - sr_err("Output module '%s' has no option '%s'", omod->id, key); + sr_err("Output module '%s' has no option '%s'", + omod->id, (char *)key); g_hash_table_destroy(new_opts); g_free(op); return NULL; diff --git a/src/scpi/scpi.c b/src/scpi/scpi.c index 38d74ab5..e198b2bd 100644 --- a/src/scpi/scpi.c +++ b/src/scpi/scpi.c @@ -425,10 +425,10 @@ SR_PRIV int sr_scpi_get_string(struct sr_scpi_dev_inst *scpi, if (response->len >= 1 && response->str[response->len - 1] == '\r') g_string_truncate(response, response->len - 1); - *scpi_response = response->str; - g_string_free(response, FALSE); + sr_spew("Got response: '%.70s', length %" G_GSIZE_FORMAT ".", + response->str, response->len); - sr_spew("Got response: '%.70s', length %d.", *scpi_response, strlen(*scpi_response)); + *scpi_response = g_string_free(response, FALSE); return SR_OK; } diff --git a/src/scpi/scpi_tcp.c b/src/scpi/scpi_tcp.c index cf01c905..14a2d2cb 100644 --- a/src/scpi/scpi_tcp.c +++ b/src/scpi/scpi_tcp.c @@ -86,7 +86,7 @@ static int scpi_tcp_open(void *priv) err = getaddrinfo(tcp->address, tcp->port, &hints, &results); if (err) { - sr_err("Address lookup failed: %s:%d: %s", tcp->address, tcp->port, + sr_err("Address lookup failed: %s:%s: %s", tcp->address, tcp->port, gai_strerror(err)); return SR_ERR; } diff --git a/src/scpi/scpi_vxi.c b/src/scpi/scpi_vxi.c index b2324b71..cef0cf0b 100644 --- a/src/scpi/scpi_vxi.c +++ b/src/scpi/scpi_vxi.c @@ -118,7 +118,7 @@ static int scpi_vxi_send(void *priv, const char *command) Device_WriteResp *write_resp; Device_WriteParms write_parms; char *terminated_command; - unsigned int len; + unsigned long len; terminated_command = g_strdup_printf("%s\r\n", command); len = strlen(terminated_command); @@ -132,7 +132,7 @@ static int scpi_vxi_send(void *priv, const char *command) if (!(write_resp = device_write_1(&write_parms, vxi->client)) || write_resp->error) { - sr_err("Device write failed for %s with error %d", + sr_err("Device write failed for %s with error %ld", vxi->address, write_resp ? write_resp->error : 0); return SR_ERR; } @@ -140,7 +140,7 @@ static int scpi_vxi_send(void *priv, const char *command) g_free(terminated_command); if (write_resp->size < len) - sr_dbg("Only sent %d/%d bytes of SCPI command: '%s'.", + sr_dbg("Only sent %lu/%lu bytes of SCPI command: '%s'.", write_resp->size, len, command); else sr_spew("Successfully sent SCPI command: '%s'.", command); @@ -177,7 +177,7 @@ static int scpi_vxi_read_data(void *priv, char *buf, int maxlen) if (!(read_resp = device_read_1(&read_parms, vxi->client)) || read_resp->error) { - sr_err("Device read failed for %s with error %d", + sr_err("Device read failed for %s with error %ld", vxi->address, read_resp ? read_resp->error : 0); return SR_ERR; } diff --git a/src/serial.c b/src/serial.c index b0ae07f0..d9c611bd 100644 --- a/src/serial.c +++ b/src/serial.c @@ -267,7 +267,7 @@ static int _serial_write(struct sr_serial_dev_inst *serial, return SR_ERR; } - sr_spew("Wrote %d/%d bytes.", ret, count); + sr_spew("Wrote %zd/%zu bytes.", ret, count); return ret; } @@ -345,7 +345,7 @@ static int _serial_read(struct sr_serial_dev_inst *serial, void *buf, } if (ret > 0) - sr_spew("Read %d/%d bytes.", ret, count); + sr_spew("Read %zd/%zu bytes.", ret, count); return ret; } @@ -683,7 +683,7 @@ SR_PRIV int serial_stream_detect(struct sr_serial_dev_inst *serial, { uint64_t start, time, byte_delay_us; size_t ibuf, i, maxlen; - int len; + ssize_t len; maxlen = *buflen; @@ -716,12 +716,12 @@ SR_PRIV int serial_stream_detect(struct sr_serial_dev_inst *serial, if ((ibuf - i) >= packet_size) { /* We have at least a packet's worth of data. */ if (is_valid(&buf[i])) { - sr_spew("Found valid %d-byte packet after " + sr_spew("Found valid %zu-byte packet after " "%" PRIu64 "ms.", (ibuf - i), time); *buflen = ibuf; return SR_OK; } else { - sr_spew("Got %d bytes, but not a valid " + sr_spew("Got %zu bytes, but not a valid " "packet.", (ibuf - i)); } /* Not a valid packet. Continue searching. */ @@ -729,7 +729,7 @@ SR_PRIV int serial_stream_detect(struct sr_serial_dev_inst *serial, } if (time >= timeout_ms) { /* Timeout */ - sr_dbg("Detection timed out after %dms.", time); + sr_dbg("Detection timed out after %" PRIu64 "ms.", time); break; } if (len < 1) @@ -738,7 +738,7 @@ SR_PRIV int serial_stream_detect(struct sr_serial_dev_inst *serial, *buflen = ibuf; - sr_err("Didn't find a valid packet (read %d bytes).", *buflen); + sr_err("Didn't find a valid packet (read %zu bytes).", *buflen); return SR_ERR; } diff --git a/src/transform/transform.c b/src/transform/transform.c index b518088b..f8ae7970 100644 --- a/src/transform/transform.c +++ b/src/transform/transform.c @@ -221,7 +221,8 @@ SR_API const struct sr_transform *sr_transform_new(const struct sr_transform_mod /* Pass option along. */ gvt = g_variant_get_type(mod_opts[i].def); if (!g_variant_is_of_type(value, gvt)) { - sr_err("Invalid type for '%s' option.", key); + sr_err("Invalid type for '%s' option.", + (char *)key); g_free(t); return NULL; } @@ -239,7 +240,8 @@ SR_API const struct sr_transform *sr_transform_new(const struct sr_transform_mod g_hash_table_iter_init(&iter, options); while (g_hash_table_iter_next(&iter, &key, &value)) { if (!g_hash_table_lookup(new_opts, key)) { - sr_err("Transform module '%s' has no option '%s'.", tmod->id, key); + sr_err("Transform module '%s' has no option '%s'.", + tmod->id, (char *)key); g_hash_table_destroy(new_opts); g_free(t); return NULL;