[dpdk-dev] [PATCH] Fix off-by-one errors in snprintf in various files
Bruce Richardson
bruce.richardson at intel.com
Fri May 10 16:55:42 CEST 2019
On Fri, May 10, 2019 at 10:53:12AM -0400, Michael Santana wrote:
> 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 at dpdk.org
>
> Signed-off-by: Michael Santana <msantana at redhat.com>
> ---
> drivers/net/qede/base/bcm_osal.c | 4 ++--
> drivers/net/qede/qede_filter.c | 2 +-
> drivers/net/vdev_netvsc/vdev_netvsc.c | 2 +-
> examples/multi_process/client_server_mp/shared/common.h | 2 +-
> examples/server_node_efd/shared/common.h | 2 +-
> lib/librte_eal/common/eal_common_options.c | 3 +--
> lib/librte_eal/common/eal_filesystem.h | 9 ++++-----
> lib/librte_eal/common/malloc_heap.c | 4 ++--
> 8 files changed, 13 insertions(+), 15 deletions(-)
>
Looks a good cleanup, thanks.
Acked-by: Bruce Richardson <bruce.richardson at intel.com>
More information about the dev
mailing list