Commit Graph

325 Commits

Author SHA1 Message Date
Eric Blake
d940e3bdb9 build: silence some compiler warnings from gnulib
Gnulib claims that there are some classes of warnings that are
worth enabling during development, but where silencing those
warnings causes code bloat that is not necessary in an optimized
build.  The code bloat to silence the warnings is only enabled
by -Dlint.  Follow the lead of coreutils in setting up -Dlint
whenever full warnings are requested.

* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Add
-Dlint, and move _FORTIFY_SOURCE to config.h instead of CFLAGS.
2012-01-19 13:14:10 -07:00
Eric Blake
f17e0e2182 build: reduce warnings from older gcc
Older gcc warns (on every file!) that -Wabi and -Wdeprecated only
make sense on C++ projects.  Newer gcc accepts these warnings for
C, but it is not clear that they can do anything useful, so it
is easier to just drop the warnings altogether.

* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Silence
-Wabi and -Wdeprecated on older gcc.
Reported by Peter Krempa.
2011-12-05 10:14:55 -07:00
Eric Blake
75da320087 build: fix build at -O2 on rawhide
I had previously tested commit 059d746 with -O intentionally omitted
from my CFLAGS; but that means that I missed out on this warning
from gcc 4.6.2 when optimizations are enabled:

util/buf.c: In function 'virBufferGetIndent':
util/buf.c:86:1: error: function might be candidate for attribute 'pure' [-Werror=suggest-attribute=pure]

While it is probably a good idea to add the attributes and silence
this warning, it's also invasive; 'make -k' found more than 75 such
complaints.  And it doesn't help that gcc 4.6.2 is still buggy
(coreutils reported a case where gcc 4.6.2 incorrectly suggested
marking a function pure that incremented a global variable; fixed
in gcc 4.7).  So the best fix for now is to disable the warning.

It also doesn't help that I stumbled across another problem - gcc
documents that -Wsuggest-attribute=pure only warns if you use -O,
or if you use -fipa-pure-const.  But in practice, when I omitted -O
but added -fipa-pure-const, the warnings are fickle - I got warnings
for simple compilation that disappeared when I also added -fPIC.
And the way libtool compiles things is with -fPIC first, then without
-fPIC but with errors sent to /dev/null - which meant that without
disabling -Wsuggest-attribute=pure, I got a compile error with no
message.  :(  See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10197

* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Silence
-Wsuggest-attribute warnings for now.
2011-12-02 13:00:57 -07:00
Eric Blake
059d746ddb build: update to latest gnulib
* .gnulib: Update to latest, for improved 'make syntax-check' and
compiler warnings.
* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS):
Re-silence -Wformat-nonliteral.
* cfg.mk (_test_script_regex): Recognize our test scripts.
* gnulib/local/lib/*.diff: Drop, now that gnulib has this.
* tests/virsh-optparse: Fix use of compare.
* tests/virsh-schedinfo: Likewise.
2011-12-01 14:12:59 -07:00
Matthias Bolte
9ba4eb3c08 tests: Lower stack usage below 4096 bytes
Make virtTestLoadFile allocate the buffer to read the file into.

Fix logic error in virtTestLoadFile, stop reading on the first empty line.

Use virFileReadLimFD in virtTestCaptureProgramOutput to avoid manual
buffer handling.
2011-04-30 19:59:52 +02:00
Eric Blake
02c39a2f6d build: fix gitignore sorting
Make it so we don't have to 'git add -f' particular files like
po/POTFILES.in all the time (tested by fixing one of our
special-case files as part of the patch).

* .gnulib: Update to latest.
* bootstrap: Resync from coreutils.
* .gitignore: Sort whitelist entries correctly, including ignoring
files rather than directories.
* m4/virt-compile-warnings.m4: Convert tabs to space.
2011-04-07 15:03:53 -06:00
Jim Fehlig
3df6fd706c Fix build for older gcc
With gcc 4.3.4 I'm seeing the following warning failure

cc1: warnings being treated as errors
cc1: error: -funit-at-a-time is required for inlining of functions
that are only called once [-Wdisabled-optimization]

Add -funit-at-a-time to WARN_CFLAGS.
2011-04-06 15:05:45 -06:00
Daniel P. Berrange
dba5ba62bb Don't try to enable stack protector on Win32
The GCC Win32 compiler will claim to support -fstack-protector,
but if it actually gets triggered by a suitable code pattern,
linking will fail. Other non-Linux OS likely suffer the same
way with gcc.

* m4/virt-compile-warnings.m4: Only use stack protector when
  the build target is Linux.
2011-04-05 17:43:40 +01:00
Daniel P. Berrange
a4e37ff1a3 Enable use of -Wold-style-definition compiler flag
A couple of functions were declared using the old style foo()
for no-parameters, instead of foo(void)

* src/xen/xen_hypervisor.c, tests/testutils.c: Replace () with (void)
  in some function declarations
* m4/virt-compile-warnings.m4: Enable -Wold-style-definition
2011-04-05 11:40:04 +01:00
Daniel P. Berrange
329e9dc629 Enable use of -Wmissing-noreturn
* src/internal.h: Define a ATTRIBUTE_NO_RETURN annotation
* src/lxc/lxc_container.c: Annotate lxcContainerDummyChild
  with ATTRIBUTE_NO_RETURN
* tests/eventtest.c: Mark async thread as ATTRIBUTE_NO_RETURN
* m4/virt-compile-warnings.m4: Enable -Wmissing-noreturn
2011-04-05 11:39:58 +01:00
Daniel P. Berrange
7d76d5d506 Enable -Wmissing-format-attribute warning
Add a couple of missing ATTRIBUTE_FMT_PRINTF annotations

* tools/virsh.c, tests/testutils.c: Add printf format attribute
* m4/virt-compile-warnings.m4: Enable -Wmissing-format-attribute
2011-04-05 11:39:52 +01:00
Daniel P. Berrange
4825b521e2 Remove acinclude.m4 file
Split the bit acinclude.m4 file into smaller pieces named
as m4/virt-XXXXX.m4

* .gitignore: Ignore gettext related files
* acinclude.m4: Delete
* m4/virt-compile-warnings.m4: Checks for GCC compiler flags
* m4/virt-pkgconfig-back-compat.m4: Backcompat check for
  pkgconfig program
2011-04-05 11:39:44 +01:00
Daniel P. Berrange
0e867555bd Use gnulib's manywarnings & warnings modules
Remove custom code for checking compiler warnings, using
gl_WARN_ADD instead. Don't list all flags ourselves, use
gnulib's gl_MANYWARN_ALL_GCC to get all possible GCC flags,
then turn off the ones we don't want yet.

* acinclude.m4: Rewrite to use gl_WARN_ADD and gl_MANYWARN_ALL_GCC
* bootstrap.conf: Add warnings & manywarnings
* configure.ac: Switch to gl_WARN_ADD
* m4/compiler-flags.m4: Obsoleted by gl_WARN_ADD
2011-04-05 11:39:35 +01:00
Eric Blake
144c06d4ee maint: update to latest gnulib
Allows bootstrap to work on FreeBSD, where gzip doesn't have a '.'
in its version; and silences false positives in the new
'make syntax-check' rule.

* .gnulib: Update to latest.
* bootstrap: Synchronize to upstream.
* .x-sc_bindtextdomain: New exemptions.
* Makefile.am (syntax_check_exceptions): Ship new file.
* .gitignore: Regenerate per latest bootstrap, anchor entries that
are only in the root directory, and consolidate entries from other
generated .gitignore files.
* build-aux/.gitignore, m4/.gitignore, po/.gitignore: Remove from
version control, since bootstrap generates them.
2010-11-17 10:13:12 -07:00
Eric Blake
e7064aa6a2 build: restore operation of bit-rotted 'make cov'
'./autobuild.sh' with lcov installed discovered that our
coverage support has been bit-rotting for a while.  This
restores it back to a successful state, although I have
not yet spent any time looking through the resulting files to
look for low-hanging fruit in the unit test coverage front.

* configure.ac: Clear COMPILER_FLAGS at right place.
* Makefile.am (cov): Newer genhtml no longer likes plain -s.
* m4/compiler-flags.m4 (gl_COMPILER_FLAGS): Don't AC_SUBST
COMPILER_FLAGS; it is a shell variable for use in configure only.
* src/Makefile.am (AM_CFLAGS, AM_LDFLAGS): New variables, to make
it easier to provide global flag additions.  Use throughout, to
uniformly apply coverage flags.
* .gitignore: Globally ignore gcov output.
* daemon/.gitignore: Simplify.
* src/.gitignore: Likewise.
* tests/.gitignore: Likewise.
2010-07-29 13:41:25 -06:00
Eric Blake
e07cf19fe5 build: don't use "test cond1 -o cond2": it's not portable
* configure.ac: Use "test cond1 || test cond2" instead.
* m4/compiler-flags.m4 (gl_COMPILER_FLAGS): Likewise.
* tests/test-lib.sh (verbose): Likewise.
2010-03-25 09:28:24 +01:00
Jim Meyering
fb98f4b10d remove all .cvsignore files 2009-07-08 16:17:51 +02:00
Daniel P. Berrange
aaabde58cb Remove trailing whitespace from m4 file 2009-04-30 13:30:51 +00:00
Daniel P. Berrange
cb4a6614fa Fix check for -Wformat-security which depends on -Wformat 2009-04-28 10:55:45 +00:00
Jim Meyering
5f0c720163 .cvsignore: Add explicit list of generated files.
* .hgignore: Regenerate.
* m4/.gitignore: Regenerate.
2009-01-23 16:15:49 +00:00
Jim Meyering
48dc345f2d correct and tighten up .*ignore files
* .cvsignore: Don't ignore *.orig or *.rej.  They're not build products.
Don't ignore the entire m4 directory.
* Makefile.maint (sync-vcs-ignore-files): Correct quoting.
Use sed rather than a for loop.
Search only version-controled files (for reproducibility)
* gnulib/lib/netinet/.cvsignore: Append missing newline-at-EOF,
so that the use of sed doesn't mistakenly concatenate lines.
* gnulib/lib/sys/.cvsignore: Likewise.
* m4/.cvsignore: Ignore acinclude.m4 and aclocal.m4, not *.m4.
* .hgignore: Regenerate.
* all .gitignore files: Regenerate.
2009-01-23 13:32:17 +00:00
John Levon
a7acdde406 generate .hgignore 2009-01-22 19:03:11 +00:00
John Levon
d052118dae Improve compiler flag checking 2009-01-14 15:23:26 +00:00
Jim Meyering
261e7581b1 Use gnulib, starting with its physmem and getaddrinfo modules.
New files go into these directories:
  gnulib/lib
  gnulib/m4
  gnulib/tests

* bootstrap: A wrapper around gnulib-tool.
* configure.in: Invoke gl_EARLY and gl_INIT, being careful to put gl_EARLY
before any macro that uses AC_COMPILE_IFELSE.
(AC_OUTPUT): Add lib/Makefile and gl-tests/Makefile.  Remove m4/Makefile.
* Makefile.am (SUBDIRS): Add gnulib/lib and remove m4.  Add gnulib/tests
early enough that those tests run before any libvirt unit tests.
* m4/Makefile.am: Remove file.  Not needed.
* src/Makefile.am (INCLUDES): Add -I$(top_srcdir)/gnulib/lib -I../gnulib/lib.
(LDADDS, libvirt_la_LIBADD): Add ../gnulib/lib/libgnu.la.
* src/nodeinfo.c: Include "physmem.h".
* qemud/qemud.c, src/remote_internal.c: Include "getaddrinfo.h".
(MEMINFO_PATH, linuxNodeInfoMemPopulate): Remove definitions.
(virNodeInfoPopulate): Use physmem_total, not linuxNodeInfoMemPopulate.
* tests/Makefile.am (INCLUDES): Add -I$(top_srcdir)/gnulib/lib -I../gnulib/lib.
(LDADDS): Add ../gnulib/lib/libgnu.la.
* qemud/Makefile.am (libvirtd_LDADD): Add ../gnulib/lib/libgnu.la.
* tests/nodeinfotest.c (linuxTestCompareFiles): No longer read total
memory from a file.
Update expected output not to include "Memory: NNNN"
* tests/nodeinfodata/linux-nodeinfo-1.txt:
* tests/nodeinfodata/linux-nodeinfo-2.txt:
* tests/nodeinfodata/linux-nodeinfo-3.txt:
* tests/nodeinfodata/linux-nodeinfo-4.txt:
* tests/nodeinfodata/linux-nodeinfo-5.txt:
* tests/nodeinfodata/linux-nodeinfo-6.txt:
* src/test.c [WITH_TEST]: Remove definition of _GNU_SOURCE that
would conflict with the one now in "config.h".
* autogen.sh: Add -I gnulib/m4.
* src/conf.c, src/sexpr.c: Don't define _GNU_SOURCE.
Instead, include "config.h".
* qemud/qemud.c: Remove definition of _GNU_SOURCE.
* src/openvz_driver.c: Likewise.
* src/qemu_driver.c: Likewise.
* src/remote_internal.c: Likewise.

* configure.in: Use AC_CONFIG_AUX_DIR(build-aux), so that a bunch
of gettextize-generated files go into build-aux/, rather than in
the top-level directory.
* .cvsignore: Adjust.
* build-aux/.cvsignore: New file.


Author: Jim Meyering <meyering@redhat.com>
2007-12-05 21:31:07 +00:00
Daniel P. Berrange
d09a9a4294 Added m4 scripts to check compiler flags 2007-02-14 02:29:20 +00:00