Re: [PATCH] Avoid double-including config.h

2017-05-02 Thread Ulf Hermann

Maybe we can cleanup that last
one once we integrate gnulib (which I believe has a good/64-off_t fts.h
already).


gnulib is among the bad ones. Or, at least we detect it as bad.

Ulf


Re: [PATCH] Avoid double-including config.h

2017-05-02 Thread Mark Wielaard
On Thu, 2017-04-20 at 16:31 +0200, Ulf Hermann wrote:
> config.h doesn't have include guards, so including it twice is bad. We
> deal with this by checking for PACKAGE_NAME, but only in some places.
> Once we start using gnulib, we will need to include config.h before any
> gnulib-generated headers. This is problematic if we include it
> transitively through our own private headers.
> 
> In order to set a clear rule about inclusion of config.h, it is now
> included in every .c file as first header, but not in any header. This
> will definitely avoid double-inclusion and satisfy the condition that it
> has to be included before gnulib headers. It comes at the price of
> adding some redundancy, but there is no clean way to avoid this.

It seems a clear rule that is easy to follow. The only exceptions are
the crc32.c file which gets included itself and the
linux-kernel-modules.c which needs the ugly BAD_FTS check before
config.h (which your patch both handles). Maybe we can cleanup that last
one once we integrate gnulib (which I believe has a good/64-off_t fts.h
already).

Applied to master.

Thanks,

Mark


[PATCH] Avoid double-including config.h

2017-04-20 Thread Ulf Hermann
config.h doesn't have include guards, so including it twice is bad. We
deal with this by checking for PACKAGE_NAME, but only in some places.
Once we start using gnulib, we will need to include config.h before any
gnulib-generated headers. This is problematic if we include it
transitively through our own private headers.

In order to set a clear rule about inclusion of config.h, it is now
included in every .c file as first header, but not in any header. This
will definitely avoid double-inclusion and satisfy the condition that it
has to be included before gnulib headers. It comes at the price of
adding some redundancy, but there is no clean way to avoid this.

Signed-off-by: Ulf Hermann 
---
 lib/ChangeLog   |  5 +++
 lib/crc32.c |  4 ++
 lib/system.h|  4 --
 libdwfl/ChangeLog   | 58 +
 libdwfl/argp-std.c  |  4 ++
 libdwfl/cu.c|  4 ++
 libdwfl/derelocate.c|  4 ++
 libdwfl/dwfl_addrdie.c  |  4 ++
 libdwfl/dwfl_addrdwarf.c|  4 ++
 libdwfl/dwfl_addrmodule.c   |  4 ++
 libdwfl/dwfl_begin.c|  4 ++
 libdwfl/dwfl_build_id_find_debuginfo.c  |  4 ++
 libdwfl/dwfl_build_id_find_elf.c|  4 ++
 libdwfl/dwfl_cumodule.c |  4 ++
 libdwfl/dwfl_dwarf_line.c   |  4 ++
 libdwfl/dwfl_end.c  |  4 ++
 libdwfl/dwfl_frame.c|  4 ++
 libdwfl/dwfl_frame_regs.c   |  4 ++
 libdwfl/dwfl_getdwarf.c |  4 ++
 libdwfl/dwfl_getmodules.c   |  4 ++
 libdwfl/dwfl_getsrc.c   |  4 ++
 libdwfl/dwfl_getsrclines.c  |  4 ++
 libdwfl/dwfl_line_comp_dir.c|  4 ++
 libdwfl/dwfl_linecu.c   |  4 ++
 libdwfl/dwfl_lineinfo.c |  4 ++
 libdwfl/dwfl_linemodule.c   |  4 ++
 libdwfl/dwfl_module.c   |  4 ++
 libdwfl/dwfl_module_addrdie.c   |  4 ++
 libdwfl/dwfl_module_addrname.c  |  4 ++
 libdwfl/dwfl_module_addrsym.c   |  4 ++
 libdwfl/dwfl_module_build_id.c  |  4 ++
 libdwfl/dwfl_module_dwarf_cfi.c |  4 ++
 libdwfl/dwfl_module_eh_cfi.c|  4 ++
 libdwfl/dwfl_module_getdwarf.c  |  4 ++
 libdwfl/dwfl_module_getelf.c|  4 ++
 libdwfl/dwfl_module_getsrc.c|  4 ++
 libdwfl/dwfl_module_getsrc_file.c   |  4 ++
 libdwfl/dwfl_module_getsym.c|  4 ++
 libdwfl/dwfl_module_info.c  |  4 ++
 libdwfl/dwfl_module_nextcu.c|  4 ++
 libdwfl/dwfl_module_register_names.c|  4 ++
 libdwfl/dwfl_module_report_build_id.c   |  4 ++
 libdwfl/dwfl_module_return_value_location.c |  4 ++
 libdwfl/dwfl_nextcu.c   |  4 ++
 libdwfl/dwfl_onesrcline.c   |  4 ++
 libdwfl/dwfl_report_elf.c   |  4 ++
 libdwfl/dwfl_validate_address.c |  4 ++
 libdwfl/dwfl_version.c  |  4 ++
 libdwfl/find-debuginfo.c|  4 ++
 libdwfl/gzip.c  |  4 ++
 libdwfl/image-header.c  |  4 ++
 libdwfl/libdwflP.h  |  3 --
 libdwfl/lines.c |  4 ++
 libdwfl/linux-core-attach.c |  4 ++
 libdwfl/linux-pid-attach.c  |  4 ++
 libdwfl/linux-proc-maps.c   |  4 ++
 libdwfl/offline.c   |  4 ++
 libdwfl/open.c  |  4 ++
 libdwfl/relocate.c  |  4 ++
 libdwfl/segment.c   |  4 ++
 libelf/ChangeLog|  4 ++
 libelf/libelfP.h|  4 --
 62 files changed, 291 insertions(+), 11 deletions(-)

diff --git a/lib/ChangeLog b/lib/ChangeLog
index 84290f7..8cac7af 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,8 @@
+2017-04-20  Ulf Hermann  
+
+   * crc32.c: include config.h.
+   * system.h: Don't include config.h.
+
 2017-02-16  Ulf Hermann  
 
* Makefile.am (libeu_a_SOURCES): Remove version.c, add printversion.c
diff --git a/lib/crc32.c b/lib/crc32.c
index 1a76b1b..758602e 100644
--- a/lib/crc32.c
+++ b/lib/crc32.c
@@ -25,6 +25,10 @@
the GNU Lesser General Public License along with this program.  If
not, see .  */
 
+#if HAVE_CONFIG_H
+#include 
+#endif
+
 #include 
 #include "system.h"
 
diff --git a/lib/system.h b/lib/system.h
index 2d05702..9203335 100644
--- a/lib/system.h
+++ b/lib/system.h
@@ -29,10 +29,6 @@
 #ifndef LIB_SYSTEM_H
 #define LIB_SYSTEM_H   1
 
-#ifdef HAVE_CONFIG_H
-#