[ovs-dev] [PATCH] vconn-stream: Make definitions of tcp_vconn_class, etc., easier to find.

Ethan Jackson ethan at nicira.com
Tue Feb 15 22:50:21 UTC 2011


Looks Good.

Ethan

On Fri, Feb 4, 2011 at 3:10 PM, Ben Pfaff <blp at nicira.com> wrote:
> When object definitions are entirely hidden inside macros with token
> pasting tricks, tools like "tags" and even "grep" cannot find them.  This
> change makes the definitions of tcp_vconn_class and other stream-based
> vconns easier to find, by exposing their definitions to these tools.
>
> Reported-by: Yongqiang Liu <liuyq7809 at gmail.com>
> ---
>  AUTHORS            |    1 +
>  lib/vconn-stream.c |   34 +++++++++++++++++-----------------
>  2 files changed, 18 insertions(+), 17 deletions(-)
>
> diff --git a/AUTHORS b/AUTHORS
> index c48479f..6687b41 100644
> --- a/AUTHORS
> +++ b/AUTHORS
> @@ -75,6 +75,7 @@ Stephen Hemminger       shemminger at vyatta.com
>  Takayuki HAMA           t-hama at cb.jp.nec.com
>  Teemu Koponen           koponen at nicira.com
>  Vishal Swarankar        vishal.swarnkar at gmail.com
> +Yongqiang Liu           liuyq7809 at gmail.com
>  kk yap                  yapkke at stanford.edu
>
>  Thanks to all Open vSwitch contributors.  If you are not listed above
> diff --git a/lib/vconn-stream.c b/lib/vconn-stream.c
> index 82854e9..39f1c94 100644
> --- a/lib/vconn-stream.c
> +++ b/lib/vconn-stream.c
> @@ -1,5 +1,5 @@
>  /*
> - * Copyright (c) 2008, 2009, 2010 Nicira Networks.
> + * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
>  *
>  * Licensed under the Apache License, Version 2.0 (the "License");
>  * you may not use this file except in compliance with the License.
> @@ -365,9 +365,9 @@ pvconn_pstream_wait(struct pvconn *pvconn)
>
>  /* Stream-based vconns and pvconns. */
>
> -#define DEFINE_VCONN_STREAM_CLASS(NAME)             \
> -        struct vconn_class NAME##_vconn_class = {   \
> -            #NAME,                                  \
> +#define STREAM_INIT(NAME)                           \
> +    {                                               \
> +            NAME,                                   \
>             vconn_stream_open,                      \
>             vconn_stream_close,                     \
>             vconn_stream_connect,                   \
> @@ -376,27 +376,27 @@ pvconn_pstream_wait(struct pvconn *pvconn)
>             vconn_stream_run,                       \
>             vconn_stream_run_wait,                  \
>             vconn_stream_wait,                      \
> -        };
> +    }
>
> -#define DEFINE_PVCONN_STREAM_CLASS(NAME)            \
> -        struct pvconn_class NAME##_pvconn_class = { \
> -            #NAME,                                  \
> +#define PSTREAM_INIT(NAME)                          \
> +    {                                               \
> +            NAME,                                   \
>             pvconn_pstream_listen,                  \
>             pvconn_pstream_close,                   \
>             pvconn_pstream_accept,                  \
>             pvconn_pstream_wait                     \
> -        };
> +    }
>
> -static DEFINE_VCONN_STREAM_CLASS(stream);
> -static DEFINE_PVCONN_STREAM_CLASS(pstream);
> +static struct vconn_class stream_vconn_class = STREAM_INIT("stream");
> +static struct pvconn_class pstream_pvconn_class = PSTREAM_INIT("pstream");
>
> -DEFINE_VCONN_STREAM_CLASS(tcp);
> -DEFINE_PVCONN_STREAM_CLASS(ptcp);
> +struct vconn_class tcp_vconn_class = STREAM_INIT("tcp");
> +struct pvconn_class ptcp_pvconn_class = PSTREAM_INIT("ptcp");
>
> -DEFINE_VCONN_STREAM_CLASS(unix);
> -DEFINE_PVCONN_STREAM_CLASS(punix);
> +struct vconn_class unix_vconn_class = STREAM_INIT("unix");
> +struct pvconn_class punix_pvconn_class = PSTREAM_INIT("punix");
>
>  #ifdef HAVE_OPENSSL
> -DEFINE_VCONN_STREAM_CLASS(ssl);
> -DEFINE_PVCONN_STREAM_CLASS(pssl);
> +struct vconn_class ssl_vconn_class = STREAM_INIT("ssl");
> +struct pvconn_class pssl_pvconn_class = PSTREAM_INIT("pssl");
>  #endif
> --
> 1.7.1
>
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev_openvswitch.org
>




More information about the dev mailing list