mirror of
git://sigrok.org/libserialport
synced 2023-08-10 21:13:24 +03:00
Fix misleading snprintf() arguments.
This commit is contained in:
parent
ea17bfca3d
commit
7c1101dc08
10
freebsd.c
10
freebsd.c
@ -162,7 +162,7 @@ static int sysctl_query_dev_drv(const char *drv_name_str,
|
|||||||
if (!ttyname || !ttyport_cnt)
|
if (!ttyname || !ttyport_cnt)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
snprintf(sbuf, sizeof(sbuf) - 1, "dev.%s.%s.ttyname", drv_name_str,
|
snprintf(sbuf, sizeof(sbuf), "dev.%s.%s.ttyname", drv_name_str,
|
||||||
drv_inst_str);
|
drv_inst_str);
|
||||||
tbuf_len = sizeof(tbuf) - 1;
|
tbuf_len = sizeof(tbuf) - 1;
|
||||||
if ((rc = sysctlbyname(sbuf, tbuf, &tbuf_len, NULL, 0)) != 0)
|
if ((rc = sysctlbyname(sbuf, tbuf, &tbuf_len, NULL, 0)) != 0)
|
||||||
@ -173,7 +173,7 @@ static int sysctl_query_dev_drv(const char *drv_name_str,
|
|||||||
DBG("sysctl: '%s' (%d) (%d): '%.*s'\n", sbuf, rc, (int)tbuf_len,
|
DBG("sysctl: '%s' (%d) (%d): '%.*s'\n", sbuf, rc, (int)tbuf_len,
|
||||||
(int)tbuf_len, tbuf);
|
(int)tbuf_len, tbuf);
|
||||||
|
|
||||||
snprintf(sbuf, sizeof(sbuf) - 1, "dev.%s.%s.ttyports",
|
snprintf(sbuf, sizeof(sbuf), "dev.%s.%s.ttyports",
|
||||||
drv_name_str, drv_inst_str);
|
drv_name_str, drv_inst_str);
|
||||||
tbuf_len = sizeof(tbuf) - 1;
|
tbuf_len = sizeof(tbuf) - 1;
|
||||||
rc = sysctlbyname(sbuf, tbuf, &tbuf_len, NULL, 0);
|
rc = sysctlbyname(sbuf, tbuf, &tbuf_len, NULL, 0);
|
||||||
@ -256,7 +256,7 @@ SP_PRIV enum sp_return get_port_details(struct sp_port *port)
|
|||||||
/* Native UART enumeration. */
|
/* Native UART enumeration. */
|
||||||
if ((cua_sfx[0] == 'u') || (cua_sfx[0] == 'd')) {
|
if ((cua_sfx[0] == 'u') || (cua_sfx[0] == 'd')) {
|
||||||
port->transport = SP_TRANSPORT_NATIVE;
|
port->transport = SP_TRANSPORT_NATIVE;
|
||||||
snprintf(tbuf, sizeof(tbuf) - 1, "cua%s", cua_sfx);
|
snprintf(tbuf, sizeof(tbuf), "cua%s", cua_sfx);
|
||||||
port->description = strdup(tbuf);
|
port->description = strdup(tbuf);
|
||||||
RETURN_OK();
|
RETURN_OK();
|
||||||
}
|
}
|
||||||
@ -287,9 +287,9 @@ SP_PRIV enum sp_return get_port_details(struct sp_port *port)
|
|||||||
/* Handle multiple subinstances of serial ports in the same driver instance. */
|
/* Handle multiple subinstances of serial ports in the same driver instance. */
|
||||||
for (sub_inst = 0; sub_inst < ttyport_cnt; sub_inst++) {
|
for (sub_inst = 0; sub_inst < ttyport_cnt; sub_inst++) {
|
||||||
if (ttyport_cnt == 1)
|
if (ttyport_cnt == 1)
|
||||||
snprintf(tbuf, sizeof(tbuf) - 1, "%s", ttyname);
|
snprintf(tbuf, sizeof(tbuf), "%s", ttyname);
|
||||||
else
|
else
|
||||||
snprintf(tbuf, sizeof(tbuf) - 1, "%s.%d", ttyname, sub_inst);
|
snprintf(tbuf, sizeof(tbuf), "%s.%d", ttyname, sub_inst);
|
||||||
if (!strcmp(cua_sfx, tbuf)) {
|
if (!strcmp(cua_sfx, tbuf)) {
|
||||||
DBG("MATCH: '%s' == '%s'\n", cua_sfx, tbuf);
|
DBG("MATCH: '%s' == '%s'\n", cua_sfx, tbuf);
|
||||||
cua_dev_found = 1;
|
cua_dev_found = 1;
|
||||||
|
2
linux.c
2
linux.c
@ -137,7 +137,7 @@ SP_PRIV enum sp_return get_port_details(struct sp_port *port)
|
|||||||
|
|
||||||
/* If present, add serial to description for better identification. */
|
/* If present, add serial to description for better identification. */
|
||||||
if (port->usb_serial && strlen(port->usb_serial)) {
|
if (port->usb_serial && strlen(port->usb_serial)) {
|
||||||
snprintf(description, sizeof(description) - 1,
|
snprintf(description, sizeof(description),
|
||||||
"%s - %s", port->description, port->usb_serial);
|
"%s - %s", port->description, port->usb_serial);
|
||||||
if (port->description)
|
if (port->description)
|
||||||
free(port->description);
|
free(port->description);
|
||||||
|
Loading…
Reference in New Issue
Block a user