- don't test for HAVE_SYS_TIMES_H before we include "config.h" - Opengroup specification says that a struct tms * must be passed to times() and some implementations don't validate that, causing a segmentation fault if you pass NULL.
- cast the clock_t to long for printing please note that this usage is still not necessarily correct, the spec says that the value returned is "clock ticks" which may be something different than "milliseconds" --- apps/obexftp.c | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/obexftp.c b/apps/obexftp.c index bc1da89..9ffe913 100644 --- a/apps/obexftp.c +++ b/apps/obexftp.c @@ -29,10 +29,6 @@ #include <sys/types.h> -#ifdef HAVE_SYS_TIMES_H -#include <sys/times.h> -#endif - #include <obexftp/obexftp.h> #include <obexftp/client.h> #include <obexftp/uuid.h> @@ -47,6 +43,10 @@ #include <common.h> +#ifdef HAVE_SYS_TIMES_H +#include <sys/times.h> +#endif + // perhaps this scheme would be better? // IRDA irda://[nick?] // CABLE tty://path @@ -253,6 +253,7 @@ static int cli_connect_uuid(const char *uuid, int uuid_len) int ret, retry; #ifdef HAVE_SYS_TIMES_H clock_t clock; + struct tms tms; #endif if (cli == NULL) { @@ -283,12 +284,12 @@ static int cli_connect_uuid(const char *uuid, int uuid_len) /* Connect */ #ifdef HAVE_SYS_TIMES_H - clock = times(NULL); + clock = times(&tms); #endif ret = obexftp_connect_src(cli, src_dev, device, channel, uuid, uuid_len); #ifdef HAVE_SYS_TIMES_H - clock = times(NULL)-clock; - fprintf(stderr, "Tried to connect for %ldms\n", clock); + clock = times(&tms)-clock; + fprintf(stderr, "Tried to connect for %ldms\n", (long)clock); #endif if (ret >= 0) return ret; -- 1.7.0.5 ------------------------------------------------------------------------------ Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ Openobex-users mailing list Openobex-users@lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/openobex-users