goto scan_cleanup;
}
- len = 128;
+ len = sizeof(buf);
ret = brymen_stream_detect(serial, buf, &len, brymen_packet_length,
brymen_packet_is_valid, 1000, 9600);
if (ret != SR_OK)
serial = sdi->conn;
if (devc->state == IDLE) {
- if (serial_read_nonblocking(serial, buf, 128) != 1 || buf[0] != 0x10)
+ if (serial_read_nonblocking(serial, buf, sizeof(buf)) != 1 || buf[0] != 0x10)
/* Nothing there, or caught the tail end of a previous packet,
* or some garbage. Unless it's a single "data ready" byte,
* we don't want it. */
/* Response is first a CMD_ACK byte (ASCII '0' for OK,
* or '1' to signify an error. */
- len = 128;
+ len = sizeof(buf);
serial_readline(serial, &b, &len, 150);
if (len != 1)
continue;
continue;
/* If CMD_ACK was OK, ID string follows. */
- len = 128;
+ len = sizeof(buf);
serial_readline(serial, &b, &len, 850);
if (len < 10)
continue;
inc->samplerate = g_variant_get_uint64(g_hash_table_lookup(options, "samplerate"));
for (i = 0; i < num_channels; i++) {
- snprintf(name, 16, "%d", i);
+ snprintf(name, sizeof(name), "%d", i);
sr_channel_new(in->sdi, i, SR_CHANNEL_LOGIC, TRUE, name);
}
inc->samplerate = g_variant_get_uint64(g_hash_table_lookup(options, "samplerate"));
for (i = 0; i < num_channels; i++) {
- snprintf(name, 16, "%d", i);
+ snprintf(name, sizeof(name), "%d", i);
sr_channel_new(in->sdi, i, SR_CHANNEL_LOGIC, TRUE, name);
}
continue;
for (channel = 0; channel < 16; channel++) {
- snprintf(name, 8, "%c%d", get_pod_name_from_id(pod), channel);
+ snprintf(name, sizeof(name), "%c%d", get_pod_name_from_id(pod), channel);
inc->channels[pod][channel] =
sr_channel_new(in->sdi, chan_id, SR_CHANNEL_LOGIC, TRUE, name);
chan_id++;
}
- snprintf(name, 8, "CLK%c", get_pod_name_from_id(pod));
+ snprintf(name, sizeof(name), "CLK%c", get_pod_name_from_id(pod));
inc->channels[pod][16] =
sr_channel_new(in->sdi, chan_id, SR_CHANNEL_LOGIC, TRUE, name);
chan_id++;
return ret;
for (int i = 0; i < inc->num_channels; i++) {
- snprintf(channelname, 8, "CH%d", i + 1);
+ snprintf(channelname, sizeof(channelname), "CH%d", i + 1);
sr_channel_new(in->sdi, i, SR_CHANNEL_ANALOG, TRUE, channelname);
}
sr_dbg("Opened %s.", vdev->capturefile);
} else {
/* Try as first chunk filename. */
- snprintf(capturefile, 15, "%s-1", vdev->capturefile);
+ snprintf(capturefile, sizeof(capturefile) - 1, "%s-1", vdev->capturefile);
if (zip_stat(vdev->archive, capturefile, 0, &zs) != -1) {
vdev->cur_chunk = 1;
if (!(vdev->capfile = zip_fopen(vdev->archive,
} else {
/* Capture data is chunked, advance to the next chunk. */
vdev->cur_chunk++;
- snprintf(capturefile, 15, "%s-%d", vdev->capturefile,
+ snprintf(capturefile, sizeof(capturefile) - 1, "%s-%d", vdev->capturefile,
vdev->cur_chunk);
if (zip_stat(vdev->archive, capturefile, 0, &zs) != -1) {
if (!(vdev->capfile = zip_fopen(vdev->archive,