Merge topic branch t/overflow into master This series implements a new memory allocation API which checks for overflows. The first part of the series just renames the main allocation functions. Later patches in the series implement allocators which take two size_t arguments (like calloc(3)) and check whether the multiplication overflows by employing the __builtin_mul_overflow() primitive supported by gcc and clang. This requires us to bump the lowest supported gcc and clang version. * refs/heads/t/overflow: build: Compile with -ftrapv. string: Introduce arr_zalloc(). string: Introduce arr_alloc(). string: Introduce arr_realloc() and check for integer overflow. string: Rename para_calloc() -> zalloc(). string: Rename para_malloc() -> alloc(). string: Overhaul para_strdup().
Rename ->{pre,post}_select methods to ->{pre,post}_monitor. The word "monitor" is neutral and continues to be correct after the switch from select(2) to poll(2). Pure rename, nothing to see here.
Consolidate receiver/filter/writer {pre,post}_select() docs. The documentation of these three ->pre_select() and ->post_select() methods overlapped quite a bit. Some comments stated general properties of the sched API which fit better in the documentation of sched.h, so move these bits there. Improve the text a bit while at it and avoid talking about select(2) and fd sets as these are implementation details. Instead, focus on the general concept of fd monitoring. Pure comment cleanups, no code changes.
string: Rename para_malloc() -> alloc(). Just because it's shorter and matches the naming of the new allocators we are about to introduce. The bulk of this patch was created with sed -i 's/para_malloc/alloc/g' *.c *.h yy/mp.y
Remove ->init() of struct receiver. The previous patch removed the ->init() method of the afh receiver. Since the afh receiver was the only receiver that defined an init method, the method can now be removed from struct receiver. As a consequence, recv_init(), which calls each receiver's init method has become a no-op and can also be removed.
Shorten copyright notice. The GPLv2 line does not add any additional information, so drop it. This leaves a single line of legalese text for most files, which is about the amount of screen real estate it deserves. This patch was created with the following script (plus some manual fixups): awk '{ if (NR <= 5) { gs = gensub(/.*Copyright.* ([0-9]+).*Andre Noll.*/, "\\1", "g") if (gs != $0) year = gs next } if (NR == 6 && year != "") printf("/* Copyright (C) %s Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */\n", year) print }'
recv: Explain user data mechanism. This is not obvious, so it deserves a comment in recv_init(). The patch also adds a reference to each of the four instances of struct receiver, reducing the number of doxygen warnings when EXTRACT_ALL is set to NO in Doxyfile.
recv_common.c: Fix doxygen warning in recv_init(). In the doxygen comment of this function, one argument name was prefixed with a backslash by mistake. Old doxygen versions did not complain about this, but doxygen-1.8.11 does: warning: unexpected token in comment block while parsing the argument of command param
Convert receivers to lopsub. This converts the four receivers (afh, http, dccp, udp) to use the lopsub library instead of gengetopt. The command line options of the receivers are implemented as subcommands of the new recv_cmd lopsub suite. Hence the four gengetopt command line parsers and ->ggo_help of struct receiver can be removed. This change allows to get rid of the receiver array which was defined through the DEFINE_RECEIVER_ARRAY macro. We now store each receiver structure in the user_data pointer provided by lopsub. Since this structure is initialized at compile time (and constant since ->ggo_help is gone), ->init() of struct receiver is no longer needed to initialize the various function pointers. The function is now optional and does not take an argument any more. At the moment, only the afh receiver needs ->init() to initialize all supported audio format handlers. t0005 needs slight adjustment since the section headers of the help text have changed a bit.
Fix documentation of check_receiver_arg(). Receiver name and options are NOT separated by a colon. Also, all three receivers (http, udp, dccp) are always supported, so it's pointless to talk about supported paraslash receivers. This patch simplifies the comment accordingly.
Update year in copyright headers. Done with files=$(git grep -l 'Copyright (C) [0-9]\{4\}\(-2014\)* Andre Noll') sed --in-place= -e 's/Copyright (C) \([0-9]\{4\}\)-2014 Andre Noll/Copyright (C) \1 Andre Noll/1' $files In previous years we ran a similar script to set the second year in the range to the current year. This is kind of silly, so let's get rid of this useless information. This commit replaces "Copyright (C) A-B" by "Copyright (C) A" in all file headers, i.e. only the first year (A) is left in. Accurate information including time stamps for each change can be obtained from the git history.
Assorted typo fixes in comments. Quite a few..
doc: Change email address to maan@tuebingen.mpg.de The mail server on systemlinux.org was down for more than a week lately, so let's use an alternative official address. This commit changes all maan@systemlinux.org addresses to maan@tuebingen.mpg.de. Most .c and .h files contain the email address in the copyright header, so they must all be patched. Three other files contain the address for a different reason: * README lists email and git, gitweb and home page URLs * configure.ac needs it for configure -h * version.c contains it for the -V option of all commands
sched: Directly pass context pointer to pre/post_select(). The patch is large, but it's fairly straight forward: Instead of a task pointer all ->pre_select() and ->post_select() methods now receive the context pointer that was passed to the scheduler when the task was registered. This allows to kill the public task_context(). Two pre_select/post_select functions are not directly called by the scheduler: session_post_select(), generic_recv_pre_select(). These are changed to receive a proper struct rather than a void pointer. Note that generic_filter_pre_select() is not changed in this manner because some filters do not provide a pre_select wrapper but set task->pre_select to generic_filter_pre_select().
task_register() conversion: receivers This adds a new public function, task_reap(), to sched.c. It is called by para_audiod and para_play to free the memory occupied by the receiver node after EOF. sched_shutdown() can not be used for this purpose since the scheduler stays active during the life time of these programs (i.e. schedule() never returns) while receiver nodes come and go. The new task_reap() has to face the problem that it is called from another task's ->post_select() method, so removing the task being reaped from the scheduler task list is not possible in task_reap(). Hence this patch adds the new flag "dead" to struct task. It is initially unset and is turned on in task_reap() to indicate that (a) the task has exited (i.e. ->post_select() returned negative) and (b) task_reap() has been called to fetch the exit status. Only if this flag is set, the scheduler removes the task from the task list.
Don't set t->error in ->pre_select(). ->pre_select() methods should never fail, and tasks should not set this variable at all. It is ignored anyway when set there.
recv_common.c: Improve documentation of check_receiver_arg(). Drop meaningless "and further are present", and note that the "real" type of the returned pointer depends on the receiver.
Change copyright year to 2014. This year, we're really on time. The changes in this patch were created by the following silly script: files=$(git grep -l 'Copyright (C) [0-9]\{4\}\(-2013\)* Andre Noll') sed --in-place= -e 's/Copyright (C) \([0-9]\{4\}\)-2013 Andre Noll/Copyright (C) \1-2014 Andre Noll/1' $files sed --in-place= -e 's/Copyright (C) 2013 Andre Noll/Copyright (C) 2013-2014 Andre Noll/1' $files
Provide "purpose" texts. This text will be printed right after the program name in the --help output. For para_afh, the inline text becomes redundant, so this text is removed. Each executable gets a purpose text, and for receivers, filters, writers the purpose will be printed as part of the help output of para_audiod, para_filter. para_recv and para_write.
Revamp ggo help. This adds usage and description fields to struct ggo_help and changes ggo_print_help() to optionally print these. The boolean detailed_help flag of ggo_print_help() is replaced by a bitmask which lets the caller specify what to print. Four pre-defined masks are used to print the normal help, the detailed help, the help for modules (receivers, filters, writers) and the detailed module help. The new macro DEFINE_GGO_HELP can be employed to create a struct ggo_help from a gengetopt structure.