summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMichael Santana <msantana@redhat.com>2019-05-10 10:53:12 -0400
committerThomas Monjalon <thomas@monjalon.net>2019-05-29 13:02:53 +0200
commitf4be6a9a2903e68f5f04124eeb59325c17f1e1eb (patch)
tree697aa867138ca13ddae4c7d7a37345d023c487ab /examples
parentd31b95860d8e9dd7c6e242bd08baaac00a9714f0 (diff)
downloaddpdk-f4be6a9a2903e68f5f04124eeb59325c17f1e1eb.zip
dpdk-f4be6a9a2903e68f5f04124eeb59325c17f1e1eb.tar.gz
dpdk-f4be6a9a2903e68f5f04124eeb59325c17f1e1eb.tar.xz
fix off-by-one errors in snprintf
snprintf guarantees to always correctly place a null terminator in the buffer string. So manually placing a null terminator in a buffer right after a call to snprintf is redundant code. Additionally, there is no need to use 'sizeof(buffer) - 1' in snprintf as this means we are not using the last character in the buffer. 'sizeof(buffer)' is enough. Cc: stable@dpdk.org Signed-off-by: Michael Santana <msantana@redhat.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/multi_process/client_server_mp/shared/common.h2
-rw-r--r--examples/server_node_efd/shared/common.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/examples/multi_process/client_server_mp/shared/common.h b/examples/multi_process/client_server_mp/shared/common.h
index ac91755..6dd43fc 100644
--- a/examples/multi_process/client_server_mp/shared/common.h
+++ b/examples/multi_process/client_server_mp/shared/common.h
@@ -49,7 +49,7 @@ get_rx_queue_name(unsigned id)
* by maximum 3 digits (plus an extra byte for safety) */
static char buffer[sizeof(MP_CLIENT_RXQ_NAME) + 2];
- snprintf(buffer, sizeof(buffer) - 1, MP_CLIENT_RXQ_NAME, id);
+ snprintf(buffer, sizeof(buffer), MP_CLIENT_RXQ_NAME, id);
return buffer;
}
diff --git a/examples/server_node_efd/shared/common.h b/examples/server_node_efd/shared/common.h
index b8b533d..130fd4f 100644
--- a/examples/server_node_efd/shared/common.h
+++ b/examples/server_node_efd/shared/common.h
@@ -61,7 +61,7 @@ get_rx_queue_name(unsigned int id)
*/
static char buffer[sizeof(MP_NODE_RXQ_NAME) + 2];
- snprintf(buffer, sizeof(buffer) - 1, MP_NODE_RXQ_NAME, id);
+ snprintf(buffer, sizeof(buffer), MP_NODE_RXQ_NAME, id);
return buffer;
}