Commit 291237b4 authored by David Gibson's avatar David Gibson Committed by Rusty Russell

ccan: Correct some poor conventions in _info includes

There are a couple of small problems with the includes used in most of
ccan's _info files.

   * _info routinely uses printf(), and so should include <stdio.h>, but
only some of them do.  We get away with it, because they do include
<string.h>, which apparently includes <stdio.h> indirectly, but we should
be explicit about it.

   * Most _info files were including config.h after the system headers.
That _seems_ sensible, but actually causes problems.  Because config.h
defines _GNU_SOURCE it can change the behaviour of the system headers.
More specifically it can make them behave differently to how the individual
module headers (which have included config.h) expects them to behave.

This patch adjusts all the existing _info files and, more importantly,
the template constructed by ccanlint.
Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 9a483e66
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* alignof - ALIGNOF() macro to determine alignment of a type. * alignof - ALIGNOF() macro to determine alignment of a type.
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* antithread - Accelerated Native Technology Implementation of "threads" * antithread - Accelerated Native Technology Implementation of "threads"
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* antithread/alloc - memory allocator routines * antithread/alloc - memory allocator routines
......
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* argcheck - macros to check arguments at runtime * argcheck - macros to check arguments at runtime
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* array_size - routine for safely deriving the size of a visible array. * array_size - routine for safely deriving the size of a visible array.
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* asearch - typesafe binary search (bsearch) * asearch - typesafe binary search (bsearch)
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* asprintf - asprintf wrapper (and if necessary, implementation). * asprintf - asprintf wrapper (and if necessary, implementation).
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* autodata - stash pointers in your binary for automatic registration * autodata - stash pointers in your binary for automatic registration
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* avl - Key-value dictionary based on AVL trees * avl - Key-value dictionary based on AVL trees
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* bdelta - Generate and apply binary deltas * bdelta - Generate and apply binary deltas
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* bitmap - bitmap handling * bitmap - bitmap handling
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* block_pool - An efficient allocator for blocks that don't need to be resized or freed. * block_pool - An efficient allocator for blocks that don't need to be resized or freed.
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* breakpoint - break if the program is run under gdb. * breakpoint - break if the program is run under gdb.
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* btree - Efficient sorted associative container based on B-trees. * btree - Efficient sorted associative container based on B-trees.
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* build_assert - routines for build-time assertions * build_assert - routines for build-time assertions
......
#include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h" #include "config.h"
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* cast - routines for safer casting. * cast - routines for safer casting.
......
#include "config.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "config.h"
/** /**
* ccan_tokenizer - A full-text lexer for C source files * ccan_tokenizer - A full-text lexer for C source files
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* charset - character set conversion and validation routines * charset - character set conversion and validation routines
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* check_type - routines for compile time type checking * check_type - routines for compile time type checking
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* ciniparser - easily parse and manipulate ini style configuration files * ciniparser - easily parse and manipulate ini style configuration files
......
#include "config.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "config.h"
/** /**
* compiler - macros for common compiler extensions * compiler - macros for common compiler extensions
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* container_of - routine for upcasting * container_of - routine for upcasting
......
#include "config.h"
#include <stdio.h>
#include <string.h>
#include "cpuid.h" #include "cpuid.h"
/** /**
......
#include "config.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* crcsync - routines to use crc for an rsync-like protocol. * crcsync - routines to use crc for an rsync-like protocol.
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* daemon_with_notify - daemonize a process, can wait for child to signal readiness * daemon_with_notify - daemonize a process, can wait for child to signal readiness
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* daemonize - routine to turn a process into a well-behaved daemon. * daemonize - routine to turn a process into a well-behaved daemon.
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
#include "ccan/darray/darray.h" #include "ccan/darray/darray.h"
......
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h> #include <string.h>
/** /**
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* endian - endian conversion macros for simple types * endian - endian conversion macros for simple types
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* err - err(), errx(), warn() and warnx(), as per BSD's err.h. * err - err(), errx(), warn() and warnx(), as per BSD's err.h.
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* failtest - unit test helpers for testing malloc and other failures. * failtest - unit test helpers for testing malloc and other failures.
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* grab_file - file helper routines * grab_file - file helper routines
......
#include "config.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* heap - a simple heap implementation * heap - a simple heap implementation
......
#include "config.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* idtree - id allocation tree * idtree - id allocation tree
......
...@@ -35,9 +35,9 @@ ...@@ -35,9 +35,9 @@
* License: CC0 (Public domain) * License: CC0 (Public domain)
* Author: Timothy B. Terriberry <tterribe@xiph.org> * Author: Timothy B. Terriberry <tterribe@xiph.org>
*/ */
#include "config.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "config.h"
int main(int _argc,const char *_argv[]){ int main(int _argc,const char *_argv[]){
/*Expect exactly one argument.*/ /*Expect exactly one argument.*/
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* io - simple library for asynchronous io handling. * io - simple library for asynchronous io handling.
......
...@@ -104,9 +104,9 @@ ...@@ -104,9 +104,9 @@
* // We actually depend on the LGPL ilog routines, so not PD :( * // We actually depend on the LGPL ilog routines, so not PD :(
* license_depends_compat FAIL * license_depends_compat FAIL
*/ */
#include "config.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "config.h"
int main(int _argc,const char *_argv[]){ int main(int _argc,const char *_argv[]){
/*Expect exactly one argument.*/ /*Expect exactly one argument.*/
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* jacobson_karels - Jacobson/Karels Round Trip Time algorithm * jacobson_karels - Jacobson/Karels Round Trip Time algorithm
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* jmap - map from indices to values (based on libJudy) * jmap - map from indices to values (based on libJudy)
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* jset - set of pointers (based on libJudy) * jset - set of pointers (based on libJudy)
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* json - Parse and generate JSON (JavaScript Object Notation) * json - Parse and generate JSON (JavaScript Object Notation)
......
/* Licensed under GPLv3+ - see LICENSE file for details */ /* Licensed under GPLv3+ - see LICENSE file for details */
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h> #include <string.h>
/** /**
......
#include "config.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "config.h"
/** /**
* likely - macros for annotating likely/unlikely branches in the code * likely - macros for annotating likely/unlikely branches in the code
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* list - double linked list routines * list - double linked list routines
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* md4 - MD4 Message Digest Algorithm (RFC1320). * md4 - MD4 Message Digest Algorithm (RFC1320).
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* minmax - typesafe minimum and maximum functions * minmax - typesafe minimum and maximum functions
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* net - simple IPv4/IPv6 socket library * net - simple IPv4/IPv6 socket library
......
#include "config.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* noerr - routines for cleaning up without blatting errno * noerr - routines for cleaning up without blatting errno
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* objset - unordered set of pointers. * objset - unordered set of pointers.
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* ogg_to_pcm - decode ogg vorbis audio files to PCM data using libvorbis * ogg_to_pcm - decode ogg vorbis audio files to PCM data using libvorbis
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* opt - simple command line parsing * opt - simple command line parsing
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* ptr_valid - test whether a pointer is safe to dereference. * ptr_valid - test whether a pointer is safe to dereference.
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* rbuf - buffered I/O input primitive. * rbuf - buffered I/O input primitive.
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* read_write_all - read_all and write_all routines. * read_write_all - read_all and write_all routines.
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* short_types - shorter names for standard integer types * short_types - shorter names for standard integer types
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* siphash - a keyed hash function * siphash - a keyed hash function
......
#include "config.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "config.h"
/** /**
* sparse_bsearch - search a sorted array with some invalid entries * sparse_bsearch - search a sorted array with some invalid entries
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* str - string helper routines * str - string helper routines
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* stringmap - Macros for mapping strings to things * stringmap - Macros for mapping strings to things
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* strmap - an ordered map of strings to values * strmap - an ordered map of strings to values
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* strset - an ordered set of strings * strset - an ordered set of strings
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* take - routines to mark pointers to be consumed by called functions. * take - routines to mark pointers to be consumed by called functions.
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* tal - compact tree allocator routines (inspired by talloc) * tal - compact tree allocator routines (inspired by talloc)
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* tal/grab_file - file helper routines * tal/grab_file - file helper routines
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* tal/link - link helper for tal * tal/link - link helper for tal
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* tal/path - routines to manipulate paths * tal/path - routines to manipulate paths
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* tal/str - string helper routines which use tal * tal/str - string helper routines which use tal
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* tal/talloc - an implementation of the tal interface in terms of talloc. * tal/talloc - an implementation of the tal interface in terms of talloc.
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* talloc - tree allocator routines * talloc - tree allocator routines
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* tally - running tally of integers * tally - running tally of integers
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* tap - Test Anything Protocol * tap - Test Anything Protocol
......
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h> #include <string.h>
/** /**
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* time - routines for dealing with time * time - routines for dealing with time
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* timer - efficient implementation of rarely-expiring timers. * timer - efficient implementation of rarely-expiring timers.
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* tlist - typesafe double linked list routines * tlist - typesafe double linked list routines
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* ttxml - tiny XML library for parsing (trusted!) XML documents. * ttxml - tiny XML library for parsing (trusted!) XML documents.
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* typesafe_cb - macros for safe callbacks. * typesafe_cb - macros for safe callbacks.
......
#include <string.h>
#include "config.h" #include "config.h"
#include <stdio.h>
#include <string.h>
/** /**
* version - helper functions for major.minor-style version numbers * version - helper functions for major.minor-style version numbers
......
#include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "config.h"
/** /**
* wwviaudio - realtime playback and mixing of 16 bit signed PCM audio data. * wwviaudio - realtime playback and mixing of 16 bit signed PCM audio data.
......
...@@ -31,8 +31,9 @@ static void check_has_info(struct manifest *m, ...@@ -31,8 +31,9 @@ static void check_has_info(struct manifest *m,
} }
static const char template[] = static const char template[] =
"#include <string.h>\n"
"#include \"config.h\"\n" "#include \"config.h\"\n"
"#include <stdio.h>\n"
"#include <string.h>\n"
"\n" "\n"
"/**\n" "/**\n"
" * %s - YOUR-ONE-LINE-DESCRIPTION-HERE\n" " * %s - YOUR-ONE-LINE-DESCRIPTION-HERE\n"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment