From: Dmitry V. Levin Date: Thu, 29 May 2014 17:59:01 +0000 (+0000) Subject: Constify tv_* functions X-Git-Tag: v4.9~77 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=447db45365e37ec97c41b26b5a24e38d58e4f3ae;p=platform%2Fupstream%2Fstrace.git Constify tv_* functions * defs.h (tv_nz, tv_cmp, tv_float, tv_add, tv_sub, tv_mul, tv_div): Add const qualifier to read only arguments. * util.c (tv_nz, tv_cmp, tv_float, tv_add, tv_sub, tv_mul, tv_div): Likewise. --- diff --git a/defs.h b/defs.h index 4e06a92a..22e847ba 100644 --- a/defs.h +++ b/defs.h @@ -712,13 +712,13 @@ extern int ubi_ioctl(struct tcb *, long, long); extern int loop_ioctl(struct tcb *, long, long); extern int ptp_ioctl(struct tcb *, long, long); -extern int tv_nz(struct timeval *); -extern int tv_cmp(struct timeval *, struct timeval *); -extern double tv_float(struct timeval *); -extern void tv_add(struct timeval *, struct timeval *, struct timeval *); -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); +extern int tv_nz(const struct timeval *); +extern int tv_cmp(const struct timeval *, const struct timeval *); +extern double tv_float(const struct timeval *); +extern void tv_add(struct timeval *, const struct timeval *, const struct timeval *); +extern void tv_sub(struct timeval *, const struct timeval *, const struct timeval *); +extern void tv_mul(struct timeval *, const struct timeval *, int); +extern void tv_div(struct timeval *, const struct timeval *, int); /* Strace log generation machinery. * diff --git a/util.c b/util.c index ff18b87c..33482d5f 100644 --- a/util.c +++ b/util.c @@ -79,13 +79,13 @@ string_to_uint(const char *str) } int -tv_nz(struct timeval *a) +tv_nz(const struct timeval *a) { return a->tv_sec || a->tv_usec; } int -tv_cmp(struct timeval *a, struct timeval *b) +tv_cmp(const struct timeval *a, const struct timeval *b) { if (a->tv_sec < b->tv_sec || (a->tv_sec == b->tv_sec && a->tv_usec < b->tv_usec)) @@ -97,13 +97,13 @@ tv_cmp(struct timeval *a, struct timeval *b) } double -tv_float(struct timeval *tv) +tv_float(const struct timeval *tv) { return tv->tv_sec + tv->tv_usec/1000000.0; } void -tv_add(struct timeval *tv, struct timeval *a, struct timeval *b) +tv_add(struct timeval *tv, const struct timeval *a, const struct timeval *b) { tv->tv_sec = a->tv_sec + b->tv_sec; tv->tv_usec = a->tv_usec + b->tv_usec; @@ -114,7 +114,7 @@ tv_add(struct timeval *tv, struct timeval *a, struct timeval *b) } void -tv_sub(struct timeval *tv, struct timeval *a, struct timeval *b) +tv_sub(struct timeval *tv, const struct timeval *a, const struct timeval *b) { tv->tv_sec = a->tv_sec - b->tv_sec; tv->tv_usec = a->tv_usec - b->tv_usec; @@ -125,7 +125,7 @@ tv_sub(struct timeval *tv, struct timeval *a, struct timeval *b) } void -tv_div(struct timeval *tv, struct timeval *a, int n) +tv_div(struct timeval *tv, const struct timeval *a, int n) { tv->tv_usec = (a->tv_sec % n * 1000000 + a->tv_usec + n / 2) / n; tv->tv_sec = a->tv_sec / n + tv->tv_usec / 1000000; @@ -133,7 +133,7 @@ tv_div(struct timeval *tv, struct timeval *a, int n) } void -tv_mul(struct timeval *tv, struct timeval *a, int n) +tv_mul(struct timeval *tv, const struct timeval *a, int n) { tv->tv_usec = a->tv_usec * n; tv->tv_sec = a->tv_sec * n + tv->tv_usec / 1000000;