From 439f436cda6153c16879d3634626cc315de2cb68 Mon Sep 17 00:00:00 2001 From: "Gary R. Van Sickle" <grvs@users.sourceforge.net> Date: Mon, 8 Feb 2016 18:06:36 -0600 Subject: [PATCH] configure.ac: Added -Wformat -Wformat-security and -Werror=format-security to AM_CXXFLAGS, if compiler supports it. Makefile.am: Added --long option to git describe. Resolves #56. ArgParse.cpp: Changed fprintf() to fputs() to print a non-literal but const string. --- Makefile.am | 4 ++-- configure.ac | 3 ++- src/ArgParse.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index 570026bf..c6460243 100644 --- a/Makefile.am +++ b/Makefile.am @@ -53,7 +53,7 @@ build_info.cpp: FORCE verify-provenance GIT_DESCRIBE=$$(cat $(top_srcdir)/.tarball-version); \ elif (which git && cd $(top_srcdir) && git describe > /dev/null); then \ : We are building from a git repo. ; \ - GIT_DESCRIBE="$$(cd $(top_srcdir) && git describe --dirty)"; \ + GIT_DESCRIBE="$$(cd $(top_srcdir) && git describe --long --dirty)"; \ else GIT_DESCRIBE="unknown"; \ fi; \ echo "const char *g_git_describe = \"$${GIT_DESCRIBE}\";" >> "$@" @@ -74,7 +74,7 @@ verify-provenance: fi; dist-hook: - echo -n "$$(cd $(top_srcdir) && git describe --dirty | tr -d '\r\n')-tarball" > "$(distdir)/.tarball-version" + echo -n "$$(cd $(top_srcdir) && git describe --long --dirty | tr -d '\r\n')-tarball" > "$(distdir)/.tarball-version" ucg_CPPFLAGS = -I $(top_srcdir)/src \ $(BOOST_TR1_CPPFLAGS) $(BOOST_CPPFLAGS) \ diff --git a/configure.ac b/configure.ac index 639e2f64..34804a11 100644 --- a/configure.ac +++ b/configure.ac @@ -177,7 +177,8 @@ AS_IF([test -n $CXX11_FLAG], # Boost generates a ton of these warnings. AX_APPEND_COMPILE_FLAGS([-Wno-unused-local-typedefs], [AM_CXXFLAGS]) AX_APPEND_COMPILE_FLAGS([-pthread], [AM_CXXFLAGS]) -AX_APPEND_COMPILE_FLAGS([-Werror=format-security],[AM_CXXFLAGS]) +AX_APPEND_COMPILE_FLAGS([-Wformat -Wformat-security],[AM_CXXFLAGS]) +AX_APPEND_COMPILE_FLAGS(['-Werror=format-security'],[AM_CXXFLAGS],[-Wformat -Wformat-security]) # Put this back in to help with profiling. #AX_APPEND_COMPILE_FLAGS([-fno-omit-frame-pointer], [AM_CXXFLAGS]) AC_LANG_POP([C++]) diff --git a/src/ArgParse.cpp b/src/ArgParse.cpp index 028c8a88..f7697930 100644 --- a/src/ArgParse.cpp +++ b/src/ArgParse.cpp @@ -343,7 +343,7 @@ void ArgParse::Parse(int argc, char **argv) void ArgParse::PrintVersionText(FILE* stream, struct argp_state* state) { // Print the version string and copyright notice. - std::fprintf(stream, argp_program_version); + std::fputs(argp_program_version, stream); // In addition, we want to print the compiler/version we were built with, the libpcre version and some other info on it, // and any source control version info we can get.