[ovs-dev] [PATCH] Update openvswitch to allow linking from C++ projects

Romain Lenglet rlenglet at vmware.com
Tue Dec 17 01:46:35 UTC 2013


----- Original Message -----
> From: "Harold Lim" <haroldl at vmware.com>
> To: dev at openvswitch.org
> Cc: "Harold Lim" <haroldl at vmware.com>
> Sent: Monday, December 16, 2013 4:53:34 PM
> Subject: [ovs-dev] [PATCH] Update openvswitch to allow linking from C++	projects
> 
> 1. libopenvswitch is updated to be compiled with -fPIC.
> 2. The input variable of ovs_scan is changed from 'template' to
>    'format'. template is a keyword in C++.
> 3. Add an #ifndef guard around NOT_REACHED.
> ---
>  lib/automake.mk |    2 ++
>  lib/util.c      |    8 ++++----
>  lib/util.h      |    4 +++-
>  3 files changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/automake.mk b/lib/automake.mk
> index fadc4be..c391916 100644
> --- a/lib/automake.mk
> +++ b/lib/automake.mk
> @@ -231,6 +231,8 @@ lib_libopenvswitch_a_SOURCES = \
>  	lib/vtep-idl.c \
>  	lib/vtep-idl.h
>  
> +lib_libopenvswitch_a_CFLAGS = -fPIC

Always add $(AM_CFLAGS) in *_CFLAGS variables except in rare cases.

> +
>  nodist_lib_libopenvswitch_a_SOURCES = \
>  	lib/dirs.c
>  CLEANFILES += $(nodist_lib_libopenvswitch_a_SOURCES)
> diff --git a/lib/util.c b/lib/util.c
> index 13d41a7..e12a488 100644
> --- a/lib/util.c
> +++ b/lib/util.c
> @@ -1483,7 +1483,7 @@ scan_chars(const char *s, const struct scan_spec *spec,
> va_list *args)
>  /* This is an implementation of the standard sscanf() function, with the
>   * following exceptions:
>   *
> - *   - It returns true if the entire template was successfully scanned and
> + *   - It returns true if the entire format was successfully scanned and
>   *     converted, false if any conversion failed.
>   *
>   *   - The standard doesn't define sscanf() behavior when an out-of-range
>   value
> @@ -1500,15 +1500,15 @@ scan_chars(const char *s, const struct scan_spec
> *spec, va_list *args)
>   *   - %p is not supported.
>   */
>  bool
> -ovs_scan(const char *s, const char *template, ...)
> +ovs_scan(const char *s, const char *format, ...)
>  {
>      const char *const start = s;
>      bool ok = false;
>      const char *p;
>      va_list args;
>  
> -    va_start(args, template);
> -    p = template;
> +    va_start(args, format);
> +    p = format;
>      while (*p != '\0') {
>          struct scan_spec spec;
>          unsigned char c = *p++;
> diff --git a/lib/util.h b/lib/util.h
> index 8d810c2..1680cd6 100644
> --- a/lib/util.h
> +++ b/lib/util.h
> @@ -150,7 +150,9 @@ is_pow2(uintmax_t x)
>  #define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
>  #endif
>  
> +#ifndef NOT_REACHED
>  #define NOT_REACHED() abort()
> +#endif
>  
>  /* Expands to a string that looks like "<file>:<line>", e.g. "tmp.c:10".
>   *
> @@ -281,7 +283,7 @@ bool str_to_uint(const char *, int base, unsigned int *);
>  bool str_to_ulong(const char *, int base, unsigned long *);
>  bool str_to_ullong(const char *, int base, unsigned long long *);
>  
> -bool ovs_scan(const char *s, const char *template, ...) SCANF_FORMAT(2, 3);
> +bool ovs_scan(const char *s, const char *format, ...) SCANF_FORMAT(2, 3);
>  
>  bool str_to_double(const char *, double *);
>  
> --
> 1.7.9.5
> 
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> https://urldefense.proofpoint.com/v1/url?u=http://openvswitch.org/mailman/listinfo/dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=zXHlW45sT8%2FAsm%2BMbdJ6DyHSNzIfOMAfy9flPhaH%2FAg%3D%0A&m=UTkGUGGMi%2B8W6yifltv3OYpqH0nHFfotgwBuXWDsb2Y%3D%0A&s=011fce1a342c4e6fdf314848b341ec03bf02ac4a0fbb43ed6aea87c1631abc26
> 



More information about the dev mailing list