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.
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
Teach writers to abort gracefully on early EOF. For very short streams it may happen that the receiver and decoder unregister themselves from the buffer tree before the writer had a chance to query the information from the decoder which it needs to open the audio device. This leads to errors such as Aug 25 14:24:51 schubert (5) get_btr_value: cmd sample_rate: Operation not supported Aug 25 14:24:51 schubert (5) get_btr_value: cmd channels: Operation not supported Aug 25 14:24:51 schubert (5) get_btr_value: cmd sample_format: Operation not supported Aug 25 14:24:51 schubert (4) alsa_init: channels count not available: Invalid argument This may happen with all receivers, audio formats and writers, although it is most common with ogg streams. This commit changes get_btr_sample_rate() and friends to return a standard error code rather than assuming success. The alsa, ao and oss writers are patched to check the return value and fail gracefully if one of these functions fails.
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 }'
Convert writers to lopsub. Similar to the previous commits for receivers and filters, this commit replaces the five gengetopt parsers for the alsa, ao, file, oss, osx writers by a lopsub suite and links para_write with -llopsub. This allows to get rid of the WRITER_ENUM and the writers array as a reference to each writer structure are stored in the lopsub user_data pointer. Moreover, ->init(), ->parse_config(), ->free_config() and ->ggo_help() of struct writer are not needed any more and can be removed. The patch also removes write_common.h and moves the few prototypes write.h. Now that receivers, filters and writers have all been converted, we may also stop to include ggo.h from audiod_command.c and play.c. As for the receivers and filters, t0005 needs slight adjustments due to the new section header in the man page.
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.
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
task_register() conversion: writers
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
Add some missing includes. Letting .c files include their "own" header file guarantees that the declaration in the header file stays in sync with the definition. Eventually we may even enable gcc's -Wmissing-declarations, but we're not there yet, mainly due to command handlers, init functions and completers. Note that including signal.h in signal.c required two other includes since the header file defines a task structure.
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.
sched: Rename new_post_select back to post_select.
sched: Kill old ->post_select variant. It has no more users.
sched: Provide alternative post_select variant. Code which accesses the ->error field of another task has been a source of bugs in the past. This patch is a first step to make ->error private to sched.c. Currently the ->post_select() methods of all tasks are supposed to set ->error to a negative value to indicate that the task should be terminated, i.e. t->error being negative instructs the scheduler to not call t->pre_select() or t->post_select() any more in subsequent iterations. An equivalent way to achieve the same is to let ->post_select() return an error code instead. Benefits include * It reduces the use of ->error outside of sched.c * It's impossible to miss setting the error code * It simplifies code slightly Therefore we'd like to change the prototype of the ->post_select() methods from void (*post_select)(struct sched *s, struct task *t); to int (*post_select)(struct sched *s, struct task *t); Changes to struct sched affects many parts of the code base, hence converting all users at once would result in a very large patch. Therefore we temporarily introduce an additional ->new_post_select() method according to the second declaration above. The scheduler calls the new method if it is defined and falls back to the old variant otherwise. This approach allows to switch over one task after another without breaking things. This patch introduces the infrastructure just described and switches over the http receiver. Subsequent commits will change all other tasks in the same way. After all tasks have been switched over we can get rid of the old ->post_select variant and rename ->new_post_select() back to ->post_select().
Change copyright year to 2013. Better late than never.
write: Get rid of gengetopt's string parser. It causes gengetopt to generate quite some additional code for the string parsers of all writers. Moreover, this string parser is inferior to create_argv() and create_shifted_argv() of string.c as gengetopt's parser does not honor any quoting at all. This commit changes the signature of the ->parse_config_or_die method of struct writer to take an (argc, argv) pair instead of a string. All writers can thus call the vanilla command line parser of gengetopt. The single user in write_common.c now calls ->parse_config_or_die() with an (argc, argv) pair obtained from create_shifted_argv().
Change year in copyright message to 2012.
Always include stdbool.h. This adds the #include statement for stdbool.h to para.h. This allows to get rid of the individual includes in *.c. More importantly, since all *.c files include para.h, booleans will now be available everywhere so that we won't need to touch dozens of files anymore whenever a boolean is added to a public structure.