} 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;
} 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;
}
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;
}
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;
}
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;
}
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;
}
{
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;
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;
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;
}
const char *filename)
{
FILE *fw;
- struct stat st;
+ GStatBuf st;
struct sr_usb_dev_inst *usb;
int chunksize, result, ret;
unsigned char *buf;
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;
}
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.");
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);
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];
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);
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);
}
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;
}
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;
}
}
* 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);
}
/* 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);
}
/* 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.
}
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;
}
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;
}
}
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;
}
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));
uint64_t samplerate;
/* Number of channels. */
- gsize num_channels;
+ unsigned int num_channels;
/* Column delimiter character(s). */
GString *delimiter;
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
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)
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
{
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;
/* 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;
*/
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);
}
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);
}
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;
/* 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;
}
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;
*/
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);
}
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);
/* 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;
}
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;
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;
}
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;
}
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);
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;
}
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);
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;
}
return SR_ERR;
}
- sr_spew("Wrote %d/%d bytes.", ret, count);
+ sr_spew("Wrote %zd/%zu bytes.", ret, count);
return ret;
}
}
if (ret > 0)
- sr_spew("Read %d/%d bytes.", ret, count);
+ sr_spew("Read %zd/%zu bytes.", ret, count);
return ret;
}
{
uint64_t start, time, byte_delay_us;
size_t ibuf, i, maxlen;
- int len;
+ ssize_t len;
maxlen = *buflen;
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. */
}
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)
*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;
}
/* 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;
}
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;