[dpdk-dev,v3,40/40] rte_string_fns.h: explicit cast for int return to size_t
Checks
Commit Message
Signed-off-by: Andy Green <andy@warmcat.com>
---
lib/librte_eal/common/include/rte_string_fns.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Thu, 10 May 2018 10:49:40 +0800
Andy Green <andy@warmcat.com> wrote:
> Signed-off-by: Andy Green <andy@warmcat.com>
> ---
> lib/librte_eal/common/include/rte_string_fns.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/librte_eal/common/include/rte_string_fns.h b/lib/librte_eal/common/include/rte_string_fns.h
> index fcbb42e00..51413a55e 100644
> --- a/lib/librte_eal/common/include/rte_string_fns.h
> +++ b/lib/librte_eal/common/include/rte_string_fns.h
> @@ -55,7 +55,7 @@ rte_strsplit(char *string, int stringlen,
> static inline size_t
> rte_strlcpy(char *dst, const char *src, size_t size)
> {
> - return snprintf(dst, size, "%s", src);
> + return (size_t)(unsigned int)snprintf(dst, size, "%s", src);
> }
>
> /* pull in a strlcpy function */
>
I would rather see a proper version of strlcpy extracted from libbsd
On 05/11/2018 03:17 AM, Stephen Hemminger wrote:
> On Thu, 10 May 2018 10:49:40 +0800
> Andy Green <andy@warmcat.com> wrote:
>
>> Signed-off-by: Andy Green <andy@warmcat.com>
>> ---
>> lib/librte_eal/common/include/rte_string_fns.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/lib/librte_eal/common/include/rte_string_fns.h b/lib/librte_eal/common/include/rte_string_fns.h
>> index fcbb42e00..51413a55e 100644
>> --- a/lib/librte_eal/common/include/rte_string_fns.h
>> +++ b/lib/librte_eal/common/include/rte_string_fns.h
>> @@ -55,7 +55,7 @@ rte_strsplit(char *string, int stringlen,
>> static inline size_t
>> rte_strlcpy(char *dst, const char *src, size_t size)
>> {
>> - return snprintf(dst, size, "%s", src);
>> + return (size_t)(unsigned int)snprintf(dst, size, "%s", src);
>> }
>>
>> /* pull in a strlcpy function */
>>
>
> I would rather see a proper version of strlcpy extracted from libbsd
I also have done this and will push later. It's not inline any more.
-Andy
@@ -55,7 +55,7 @@ rte_strsplit(char *string, int stringlen,
static inline size_t
rte_strlcpy(char *dst, const char *src, size_t size)
{
- return snprintf(dst, size, "%s", src);
+ return (size_t)(unsigned int)snprintf(dst, size, "%s", src);
}
/* pull in a strlcpy function */