[SCM] strace branch, master, updated. v4.6-126-g5284557

Denys Vlasenko dvlasenk at redhat.com
Thu Sep 1 09:14:59 UTC 2011


On Thu, 2011-09-01 at 00:07 +0400, Dmitry V. Levin wrote:
> On Wed, Aug 31, 2011 at 10:11:49AM +0000, Denys Vlasenko wrote:
> > commit 5284557bfad96f12dd5798539008e1644f1dc094
> > Author: Denys Vlasenko <dvlasenk at redhat.com>
> > Date:   Wed Aug 31 12:07:38 2011 +0200
> > 
> >     Optimization: eliminate some usages of strcat()
> >     
> >     * defs.h: Declare stpcpy().
> >     * util.c: Define stpcpy().
> >     * file.c: Remove static str_append().
> >     (sprint_open_modes): Use stpcpy() instead of str_append().
> >     (sprintflags): Use stpcpy() instead of strcat().
> >     (printpathn): Eliminate usage of strcat().
> >     (printstr): Eliminate usage of strcat().
> 
> This is OK, but
> 
> > --- a/defs.h
> > +++ b/defs.h
> > @@ -680,6 +680,13 @@ extern void tv_sub(struct timeval *, struct timeval *, struct timeval *);
> >  extern void tv_mul(struct timeval *, struct timeval *, int);
> >  extern void tv_div(struct timeval *, struct timeval *, int);
> >  
> > +/* Some libc have stpcpy, some don't. Sigh...
> > + * Roll our private implementation...
> > + */
> > +#undef stpcpy
> > +#define stpcpy strace_stpcpy
> > +extern char *stpcpy(char *dst, const char *src);
> > +
> 
> I'd rather add stpcpy to AC_CHECK_FUNCS, to use stpcpy() from libc if
> the latter provides stpcpy().

Like this?

-- 
vda


diff -d -urpN strace.9/configure.ac strace.a/configure.ac
--- strace.9/configure.ac	2011-08-31 10:47:35.000000000 +0200
+++ strace.a/configure.ac	2011-09-01 11:12:22.362824609 +0200
@@ -235,6 +235,7 @@ AC_CHECK_FUNCS([ \
 	strsignal \
 	sys_siglist \
 	_sys_siglist \
+	stpcpy \
 ])
 AC_CHECK_HEADERS([ \
 	inttypes.h \
diff -d -urpN strace.9/defs.h strace.a/defs.h
--- strace.9/defs.h	2011-08-31 18:09:06.454737541 +0200
+++ strace.a/defs.h	2011-09-01 11:13:21.725068326 +0200
@@ -696,12 +696,14 @@ extern void tv_sub(struct timeval *, str
 extern void tv_mul(struct timeval *, struct timeval *, int);
 extern void tv_div(struct timeval *, struct timeval *, int);
 
+#if !defined HAVE_STPCPY
 /* Some libc have stpcpy, some don't. Sigh...
  * Roll our private implementation...
  */
 #undef stpcpy
 #define stpcpy strace_stpcpy
 extern char *stpcpy(char *dst, const char *src);
+#endif
 
 #ifdef SUNOS4
 extern int fixvfork(struct tcb *);
diff -d -urpN strace.9/util.c strace.a/util.c
--- strace.9/util.c	2011-08-31 18:58:51.218271698 +0200
+++ strace.a/util.c	2011-09-01 11:13:31.919110047 +0200
@@ -164,6 +164,7 @@ xlookup(const struct xlat *xlat, int val
 	return NULL;
 }
 
+#if !defined HAVE_STPCPY
 char *
 stpcpy(char *dst, const char *src)
 {
@@ -171,6 +172,7 @@ stpcpy(char *dst, const char *src)
 		dst++;
 	return dst;
 }
+#endif
 
 /*
  * Generic ptrace wrapper which tracks ESRCH errors





More information about the Strace-devel mailing list