On 16/02/18 13:15, Jonas Bonn wrote:
On 02/16/2018 01:38 PM, Chris Novakovic wrote:
> Generation of interface statistics files can now be controlled at
> compile-time using the --{enable,disable}-stats configure options.
> Statistics files remain enabled by default.
If this is Feng Wang's patch, then you should have him as the patch
author... if you've massaged it into something unrecognizable, just
mention him as your source of inspiration in the patch comment.
Sorry, that wasn't intentional: this is the first time I've submitted a
patch anywhere using "git format-patch" and when I wrote it my
impression was that the content of the cover letter (and therefore the
credit to Feng) would end up in the log. The patch is now substantially
different to Feng's original (see below), so I've credited him at the
end of the commit message.
> ---
> Makefile.am | 4 ++++
> configure.ac | 5 +++++
> src/stats.c | 36 ++++++++++++++++++++++++++++++++++++
> 3 files changed, 45 insertions(+)
>
> diff --git a/Makefile.am b/Makefile.am
> index 97f1c87d..030b5b8f 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -244,6 +244,10 @@ else
> AM_CPPFLAGS = -I$(builddir)/include -I$(builddir)/src -I$(srcdir)/gdbus
> endif
> +if STATS
> +AM_CPPFLAGS += -DCONNMAN_WITH_STATS
> +endif
> +
> src_connmand_CFLAGS = @DBUS_CFLAGS@ @GLIB_CFLAGS@ \
> @GNUTLS_CFLAGS@ $(builtin_cflags) \
> -DCONNMAN_PLUGIN_BUILTIN \
> diff --git a/configure.ac b/configure.ac
> index 3cdf4b29..cb6512f5 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -380,6 +380,11 @@ AC_ARG_ENABLE(tools,
> AC_HELP_STRING([--disable-tools],
> [enable_tools=${enableval}])
> AM_CONDITIONAL(TOOLS, test "${enable_tools}" != "no")
> +AC_ARG_ENABLE(stats, AC_HELP_STRING([--disable-stats],
> + [disable statistics round robin file generation]),
> + [enable_stats=${enableval}])
> +AM_CONDITIONAL(STATS, test "${enable_stats}" != "no")
Here you are setting a makefile variable in order to have your makefile
pass a definition to the preprocessor. This might be better done with
AC_DEFINE(...) and making sure to #include "config.h" in src/stats.c.
I'm now instead using AC_DEFINE to define STATS, whose existence is
checked inside each relevant function in stats.c rather than defining a
whole new group of function stubs (which might become difficult to
maintain if more functions are added further down the line).