[ovs-dev] [PATCH 1/2] ofp-print: ofp_packet_to_string() Do not emit extra trailing newline
Ben Pfaff
blp at nicira.com
Fri May 17 04:38:56 UTC 2013
On Fri, May 17, 2013 at 12:26:25PM +0900, Simon Horman wrote:
> The string produced by ofp_packet_to_string() includes a trailing
> newline, so in the case where packet data is formatted by
> ofp_print_packet_out() there is already a newline present.
>
> This patch updates ofp_print_packet_out() so that it does not
> add a second newline in this case.
>
> The test-suite has be updated to exercise output of packet data
> by ofp_packet_to_string()
>
> Signed-off-by: Simon Horman <horms at verge.net.au>
This is a good catch. Thank you.
But: do we need to add the \n in the "else" case below? It looks to me
like the higher-level ofp_to_string() function adds a trailing \n if the
string doesn't end in one, so I don't think it's really necessary to add
one here.
> --- a/lib/ofp-print.c
> +++ b/lib/ofp-print.c
> @@ -184,9 +184,8 @@ ofp_print_packet_out(struct ds *string, const struct ofp_header *oh,
> free(packet);
> }
> } else {
> - ds_put_format(string, " buffer=0x%08"PRIx32, po.buffer_id);
> + ds_put_format(string, " buffer=0x%08"PRIx32"\n", po.buffer_id);
> }
> - ds_put_char(string, '\n');
>
> ofpbuf_uninit(&ofpacts);
> }
Thanks,
Ben.
More information about the dev
mailing list