diff mbox series

[iproute2,net-next,v2,2/6] include: Add helper to retrieve a __s64 from a netlink msg

Message ID 20181004231711.6058-3-vinicius.gomes@intel.com
State Changes Requested, archived
Delegated to: David Ahern
Headers show
Series Introduce the taprio scheduler | expand

Commit Message

Vinicius Costa Gomes Oct. 4, 2018, 11:17 p.m. UTC
This allows signed 64-bit integers to be retrieved from a netlink
message.
---
 include/libnetlink.h | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Ilias Apalodimas Oct. 5, 2018, 8:41 a.m. UTC | #1
On Thu, Oct 04, 2018 at 04:17:07PM -0700, Vinicius Costa Gomes wrote:
> This allows signed 64-bit integers to be retrieved from a netlink
> message.
> ---
>  include/libnetlink.h | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/include/libnetlink.h b/include/libnetlink.h
> index 9d9249e6..88164975 100644
> --- a/include/libnetlink.h
> +++ b/include/libnetlink.h
> @@ -185,6 +185,13 @@ static inline __u64 rta_getattr_u64(const struct rtattr *rta)
>  	memcpy(&tmp, RTA_DATA(rta), sizeof(__u64));
>  	return tmp;
>  }
> +static inline __s64 rta_getattr_s64(const struct rtattr *rta)
> +{
> +	__s64 tmp;
> +
> +	memcpy(&tmp, RTA_DATA(rta), sizeof(__s64));
Maybe change it to sizeof(tmp)?
> +	return tmp;
> +}
>  static inline const char *rta_getattr_str(const struct rtattr *rta)
>  {
>  	return (const char *)RTA_DATA(rta);
> -- 
> 2.19.0
>
Vinicius Costa Gomes Oct. 5, 2018, 5:08 p.m. UTC | #2
Hi Ilias,

Ilias Apalodimas <ilias.apalodimas@linaro.org> writes:

> On Thu, Oct 04, 2018 at 04:17:07PM -0700, Vinicius Costa Gomes wrote:
>> This allows signed 64-bit integers to be retrieved from a netlink
>> message.
>> ---
>>  include/libnetlink.h | 7 +++++++
>>  1 file changed, 7 insertions(+)
>> 
>> diff --git a/include/libnetlink.h b/include/libnetlink.h
>> index 9d9249e6..88164975 100644
>> --- a/include/libnetlink.h
>> +++ b/include/libnetlink.h
>> @@ -185,6 +185,13 @@ static inline __u64 rta_getattr_u64(const struct rtattr *rta)
>>  	memcpy(&tmp, RTA_DATA(rta), sizeof(__u64));
>>  	return tmp;
>>  }
>> +static inline __s64 rta_getattr_s64(const struct rtattr *rta)
>> +{
>> +	__s64 tmp;
>> +
>> +	memcpy(&tmp, RTA_DATA(rta), sizeof(__s64));
> Maybe change it to sizeof(tmp)?

Will fix. Thanks.

>> +	return tmp;
>> +}
>>  static inline const char *rta_getattr_str(const struct rtattr *rta)
>>  {
>>  	return (const char *)RTA_DATA(rta);
>> -- 
>> 2.19.0
>> 


Cheers,
--
Vinicius
diff mbox series

Patch

diff --git a/include/libnetlink.h b/include/libnetlink.h
index 9d9249e6..88164975 100644
--- a/include/libnetlink.h
+++ b/include/libnetlink.h
@@ -185,6 +185,13 @@  static inline __u64 rta_getattr_u64(const struct rtattr *rta)
 	memcpy(&tmp, RTA_DATA(rta), sizeof(__u64));
 	return tmp;
 }
+static inline __s64 rta_getattr_s64(const struct rtattr *rta)
+{
+	__s64 tmp;
+
+	memcpy(&tmp, RTA_DATA(rta), sizeof(__s64));
+	return tmp;
+}
 static inline const char *rta_getattr_str(const struct rtattr *rta)
 {
 	return (const char *)RTA_DATA(rta);