From: Iain Hibbert <[email protected]>
- don't test for HAVE_SYS_TIMES_H before we include "config.h"
(in common.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.
- Opengroup also notes that the value of clock ticks per second
can be retrieved by sysconf(), use that to produce output in
milliseconds.
- cast the clock_t to long for printing.
---
apps/obexftp.c | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/apps/obexftp.c b/apps/obexftp.c
index bc1da89..4538c0f 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) * 1000 / sysconf(_SC_CLK_TCK);
+ fprintf(stderr, "Tried to connect for %ldms\n", (long)clock);
#endif
if (ret >= 0)
return ret;
--
1.7.4.1
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Openobex-users mailing list
[email protected]
http://lists.sourceforge.net/lists/listinfo/openobex-users