On Mon, 7 Aug 2017 14:48:03 +0300 "Dmitry V. Levin" <l...@altlinux.org> wrote:
> On Sat, Aug 05, 2017 at 04:57:34AM +0300, Edgar Kaziakhmedov wrote: > > From: Edgar Kaziakhmedov <edgar.kaziakhme...@virtuzzo.com> > > virtuzzo.com? Really? ;) Oh, these typos... > > > In order to allow usage of utility functions by other binaries > > included in the strace package (like the upcoming asinfo utility), > > these functions should be moved to separate files. > > > > * Makefile.am (strace_SOURCES): Add error_prints.c, error_prints.h, > > and xmalloc.h. > > * defs.h: Include "xmalloc.h" and "error_prints.h". > > (error_msg, error_msg_and_help, error_msg_and_die, perror_msg, > > perror_msg_and_die, xcalloc, xmalloc, xreallocarray, xstrdup, > > xstrndup): Move to corresponding headers. > > * error_prints.h: New file. > > (error_msg, error_msg_and_die, error_msg_and_help, perror_msg, > > perror_msg_and_die): Move from defs.h. > > * xmalloc.h: New file. > > (xcalloc, xmalloc, xreallocarray, xstrdup, xstrndup): Move from > > defs.h. > > * strace.c (die): Remove static quialifier to make visible for > > error_prints.c (die_out_of_memory, error_msg, error_msg_and_help, > > error_msg_and_die, perror_msg, perror_msg_and_die, verror_msg): > > Move ... > > * error_prints.c: ... to the new file. > > * xmalloc.c: Remove "defs.h". Add "xmalloc.h". Fix codestyle. > > > > Signed-off-by: Edgar Kaziakhmedov <edgar.kaziakhme...@virtuozzo.com> > > --- > > Makefile.am | 3 ++ > > defs.h | 21 ++-------- > > error_prints.c | 123 > > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > error_prints.h | 50 +++++++++++++++++++++++ strace.c | 79 > > +----------------------------------- xmalloc.c | 26 > > ++++++++---- xmalloc.h | 45 +++++++++++++++++++++ > > 7 files changed, 244 insertions(+), 103 deletions(-) > > create mode 100644 error_prints.c > > create mode 100644 error_prints.h > > create mode 100644 xmalloc.h > > Note that this commit message is out of sync with the change itself. > For example, die_out_of_memory is not moving anywhere. > > Note that config.h must be included, directly or indirectly, by each > compilation unit, and xmalloc.c is no exception because, e.g. it tests > for HAVE_STRNDUP. > > OK, I've merged it with the following corrections: > > diff --git a/error_prints.h b/error_prints.h > index 0a818c9..7ddcb50 100644 > --- a/error_prints.h > +++ b/error_prints.h > @@ -1,8 +1,8 @@ > /* > - * This file contains error printing functions. This set of > soubroutines can be > - * used by various binaries included in the strace package. For > compilation > - * variable 'program_invocation_name' and function 'die()' have to > be defined > - * globally. > + * This file contains error printing functions. > + * These functions can be used by various binaries included in the > strace > + * package. Variable 'program_invocation_name' and function 'die()' > + * have to be defined globally. > * > * Copyright (c) 2001-2017 The strace developers. > * All rights reserved. > @@ -35,8 +35,7 @@ > > #include "gcc_compat.h" > > -extern void > -ATTRIBUTE_NORETURN die(void); > +void die(void) ATTRIBUTE_NORETURN; > > void error_msg(const char *fmt, ...) ATTRIBUTE_FORMAT((printf, 1, > 2)); void perror_msg(const char *fmt, ...) ATTRIBUTE_FORMAT((printf, > 1, 2)); diff --git a/xmalloc.c b/xmalloc.c > index 4290a01..45ff57b 100644 > --- a/xmalloc.c > +++ b/xmalloc.c > @@ -25,10 +25,12 @@ > * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > */ > > -#include <stdbool.h> > +#ifdef HAVE_CONFIG_H > +# include "config.h" > +#endif > + > #include <stdlib.h> > #include <string.h> > -#include <stdio.h> > > #include "error_prints.h" > #include "xmalloc.h" > @@ -36,7 +38,7 @@ > static void > die_out_of_memory(void) > { > - static bool recursed; > + static int recursed; > > if (recursed) > exit(1); > diff --git a/xmalloc.h b/xmalloc.h > index 33b77a0..ae0501d 100644 > --- a/xmalloc.h > +++ b/xmalloc.h > @@ -1,6 +1,7 @@ > -/* This file contains wrapper functions working with memory, the > wrapper > - * just terminates program in case of lack of memory. This set of > - * soubroutines can be used by various binaries included in the > strace +/* > + * This file contains wrapper functions working with memory > allocations, > + * they just terminate the program in case of memory allocation > failure. > + * These functions can be used by various binaries included in the > strace > * package. > * > * Copyright (c) 2001-2017 The strace developers. > @@ -32,6 +33,7 @@ > #ifndef STRACE_XMALLOC_H > #define STRACE_XMALLOC_H > > +#include <stddef.h> > #include "gcc_compat.h" > > void *xcalloc(size_t nmemb, size_t size) >
pgp_QwAaTrdOO.pgp
Description: OpenPGP digital signature
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel