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.
This commit is contained in:
Daniel Elstner 2015-09-13 02:29:38 +02:00
parent 6d9da8efbf
commit 6433156c32
25 changed files with 92 additions and 72 deletions

View File

@ -112,7 +112,9 @@ static int parse_value(const uint8_t *buf, float *result)
} else if (!isdigit(buf[1]) || !isdigit(buf[2]) || } else if (!isdigit(buf[1]) || !isdigit(buf[2]) ||
!isdigit(buf[3]) || !isdigit(buf[4])) { !isdigit(buf[3]) || !isdigit(buf[4])) {
sr_dbg("Value contained invalid digits: %02x %02x %02x %02x (" 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; return SR_ERR;
} }
intval = 0; intval = 0;

View File

@ -70,8 +70,9 @@ static int parse_value(const uint8_t *buf, struct vc870_info *info,
} else if (!isdigit(buf[3]) || !isdigit(buf[4]) || } else if (!isdigit(buf[3]) || !isdigit(buf[4]) ||
!isdigit(buf[5]) || !isdigit(buf[6]) || !isdigit(buf[7])) { !isdigit(buf[5]) || !isdigit(buf[6]) || !isdigit(buf[7])) {
sr_dbg("Invalid digits: %02x %02x %02x %02x %02X " sr_dbg("Invalid digits: %02x %02x %02x %02x %02X "
"(%c %c %c %c %c).", buf[3], buf[4], buf[5], buf[6], "(%c %c %c %c %c).",
buf[7]); buf[3], buf[4], buf[5], buf[6], buf[7],
buf[3], buf[4], buf[5], buf[6], buf[7]);
return SR_ERR; return SR_ERR;
} }

View File

@ -421,7 +421,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
sr_session_send(sdi, &packet); sr_session_send(sdi, &packet);
if (devc->samples_missed > 0) if (devc->samples_missed > 0)
sr_warn("%d samples missed", devc->samples_missed); sr_warn("%" PRIu64 " samples missed", devc->samples_missed);
return SR_OK; return SR_OK;
} }

View File

@ -125,7 +125,7 @@ SR_PRIV int sr_gpio_get_value(int gpio)
status = fscanf(fd, "%d", &ret); status = fscanf(fd, "%d", &ret);
fclose(fd); fclose(fd);
if (status != 1) { 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); g_string_free(path, TRUE);
return -1; return -1;
} }

View File

@ -507,7 +507,7 @@ static float read_sample(struct sr_channel *ch)
len = read(fd, buf, sizeof(buf)); len = read(fd, buf, sizeof(buf));
if (len < 0) { 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->name, chp->probe->hwmon_num, g_strerror(errno));
ch->enabled = FALSE; ch->enabled = FALSE;
return -1.0; return -1.0;

View File

@ -293,7 +293,7 @@ static int brymen_bm86x_read_interrupt(const struct sr_dev_inst *sdi)
} }
if (transferred != sizeof(buf)) { 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; return SR_ERR;
} }

View File

@ -179,7 +179,9 @@ SR_PRIV int brymen_stream_detect(struct sr_serial_dev_inst *serial,
{ {
int64_t start, time, byte_delay_us; int64_t start, time, byte_delay_us;
size_t ibuf, i, maxlen; size_t ibuf, i, maxlen;
int status, len, packet_len, stream_len; ssize_t len, stream_len;
int packet_len;
int status;
maxlen = *buflen; 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); len = serial_read_nonblocking(serial, &buf[ibuf], maxlen - ibuf);
if (len > 0) { if (len > 0) {
ibuf += len; ibuf += len;
sr_spew("Read %d bytes.", len); sr_spew("Read %zd bytes.", len);
} }
time = g_get_monotonic_time() - start; 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) { if (time >= (int64_t)timeout_ms) {
/* Timeout */ /* Timeout */
sr_dbg("Detection timed out after %dms.", time); sr_dbg("Detection timed out after %" PRIi64 "ms.", time);
break; break;
} }
g_usleep(byte_delay_us); g_usleep(byte_delay_us);
} }
*buflen = ibuf; *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; return SR_ERR;
} }

View File

@ -38,7 +38,7 @@ int dslogic_fpga_firmware_upload(const struct sr_dev_inst *sdi,
const char *filename) const char *filename)
{ {
FILE *fw; FILE *fw;
struct stat st; GStatBuf st;
struct sr_usb_dev_inst *usb; struct sr_usb_dev_inst *usb;
int chunksize, result, ret; int chunksize, result, ret;
unsigned char *buf; 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); sr_dbg("Uploading FPGA firmware at %s.", filename);
usb = sdi->conn; 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)); sr_err("Unable to upload FPGA firmware: %s", g_strerror(errno));
return SR_ERR; return SR_ERR;
} }
@ -85,7 +85,8 @@ int dslogic_fpga_firmware_upload(const struct sr_dev_inst *sdi,
break; break;
} }
sum += transferred; 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) { if (transferred != chunksize) {
sr_err("Short transfer while uploading FPGA firmware."); sr_err("Short transfer while uploading FPGA firmware.");

View File

@ -856,7 +856,7 @@ static void process_msg_inf_13(struct sr_dev_inst *sdi)
devc->value += pow(10.0, cnt) * dgt; devc->value += pow(10.0, cnt) * dgt;
} }
sr_spew("process_msg_inf_13() value=%f scale=%f scale1000=%d mq=%d " 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); devc->scale1000, devc->mq, devc->unit, devc->mqflags);
if (devc->value != NAN) if (devc->value != NAN)
devc->value *= devc->scale * pow(1000.0, devc->scale1000); 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]); sr_spew("Cmd %d unimplemented!", devc->buf[3]);
break; break;
case 3: /* Read firmware version and status */ 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) { switch (devc->cmd_idx) {
case 0: case 0:
devc->fw_ver_maj = devc->buf[5]; 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; devc->value += pow(10.0, cnt) * dgt;
} }
sr_spew("process_msg14() value=%f scale=%f scale1000=%d mq=%d " 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); devc->scale1000, devc->mq, devc->unit, devc->mqflags);
if (devc->value != NAN) if (devc->value != NAN)
devc->value *= devc->scale * pow(1000.0, devc->scale1000); devc->value *= devc->scale * pow(1000.0, devc->scale1000);

View File

@ -394,7 +394,7 @@ static int dev_open(struct sr_dev_inst *sdi)
timediff_ms = timediff_us / 1000; timediff_ms = timediff_us / 1000;
sr_spew("Waited %" PRIi64 " ms.", timediff_ms); 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 { } else {
err = dso_open(sdi); err = dso_open(sdi);
} }

View File

@ -434,7 +434,7 @@ SR_PRIV int hung_chang_dso_2100_poll(int fd, int revents, void *cb_data)
return TRUE; return TRUE;
if (state != 0x03) { 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; return FALSE;
} }

View File

@ -193,9 +193,10 @@ SR_PRIV int motech_lps_30x_receive_data(int fd, int revents, void *cb_data)
return TRUE; return TRUE;
if (devc->acq_req_pending) { 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)) { 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; devc->acq_req_pending = 0;
} }
} }

View File

@ -576,7 +576,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
* buffer. * buffer.
*/ */
sr_dbg("max_samples = %d", devc->max_samples); 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); samplecount = MIN(devc->max_samples, devc->limit_samples);
sr_dbg("Samplecount = %d", samplecount); sr_dbg("Samplecount = %d", samplecount);

View File

@ -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 */ /* Clear out the most significant bit of the sample */
devc->tmp_sample[devc->num_bytes - 1] &= 0x7f; 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 */ /* expand second sample */
memset(devc->tmp_sample2, 0, 4); 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 */ /* Clear out the most significant bit of the sample */
devc->tmp_sample2[devc->num_bytes - 1] &= 0x7f; 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. * OLS sends its sample buffer backwards.

View File

@ -712,7 +712,8 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
} }
devc->num_block_read = 0; devc->num_block_read = 0;
} else { } 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; devc->num_channel_bytes += len;

View File

@ -214,7 +214,7 @@ static int do_ep1_command(const struct sr_dev_inst *sdi,
} }
if (xfer != cmd_len) { if (xfer != cmd_len) {
sr_dbg("Failed to send EP1 command 0x%02x: incorrect length " 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; return SR_ERR;
} }
@ -230,7 +230,7 @@ static int do_ep1_command(const struct sr_dev_inst *sdi,
} }
if (xfer != reply_len) { if (xfer != reply_len) {
sr_dbg("Failed to receive reply to EP1 command 0x%02x: " 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; return SR_ERR;
} }

View File

@ -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) { if (sr_config_list(driver, sdi, cg, SR_CONF_DEVICE_OPTIONS, &gvar_opts) != SR_OK) {
/* Driver publishes no options. */ /* Driver publishes no options. */
sr_err("No options available%s.", srci->id, suffix); sr_err("No options available%s.", suffix);
return SR_ERR_ARG; return SR_ERR_ARG;
} }
opts = g_variant_get_fixed_array(gvar_opts, &num_opts, sizeof(uint32_t)); opts = g_variant_get_fixed_array(gvar_opts, &num_opts, sizeof(uint32_t));

View File

@ -80,7 +80,7 @@ struct context {
uint64_t samplerate; uint64_t samplerate;
/* Number of channels. */ /* Number of channels. */
gsize num_channels; unsigned int num_channels;
/* Column delimiter character(s). */ /* Column delimiter character(s). */
GString *delimiter; GString *delimiter;
@ -95,23 +95,23 @@ struct context {
gboolean multi_column_mode; gboolean multi_column_mode;
/* Column number of the sample data in single 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 * 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 * first channel in multi column mode and the single column number in
* single column mode. * single column mode.
*/ */
gsize first_column; unsigned int first_column;
/* /*
* Column number of the first channel in multi column mode and position of * Column number of the first channel in multi column mode and position of
* the bit for the first channel in single column mode. * the bit for the first channel in single column mode.
*/ */
gsize first_channel; unsigned int first_channel;
/* Line number to start processing. */ /* 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 * Determines if the first line should be treated as header and used for
@ -123,13 +123,13 @@ struct context {
int format; int format;
/* Size of the sample buffer. */ /* Size of the sample buffer. */
gsize sample_buffer_size; size_t sample_buffer_size;
/* Buffer to store sample data. */ /* Buffer to store sample data. */
uint8_t *sample_buffer; uint8_t *sample_buffer;
/* Current line number. */ /* Current line number. */
gsize line_number; size_t line_number;
}; };
static int format_match(GHashTable *metadata) static int format_match(GHashTable *metadata)
@ -161,7 +161,7 @@ static int parse_binstr(const char *str, struct context *inc)
length = strlen(str); length = strlen(str);
if (!length) { 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); inc->line_number);
return SR_ERR; return SR_ERR;
} }
@ -175,7 +175,7 @@ static int parse_binstr(const char *str, struct context *inc)
if (str[length - i - 1] == '1') { if (str[length - i - 1] == '1') {
inc->sample_buffer[j / 8] |= (1 << (j % 8)); inc->sample_buffer[j / 8] |= (1 << (j % 8));
} else if (str[length - i - 1] != '0') { } 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); str, inc->single_column, inc->line_number);
return SR_ERR; return SR_ERR;
} }
@ -193,7 +193,7 @@ static int parse_hexstr(const char *str, struct context *inc)
length = strlen(str); length = strlen(str);
if (!length) { 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); inc->line_number);
return SR_ERR; return SR_ERR;
} }
@ -208,7 +208,7 @@ static int parse_hexstr(const char *str, struct context *inc)
c = str[length - i - 1]; c = str[length - i - 1];
if (!g_ascii_isxdigit(c)) { 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); str, inc->single_column, inc->line_number);
return SR_ERR; return SR_ERR;
} }
@ -237,7 +237,7 @@ static int parse_octstr(const char *str, struct context *inc)
length = strlen(str); length = strlen(str);
if (!length) { 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); inc->line_number);
return SR_ERR; return SR_ERR;
} }
@ -252,7 +252,7 @@ static int parse_octstr(const char *str, struct context *inc)
c = str[length - i - 1]; c = str[length - i - 1];
if (c < '0' || c > '7') { 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); str, inc->single_column, inc->line_number);
return SR_ERR; 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")); inc->start_line = g_variant_get_int32(g_hash_table_lookup(options, "startline"));
if (inc->start_line < 1) { 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; return SR_ERR_ARG;
} }
@ -473,8 +473,8 @@ static int initial_parse(const struct sr_input *in, GString *buf)
{ {
struct context *inc; struct context *inc;
GString *channel_name; GString *channel_name;
gsize num_columns, l, i; unsigned int num_columns, i;
unsigned int line_number; size_t line_number, l;
int ret; int ret;
char **lines, **columns; 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. */ /* Ensure that the first column is not out of bounds. */
if (!num_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, line_number); inc->first_column, line_number);
ret = SR_ERR; ret = SR_ERR;
goto out; goto out;
@ -535,7 +535,7 @@ static int initial_parse(const struct sr_input *in, GString *buf)
*/ */
if (!inc->num_channels) { if (!inc->num_channels) {
inc->num_channels = num_columns; inc->num_channels = num_columns;
sr_dbg("Number of auto-detected channels: %zu.", sr_dbg("Number of auto-detected channels: %u.",
inc->num_channels); 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); channel_name = g_string_sized_new(64);
for (i = 0; i < inc->num_channels; i++) { 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]); g_string_assign(channel_name, columns[i]);
else 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); sr_channel_new(in->sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_name->str);
} }
g_string_free(channel_name, TRUE); g_string_free(channel_name, TRUE);
@ -679,7 +679,7 @@ static int process_buffer(struct sr_input *in)
} }
num_columns = g_strv_length(columns); num_columns = g_strv_length(columns);
if (!num_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); inc->first_column, inc->line_number);
g_strfreev(columns); g_strfreev(columns);
return SR_ERR; return SR_ERR;

View File

@ -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. */ /* Option not given: insert the default value. */
gvt = g_variant_get_type(mod_opts[i].def); gvt = g_variant_get_type(mod_opts[i].def);
if (!g_variant_is_of_type(value, gvt)) { 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); g_free(in);
return NULL; 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); g_hash_table_iter_init(&iter, options);
while (g_hash_table_iter_next(&iter, &key, &value)) { while (g_hash_table_iter_next(&iter, &key, &value)) {
if (!g_hash_table_lookup(new_opts, key)) { 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_hash_table_destroy(new_opts);
g_free(in); g_free(in);
return NULL; 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_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); 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); sr_dev_inst_free(in->sdi);
if (in->buf->len > 64) { if (in->buf->len > 64) {
/* That seems more than just some sub-unitsize leftover... */ /* 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_string_free(in->buf, TRUE);
g_free(in->priv); g_free(in->priv);

View File

@ -283,7 +283,8 @@ SR_API const struct sr_output *sr_output_new(const struct sr_output_module *omod
/* Pass option along. */ /* Pass option along. */
gvt = g_variant_get_type(mod_opts[i].def); gvt = g_variant_get_type(mod_opts[i].def);
if (!g_variant_is_of_type(value, gvt)) { 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); g_free(op);
return NULL; 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); g_hash_table_iter_init(&iter, options);
while (g_hash_table_iter_next(&iter, &key, &value)) { while (g_hash_table_iter_next(&iter, &key, &value)) {
if (!g_hash_table_lookup(new_opts, key)) { 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_hash_table_destroy(new_opts);
g_free(op); g_free(op);
return NULL; return NULL;

View File

@ -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') if (response->len >= 1 && response->str[response->len - 1] == '\r')
g_string_truncate(response, response->len - 1); g_string_truncate(response, response->len - 1);
*scpi_response = response->str; sr_spew("Got response: '%.70s', length %" G_GSIZE_FORMAT ".",
g_string_free(response, FALSE); 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; return SR_OK;
} }

View File

@ -86,7 +86,7 @@ static int scpi_tcp_open(void *priv)
err = getaddrinfo(tcp->address, tcp->port, &hints, &results); err = getaddrinfo(tcp->address, tcp->port, &hints, &results);
if (err) { 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)); gai_strerror(err));
return SR_ERR; return SR_ERR;
} }

View File

@ -118,7 +118,7 @@ static int scpi_vxi_send(void *priv, const char *command)
Device_WriteResp *write_resp; Device_WriteResp *write_resp;
Device_WriteParms write_parms; Device_WriteParms write_parms;
char *terminated_command; char *terminated_command;
unsigned int len; unsigned long len;
terminated_command = g_strdup_printf("%s\r\n", command); terminated_command = g_strdup_printf("%s\r\n", command);
len = strlen(terminated_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)) if (!(write_resp = device_write_1(&write_parms, vxi->client))
|| write_resp->error) { || 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); vxi->address, write_resp ? write_resp->error : 0);
return SR_ERR; return SR_ERR;
} }
@ -140,7 +140,7 @@ static int scpi_vxi_send(void *priv, const char *command)
g_free(terminated_command); g_free(terminated_command);
if (write_resp->size < len) 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); write_resp->size, len, command);
else else
sr_spew("Successfully sent SCPI command: '%s'.", command); 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)) if (!(read_resp = device_read_1(&read_parms, vxi->client))
|| read_resp->error) { || 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); vxi->address, read_resp ? read_resp->error : 0);
return SR_ERR; return SR_ERR;
} }

View File

@ -267,7 +267,7 @@ static int _serial_write(struct sr_serial_dev_inst *serial,
return SR_ERR; return SR_ERR;
} }
sr_spew("Wrote %d/%d bytes.", ret, count); sr_spew("Wrote %zd/%zu bytes.", ret, count);
return ret; return ret;
} }
@ -345,7 +345,7 @@ static int _serial_read(struct sr_serial_dev_inst *serial, void *buf,
} }
if (ret > 0) if (ret > 0)
sr_spew("Read %d/%d bytes.", ret, count); sr_spew("Read %zd/%zu bytes.", ret, count);
return ret; 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; uint64_t start, time, byte_delay_us;
size_t ibuf, i, maxlen; size_t ibuf, i, maxlen;
int len; ssize_t len;
maxlen = *buflen; maxlen = *buflen;
@ -716,12 +716,12 @@ SR_PRIV int serial_stream_detect(struct sr_serial_dev_inst *serial,
if ((ibuf - i) >= packet_size) { if ((ibuf - i) >= packet_size) {
/* We have at least a packet's worth of data. */ /* We have at least a packet's worth of data. */
if (is_valid(&buf[i])) { 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); "%" PRIu64 "ms.", (ibuf - i), time);
*buflen = ibuf; *buflen = ibuf;
return SR_OK; return SR_OK;
} else { } else {
sr_spew("Got %d bytes, but not a valid " sr_spew("Got %zu bytes, but not a valid "
"packet.", (ibuf - i)); "packet.", (ibuf - i));
} }
/* Not a valid packet. Continue searching. */ /* 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) { if (time >= timeout_ms) {
/* Timeout */ /* Timeout */
sr_dbg("Detection timed out after %dms.", time); sr_dbg("Detection timed out after %" PRIu64 "ms.", time);
break; break;
} }
if (len < 1) if (len < 1)
@ -738,7 +738,7 @@ SR_PRIV int serial_stream_detect(struct sr_serial_dev_inst *serial,
*buflen = ibuf; *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; return SR_ERR;
} }

View File

@ -221,7 +221,8 @@ SR_API const struct sr_transform *sr_transform_new(const struct sr_transform_mod
/* Pass option along. */ /* Pass option along. */
gvt = g_variant_get_type(mod_opts[i].def); gvt = g_variant_get_type(mod_opts[i].def);
if (!g_variant_is_of_type(value, gvt)) { 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); g_free(t);
return NULL; 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); g_hash_table_iter_init(&iter, options);
while (g_hash_table_iter_next(&iter, &key, &value)) { while (g_hash_table_iter_next(&iter, &key, &value)) {
if (!g_hash_table_lookup(new_opts, key)) { 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_hash_table_destroy(new_opts);
g_free(t); g_free(t);
return NULL; return NULL;