DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] ret_pktmbuf_pool_init problem with opaque_arg
@ 2015-01-09 14:12 Alejandro Lucero
  2015-01-09 14:28 ` Olivier MATZ
  2015-01-09 22:42 ` Stephen Hemminger
  0 siblings, 2 replies; 4+ messages in thread
From: Alejandro Lucero @ 2015-01-09 14:12 UTC (permalink / raw)
  To: dev

Inside this function mbuf_data_room_size is set to a default value if
opaque_arg is null and it should be set to the value pointed by opaque_arg
if not null. Current implementation is using not the value but with the
pointer itself. I think this:

        roomsz = (uint16_t)(uintptr_t)opaque_arg;

should be something like this:

        roomsz = *(uint16_t *)opaque_arg;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] ret_pktmbuf_pool_init problem with opaque_arg
  2015-01-09 14:12 [dpdk-dev] ret_pktmbuf_pool_init problem with opaque_arg Alejandro Lucero
@ 2015-01-09 14:28 ` Olivier MATZ
  2015-01-09 14:38   ` Alejandro Lucero
  2015-01-09 22:42 ` Stephen Hemminger
  1 sibling, 1 reply; 4+ messages in thread
From: Olivier MATZ @ 2015-01-09 14:28 UTC (permalink / raw)
  To: Alejandro Lucero, dev

Hi Alejandro,

On 01/09/2015 03:12 PM, Alejandro Lucero wrote:
> Inside this function mbuf_data_room_size is set to a default value if
> opaque_arg is null and it should be set to the value pointed by opaque_arg
> if not null. Current implementation is using not the value but with the
> pointer itself. I think this:
> 
>         roomsz = (uint16_t)(uintptr_t)opaque_arg;
> 
> should be something like this:
> 
>         roomsz = *(uint16_t *)opaque_arg;
> 

In this particular case, the integer value is stored in the pointer
value: the pointer is not used as a pointer but as an integer. I agree
it can be surprising, but I think the code is correct.

Regards,
Olivier

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] ret_pktmbuf_pool_init problem with opaque_arg
  2015-01-09 14:28 ` Olivier MATZ
@ 2015-01-09 14:38   ` Alejandro Lucero
  0 siblings, 0 replies; 4+ messages in thread
From: Alejandro Lucero @ 2015-01-09 14:38 UTC (permalink / raw)
  To: Olivier MATZ; +Cc: dev

Hi Olivier,



On Fri, Jan 9, 2015 at 2:28 PM, Olivier MATZ <olivier.matz@6wind.com> wrote:

> Hi Alejandro,
>
> On 01/09/2015 03:12 PM, Alejandro Lucero wrote:
> > Inside this function mbuf_data_room_size is set to a default value if
> > opaque_arg is null and it should be set to the value pointed by
> opaque_arg
> > if not null. Current implementation is using not the value but with the
> > pointer itself. I think this:
> >
> >         roomsz = (uint16_t)(uintptr_t)opaque_arg;
> >
> > should be something like this:
> >
> >         roomsz = *(uint16_t *)opaque_arg;
> >
>
> In this particular case, the integer value is stored in the pointer
> value: the pointer is not used as a pointer but as an integer. I agree
> it can be surprising, but I think the code is correct.
>
>
Likely there is a good reason for doing things this way but I can not see
the point.

And it will confuse the user.

Thanks and Regards


> Regards,
> Olivier
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] ret_pktmbuf_pool_init problem with opaque_arg
  2015-01-09 14:12 [dpdk-dev] ret_pktmbuf_pool_init problem with opaque_arg Alejandro Lucero
  2015-01-09 14:28 ` Olivier MATZ
@ 2015-01-09 22:42 ` Stephen Hemminger
  1 sibling, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2015-01-09 22:42 UTC (permalink / raw)
  To: Alejandro Lucero; +Cc: dev

On Fri, 9 Jan 2015 14:12:10 +0000
Alejandro Lucero <alejandro.lucero@netronome.com> wrote:

> Inside this function mbuf_data_room_size is set to a default value if
> opaque_arg is null and it should be set to the value pointed by opaque_arg
> if not null. Current implementation is using not the value but with the
> pointer itself. I think this:
> 
>         roomsz = (uint16_t)(uintptr_t)opaque_arg;
> 
> should be something like this:
> 
>         roomsz = *(uint16_t *)opaque_arg;

That would require an extra value in persistent (not stack) for the size.
The way that is implemented, the caller can just pass the value by
casting to unsigned long.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-01-09 22:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-09 14:12 [dpdk-dev] ret_pktmbuf_pool_init problem with opaque_arg Alejandro Lucero
2015-01-09 14:28 ` Olivier MATZ
2015-01-09 14:38   ` Alejandro Lucero
2015-01-09 22:42 ` Stephen Hemminger

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).