diff mbox

[1/2] Match types for odp_udphdr_t with chksum fuctions

Message ID 1403286379-52829-1-git-send-email-mike.holmes@linaro.org
State Rejected
Headers show

Commit Message

Mike Holmes June 20, 2014, 5:46 p.m. UTC
odp_udphdr_t.chksum can now be assigned from odp_ipv4_udp_chksum() and
odp_chksum() without a sparse warning for different base types

typedef struct ODP_PACKED {
        uint16be_t src_port; /**< Source port */
        uint16be_t dst_port; /**< Destination port */
        uint16be_t length;   /**< UDP datagram length in bytes
(header+data) */
        uint16be_t chksum;   /**< UDP header and data checksum (0 if not
used)*/
} odp_udphdr_t;

Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---
 include/helper/odp_chksum.h | 2 +-
 include/helper/odp_udp.h    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Anders Roxell June 22, 2014, 11:20 p.m. UTC | #1
On 2014-06-20 13:46, Mike Holmes wrote:
> odp_udphdr_t.chksum can now be assigned from odp_ipv4_udp_chksum() and
> odp_chksum() without a sparse warning for different base types
> 
> typedef struct ODP_PACKED {
>         uint16be_t src_port; /**< Source port */
>         uint16be_t dst_port; /**< Destination port */
>         uint16be_t length;   /**< UDP datagram length in bytes
> (header+data) */
>         uint16be_t chksum;   /**< UDP header and data checksum (0 if not
> used)*/
> } odp_udphdr_t;
> 
> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
> ---
>  include/helper/odp_chksum.h | 2 +-
>  include/helper/odp_udp.h    | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/helper/odp_chksum.h b/include/helper/odp_chksum.h
> index 12ef61f..b2455f6 100644
> --- a/include/helper/odp_chksum.h
> +++ b/include/helper/odp_chksum.h
> @@ -27,7 +27,7 @@ extern "C" {
>   *
>   * @return checksum value
>   */
> -static inline uint16_t odp_chksum(void *buffer, int len)
> +static inline uint16be_t odp_chksum(void *buffer, int len)
>  {
>  	uint16_t *buf = buffer;
>  	unsigned int sum = 0;
> diff --git a/include/helper/odp_udp.h b/include/helper/odp_udp.h
> index 5aedb36..8adfc78 100644
> --- a/include/helper/odp_udp.h
> +++ b/include/helper/odp_udp.h
> @@ -50,7 +50,7 @@ typedef struct ODP_PACKET {
>   * @param pkt  calculate chksum for pkt
>   * @return  checksum value
>   */
> -static inline uint16_t odp_ipv4_udp_chksum(odp_packet_t pkt)
> +static inline uint16be_t odp_ipv4_udp_chksum(odp_packet_t pkt)
>  {
>  	uint32_t sum = 0;
>  	odp_udpphdr_t phdr;
> -- 
> 1.9.1
> 
> 
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp

+../../build/include/helper/odp_chksum.h:46:16: warning: incorrect type
in return expression (different base types)
+../../build/include/helper/odp_chksum.h:46:16:    expected restricted
uint16be_t
+../../build/include/helper/odp_chksum.h:46:16:    got unsigned short
[unsigned] [assigned] [usertype] result
+odp_timer_ping.c:170:35: warning: incorrect type in assignment
(different base types)
+odp_timer_ping.c:170:35:    expected unsigned short [unsigned]
[addressable] [assigned] [usertype] checksum
+odp_timer_ping.c:170:35:    got restricted uint16be_t

This warnings got introduced with this patch or did I do something
wrong?

Cheers,
Anders
Mike Holmes June 23, 2014, 3:43 p.m. UTC | #2
Let me look and see if I missed something


On 22 June 2014 19:20, Anders Roxell <anders.roxell@linaro.org> wrote:

> On 2014-06-20 13:46, Mike Holmes wrote:
> > odp_udphdr_t.chksum can now be assigned from odp_ipv4_udp_chksum() and
> > odp_chksum() without a sparse warning for different base types
> >
> > typedef struct ODP_PACKED {
> >         uint16be_t src_port; /**< Source port */
> >         uint16be_t dst_port; /**< Destination port */
> >         uint16be_t length;   /**< UDP datagram length in bytes
> > (header+data) */
> >         uint16be_t chksum;   /**< UDP header and data checksum (0 if not
> > used)*/
> > } odp_udphdr_t;
> >
> > Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
> > ---
> >  include/helper/odp_chksum.h | 2 +-
> >  include/helper/odp_udp.h    | 2 +-
> >  2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/helper/odp_chksum.h b/include/helper/odp_chksum.h
> > index 12ef61f..b2455f6 100644
> > --- a/include/helper/odp_chksum.h
> > +++ b/include/helper/odp_chksum.h
> > @@ -27,7 +27,7 @@ extern "C" {
> >   *
> >   * @return checksum value
> >   */
> > -static inline uint16_t odp_chksum(void *buffer, int len)
> > +static inline uint16be_t odp_chksum(void *buffer, int len)
> >  {
> >       uint16_t *buf = buffer;
> >       unsigned int sum = 0;
> > diff --git a/include/helper/odp_udp.h b/include/helper/odp_udp.h
> > index 5aedb36..8adfc78 100644
> > --- a/include/helper/odp_udp.h
> > +++ b/include/helper/odp_udp.h
> > @@ -50,7 +50,7 @@ typedef struct ODP_PACKET {
> >   * @param pkt  calculate chksum for pkt
> >   * @return  checksum value
> >   */
> > -static inline uint16_t odp_ipv4_udp_chksum(odp_packet_t pkt)
> > +static inline uint16be_t odp_ipv4_udp_chksum(odp_packet_t pkt)
> >  {
> >       uint32_t sum = 0;
> >       odp_udpphdr_t phdr;
> > --
> > 1.9.1
> >
> >
> > _______________________________________________
> > lng-odp mailing list
> > lng-odp@lists.linaro.org
> > http://lists.linaro.org/mailman/listinfo/lng-odp
>
> +../../build/include/helper/odp_chksum.h:46:16: warning: incorrect type
> in return expression (different base types)
> +../../build/include/helper/odp_chksum.h:46:16:    expected restricted
> uint16be_t
> +../../build/include/helper/odp_chksum.h:46:16:    got unsigned short
> [unsigned] [assigned] [usertype] result
> +odp_timer_ping.c:170:35: warning: incorrect type in assignment
> (different base types)
> +odp_timer_ping.c:170:35:    expected unsigned short [unsigned]
> [addressable] [assigned] [usertype] checksum
> +odp_timer_ping.c:170:35:    got restricted uint16be_t
>
> This warnings got introduced with this patch or did I do something
> wrong?
>
> Cheers,
> Anders
>
Mike Holmes June 23, 2014, 9:29 p.m. UTC | #3
There is a more fundamental problem with this, so do not apply this patch,
but please read the new thread on the checksum implementation.


On 23 June 2014 11:43, Mike Holmes <mike.holmes@linaro.org> wrote:

> Let me look and see if I missed something
>
>
> On 22 June 2014 19:20, Anders Roxell <anders.roxell@linaro.org> wrote:
>
>> On 2014-06-20 13:46, Mike Holmes wrote:
>> > odp_udphdr_t.chksum can now be assigned from odp_ipv4_udp_chksum() and
>> > odp_chksum() without a sparse warning for different base types
>> >
>> > typedef struct ODP_PACKED {
>> >         uint16be_t src_port; /**< Source port */
>> >         uint16be_t dst_port; /**< Destination port */
>> >         uint16be_t length;   /**< UDP datagram length in bytes
>> > (header+data) */
>> >         uint16be_t chksum;   /**< UDP header and data checksum (0 if not
>> > used)*/
>> > } odp_udphdr_t;
>> >
>> > Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
>> > ---
>> >  include/helper/odp_chksum.h | 2 +-
>> >  include/helper/odp_udp.h    | 2 +-
>> >  2 files changed, 2 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/include/helper/odp_chksum.h b/include/helper/odp_chksum.h
>> > index 12ef61f..b2455f6 100644
>> > --- a/include/helper/odp_chksum.h
>> > +++ b/include/helper/odp_chksum.h
>> > @@ -27,7 +27,7 @@ extern "C" {
>> >   *
>> >   * @return checksum value
>> >   */
>> > -static inline uint16_t odp_chksum(void *buffer, int len)
>> > +static inline uint16be_t odp_chksum(void *buffer, int len)
>> >  {
>> >       uint16_t *buf = buffer;
>> >       unsigned int sum = 0;
>> > diff --git a/include/helper/odp_udp.h b/include/helper/odp_udp.h
>> > index 5aedb36..8adfc78 100644
>> > --- a/include/helper/odp_udp.h
>> > +++ b/include/helper/odp_udp.h
>> > @@ -50,7 +50,7 @@ typedef struct ODP_PACKET {
>> >   * @param pkt  calculate chksum for pkt
>> >   * @return  checksum value
>> >   */
>> > -static inline uint16_t odp_ipv4_udp_chksum(odp_packet_t pkt)
>> > +static inline uint16be_t odp_ipv4_udp_chksum(odp_packet_t pkt)
>> >  {
>> >       uint32_t sum = 0;
>> >       odp_udpphdr_t phdr;
>> > --
>> > 1.9.1
>> >
>> >
>> > _______________________________________________
>> > lng-odp mailing list
>> > lng-odp@lists.linaro.org
>> > http://lists.linaro.org/mailman/listinfo/lng-odp
>>
>> +../../build/include/helper/odp_chksum.h:46:16: warning: incorrect type
>> in return expression (different base types)
>> +../../build/include/helper/odp_chksum.h:46:16:    expected restricted
>> uint16be_t
>> +../../build/include/helper/odp_chksum.h:46:16:    got unsigned short
>> [unsigned] [assigned] [usertype] result
>> +odp_timer_ping.c:170:35: warning: incorrect type in assignment
>> (different base types)
>> +odp_timer_ping.c:170:35:    expected unsigned short [unsigned]
>> [addressable] [assigned] [usertype] checksum
>> +odp_timer_ping.c:170:35:    got restricted uint16be_t
>>
>> This warnings got introduced with this patch or did I do something
>> wrong?
>>
>> Cheers,
>> Anders
>>
>
>
>
> --
> *Mike Holmes*
> Linaro Technical Manager / Lead
> LNG - ODP
>
diff mbox

Patch

diff --git a/include/helper/odp_chksum.h b/include/helper/odp_chksum.h
index 12ef61f..b2455f6 100644
--- a/include/helper/odp_chksum.h
+++ b/include/helper/odp_chksum.h
@@ -27,7 +27,7 @@  extern "C" {
  *
  * @return checksum value
  */
-static inline uint16_t odp_chksum(void *buffer, int len)
+static inline uint16be_t odp_chksum(void *buffer, int len)
 {
 	uint16_t *buf = buffer;
 	unsigned int sum = 0;
diff --git a/include/helper/odp_udp.h b/include/helper/odp_udp.h
index 5aedb36..8adfc78 100644
--- a/include/helper/odp_udp.h
+++ b/include/helper/odp_udp.h
@@ -50,7 +50,7 @@  typedef struct ODP_PACKET {
  * @param pkt  calculate chksum for pkt
  * @return  checksum value
  */
-static inline uint16_t odp_ipv4_udp_chksum(odp_packet_t pkt)
+static inline uint16be_t odp_ipv4_udp_chksum(odp_packet_t pkt)
 {
 	uint32_t sum = 0;
 	odp_udpphdr_t phdr;