[ovs-dev] [PATCH v2 1/2] ofp-util: New function ofputil_port_to_string().
Ben Pfaff
blp at nicira.com
Mon Jun 24 20:23:08 UTC 2013
On Mon, Jun 24, 2013 at 12:48:25PM -0700, Ansis Atteka wrote:
> On Wed, Jun 12, 2013 at 11:38 AM, Ben Pfaff <blp at nicira.com> wrote:
>
> > This function is more convenient than ofputil_format_port() when a "struct
> > ds" is not already in use. This commit converts one caller for which this
> > was already true, and the following commit will add another.
> >
> > Signed-off-by: Ben Pfaff <blp at nicira.com>
> > ---
> > lib/ofp-util.c | 32 ++++++++++++++++++++++----------
> > lib/ofp-util.h | 2 ++
> > 2 files changed, 24 insertions(+), 10 deletions(-)
> >
> > diff --git a/lib/ofp-util.c b/lib/ofp-util.c
> > index 26da477..3cc4026 100644
> > --- a/lib/ofp-util.c
> > +++ b/lib/ofp-util.c
> > @@ -4144,14 +4144,12 @@ ofputil_port_from_string(const char *s, uint16_t
> > *portp)
> > *portp = port32;
> > return true;
> > } else if (port32 <= OFPP_LAST_RESV) {
> > - struct ds msg;
> > + char name[OFP_MAX_PORT_NAME_LEN];
> >
> > - ds_init(&msg);
> > - ofputil_format_port(port32, &msg);
> > + ofputil_port_to_string(port32, name, sizeof name);
> > VLOG_WARN_ONCE("referring to port %s as %u is deprecated for "
> > "compatibility with future versions of
> > OpenFlow",
> > - ds_cstr(&msg), port32);
> > - ds_destroy(&msg);
> > + name, port32);
> >
> > *portp = port32;
> > return true;
> > @@ -4192,18 +4190,32 @@ ofputil_port_from_string(const char *s, uint16_t
> > *portp)
> > void
> > ofputil_format_port(uint16_t port, struct ds *s)
> >
> {
>
> - const char *name;
> > + char name[OFP_MAX_PORT_NAME_LEN];
> >
> > + ofputil_port_to_string(port, name, sizeof name);
> > + ds_put_cstr(s, name);
> > +}
> > +
> > +/* Puts in the 'bufsize' byte in 'buf' a null-terminated string
> > representation
> >
> Did you mean something like this instead:
>
> Puts in the 'namebuf' buffer that is of size 'bufsize' a null terminated
> string representation...
Yes, thanks.
> Also, It seems that now there is trivial conflict where uint16_t has
> changed to ofp_port_t.
I resolved it, thanks.
I applied this to master.
More information about the dev
mailing list