]> sigrok.org Git - libserialport.git/commitdiff
Fix misleading snprintf() arguments.
authorUwe Hermann <redacted>
Fri, 20 Feb 2015 17:57:08 +0000 (18:57 +0100)
committerUwe Hermann <redacted>
Fri, 20 Feb 2015 17:57:08 +0000 (18:57 +0100)
freebsd.c
linux.c

index d1fabee93e1d7701e0c565366725c2273529c1e8..f7957edfe8ffe385b1d2b937fd4ca6d02aaae29c 100644 (file)
--- a/freebsd.c
+++ b/freebsd.c
@@ -162,7 +162,7 @@ static int sysctl_query_dev_drv(const char *drv_name_str,
        if (!ttyname || !ttyport_cnt)
                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);
        tbuf_len = sizeof(tbuf) - 1;
        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,
            (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);
        tbuf_len = sizeof(tbuf) - 1;
        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. */
        if ((cua_sfx[0] == 'u') || (cua_sfx[0] == 'd')) {
                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);
                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. */
                                        for (sub_inst = 0; sub_inst < ttyport_cnt; sub_inst++) {
                                                if (ttyport_cnt == 1)
-                                                       snprintf(tbuf, sizeof(tbuf) - 1, "%s", ttyname);
+                                                       snprintf(tbuf, sizeof(tbuf), "%s", ttyname);
                                                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)) {
                                                        DBG("MATCH: '%s' == '%s'\n", cua_sfx, tbuf);
                                                        cua_dev_found = 1;
diff --git a/linux.c b/linux.c
index 9ffdc91ba08189bc9bb242b2db7eb1175f227fdb..8e9bfbf72ccbd1c46e4d0511020eb9f0f11421ed 100644 (file)
--- a/linux.c
+++ b/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 (port->usb_serial && strlen(port->usb_serial)) {
-                               snprintf(description, sizeof(description) - 1,
+                               snprintf(description, sizeof(description),
                                        "%s - %s", port->description, port->usb_serial);
                                if (port->description)
                                        free(port->description);