[ovs-dev] [PATCH 4/4] ofpbuf: Use ptrdiff_t for pointer delta.

Jarno Rajahalme jarno at ovn.org
Thu Mar 3 21:27:27 UTC 2016


For the series:

Acked-by: Jarno Rajahalme <jarno at ovn.org>

While looking at lib/ofpbuf.c, I noticed a bug for which I’ll send a separate patch.

  Jarno

> On Mar 3, 2016, at 12:22 AM, Joe Stringer <joe at ovn.org> wrote:
> 
> Signed-off-by: Joe Stringer <joe at ovn.org>
> ---
> lib/ofpbuf.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/ofpbuf.c b/lib/ofpbuf.c
> index a3c4da4bcbbe..02c9d15f82bf 100644
> --- a/lib/ofpbuf.c
> +++ b/lib/ofpbuf.c
> @@ -183,8 +183,7 @@ ofpbuf_clone_with_headroom(const struct ofpbuf *buffer, size_t headroom)
>                                                  buffer->size,
>                                                  headroom);
>     if (buffer->header) {
> -        uintptr_t data_delta
> -            = (char *)new_buffer->data - (char *)buffer->data;
> +        ptrdiff_t data_delta = (char *)new_buffer->data - (char *)buffer->data;
> 
>         new_buffer->header = (char *) buffer->header + data_delta;
>     }
> @@ -267,12 +266,12 @@ ofpbuf_resize__(struct ofpbuf *b, size_t new_headroom, size_t new_tailroom)
>     new_data = (char *) new_base + new_headroom;
>     if (b->data != new_data) {
>         if (b->header) {
> -            uintptr_t data_delta = (char *) b->header - (char *) b->data;
> +            ptrdiff_t data_delta = (char *) b->header - (char *) b->data;
> 
>             b->header = (char *) new_data + data_delta;
>         }
>         if (b->msg) {
> -            uintptr_t data_delta = (char *) b->msg - (char *) b->data;
> +            ptrdiff_t data_delta = (char *) b->msg - (char *) b->data;
> 
>             b->msg = (char *) new_data + data_delta;
>         }
> -- 
> 2.1.4
> 




More information about the dev mailing list