DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: Re: [dpdk-dev] [PATCH 1/2] add support for strlcpy function
Date: Mon, 12 Mar 2018 11:51:16 +0000	[thread overview]
Message-ID: <20180312115115.GB1704@bricha3-MOBL3.ger.corp.intel.com> (raw)
In-Reply-To: <20180312113300.115551-1-bruce.richardson@intel.com>

On Mon, Mar 12, 2018 at 11:32:59AM +0000, Bruce Richardson wrote:
> The strncpy function is error prone for doing "safe" string copies, so
> we generally try to use "snprintf" instead in the code. The function
> "strlcpy" is a better alternative, since it better conveys the
> intention of the programmer, and doesn't suffer from the non-null
> terminating behaviour of it's n'ed brethern.
> 
> The downside of this function is that it is not available by default
> on linux, though standard in the BSD's. It is available on most
> distros by installing "libbsd" package.
> 
> This patch therefore provides the following in rte_string_fns.h to ensure
> that strlcpy is available there:
> * for BSD, include string.h as normal
> * if RTE_USE_LIBBSD is set, include <bsd/string.h>
> * if not set, fallback to snprintf for strlcpy
> 
> Using make build system, the RTE_USE_LIBBSD is a hard-coded value to "n",
> but when using meson, it's automatically set based on what is available
> on the platform.
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> 
> ----
> RFC->v1:
> * split patch into 2, to separate out snprintf replacement
> * added missing include in mlx drivers
> * adding linking support against libbsd when feature is enabled
> * make strlcpy an inline function rather than macro
> * fix support on BSD where strict posix compliance is requested and
>   therefore strlcpy is not available.
> ---
Forgot to include Stephen's reviewed-by from RFC:

Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>

      parent reply	other threads:[~2018-03-12 11:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-20 17:07 [dpdk-dev] [RFC PATCH] use strlcpy for string copies Bruce Richardson
2018-02-20 23:01 ` Stephen Hemminger
2018-02-23 17:18 ` Adrien Mazarguil
2018-02-23 18:11 ` Matteo Croce
2018-03-12 11:32 ` [dpdk-dev] [PATCH 1/2] add support for strlcpy function Bruce Richardson
2018-03-12 11:33   ` [dpdk-dev] [PATCH 2/2] convert snprintf to strlcpy Bruce Richardson
2018-03-12 11:50     ` Bruce Richardson
2018-04-04 13:26     ` Thomas Monjalon
2018-03-12 11:51   ` Bruce Richardson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180312115115.GB1704@bricha3-MOBL3.ger.corp.intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).