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.
sched: Use integer value for select timeout. This modifies the public struct sched so that users pass in the default timeout as an integer value in milliseconds rather than a struct timeval. This simplifies the code a little and eases the transition from select(2) to poll(2) because poll(2) also takes a plain integer for the timeout. Since para_select() of fd.c now calls ms2tv() to convert the timeout back to a struct timeval, all executables which link with fd.o must also link with time.o. This was not the case for para_mixer and para_audioc, so configure.ac needs to be adjusted accordingly.
string: Introduce arr_alloc(). Change all callers of alloc() which pass a product of two integers as the allocation size to call the new function instead. This function aborts if the multiplication overflows. With arr_alloc() in place, alloc() reduces to a trivial wrapper which calls new arr_alloc() with the first argument equal to one.
string: Rename para_calloc() -> zalloc(). Reword the documentation a bit since the function has never been a wrapper for calloc(3). 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
filter: Use lsu_merge_config_file_options(). Straight forward conversion. We now set the loglevel only once, after the config file options have been merged.
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 }'
Define status items in para.h. The only reason the status item enum and string array are defined in configure.ac is that upper case identifiers and lower case strings are not easy to do in cpp as it lacks toupper(). However, configure.ac is not the right place for defining C language constructs as the configure script should only check for installed packages. This commit moves the definition of the status item enum and array to para.h and modifies all users to use lower case for the item names. This was automated with a script which essentially did upper=${i^^} sed -i "s/\<SI_$upper/SI_$i/g" $files for each status item $i. Care has been taken to leave the order of the status items unchanged. This is important because the item numbers must be considered part of the API between server and client.
Convert para_filter to lopsub. Changes the semantics in case --filter is not given. We used to print an error, but it makes more sense to show the list of supported filters in this case. If no filters are given, we now print the list of available filters. A new function in filter_common.c, print_filter_list(), is introduced for this purpose. The manual page of para_filter has been extended to include an overall description of the command. The only error code of filter.c, E_NO_FILTERS, becomes unused and is removed.
Convert filters to lopsub. This replaces the *_filter.m4 gengetopt files by the filter_cmd lopsub suite, where each filter is realized as a subcommand. Due to this change, para_filter needs to be linked with -llopsub. The filter structure is now stored in the user_data pointer provided by lopsub, allowing to get rid of the global filters[] array, the FILTER_ENUM macro and the corresponding enumeration constants. The removal of the ->goo_help member of struct filter makes this structure constant. Hence ->init() of struct filter can also go away. We still can tell whether a filter is supported by checking the user_data pointer: if it is NULL, the filter is unsupported. The new filter_supported() helper in filter_common.c is provided for convenience. Parsing of the filter command line options is now performed generically, and the ->parse_config() method is renamed to ->setup(), an optional function which is supposed to perform semantic checks and the one-time setup of the filter, if any. It is accompanied by ->teardown() which replaces ->free_config(). The conversion of the individual filters is easy since most filters have a simple syntax or take no arguments at all. The resample_filter, however, needs a different way to copy the wav parameters from the lopsub parse result to the wav parms structure. A suitable macro, LLS_COPY_WAV_PARMS is added to check_wav.h for this purpose. The old COPY_WAV_PARMS needs to stay until para_write, the only other user of the macro, has been converted as well. The section heading of the manual page has changed slightly, causing t0005 to fail. Hence this test needs a slight adjustment.
Simplify the error subsystem, get rid of error2.[ch]. This commit removes error2.c and the surrounding infrastructure of the build system, getting rid of ~600 LOC. After the change there are no more subsystems for error codes, and we don't need to host-compile error2.c any more. Since all executables now contain the text of every error code, the change has some impact on the sizes of the (stripped) executables: Before: After: 64K para_afh 71K para_afh 43K para_audioc 47K para_audioc 256K para_audiod 259K para_audiod 64K para_client 71K para_client 39K para_fade 47K para_fade 141K para_filter 144K para_filter 51K para_gui 59K para_gui 252K para_play 255K para_play 97K para_recv 104K para_recv 227K para_server 230K para_server 60K para_write 67K para_write This increase in size is justified by the major simplification.
filter: Make ->open() optional. There is no need to force each filter to supply this method, so teach the three callers of ->open() to check for NULL pointers. The commit also fixes some trivial language issues in the documentation of ->open() and ->close().
filter.c: Use EXIT_SUCCESS. Trivial change, since POSIX requires EXIT_SUCCESS to be zero.
Constify struct filter access and introduce filter_get(). This modifies all users of the filter API to not access the filter array directly. Instead all callers now obtain a const pointer to the filter structure through the new filter_get() accessor function. However, the filter array can not be made constant yet because the ->init methods modify the filter structure. This requires some casts in filter_common.c unfortunately.
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.
filter.c: Add documentation of stat_item_values[].
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: filter tasks
task_register() conversion: stdin task This renames stdin_set_defaults() to stdin_task_register() and changes the function to register the stdin task. Before this patch, the task was registered in the callers.