Browse Source

faux.time: faux_timespec_sum() returns bool_t instead int

Serj Kalichev 3 years ago
parent
commit
db581cc62a
3 changed files with 6 additions and 6 deletions
  1. 1 1
      faux/time.h
  2. 1 1
      faux/time/testc_time.c
  3. 4 4
      faux/time/time.c

+ 1 - 1
faux/time.h

@@ -17,7 +17,7 @@ C_DECL_BEGIN
 int faux_timespec_cmp(const struct timespec *val1, const struct timespec *val2);
 bool_t faux_timespec_diff(struct timespec *res,
 	const struct timespec *val1, const struct timespec *val2);
-int faux_timespec_sum(struct timespec *res,
+bool_t faux_timespec_sum(struct timespec *res,
 	const struct timespec *val1, const struct timespec *val2);
 int faux_timespec_now(struct timespec *now);
 int faux_timespec_now_monotonic(struct timespec *now);

+ 1 - 1
faux/time/testc_time.c

@@ -131,7 +131,7 @@ int testc_faux_timespec_sum(void)
 		printf("val1=%ld:%ld, val2=%ld:%ld\n",
 			val1[i].tv_sec, val1[i].tv_nsec,
 			val2[i].tv_sec, val2[i].tv_nsec);
-		if (faux_timespec_sum(&res, &val1[i], &val2[i]) < 0) {
+		if (!faux_timespec_sum(&res, &val1[i], &val2[i])) {
 			printf("Test %u retval failed\n", i);
 			ret = -1;
 		}

+ 4 - 4
faux/time/time.c

@@ -88,10 +88,10 @@ bool_t faux_timespec_diff(struct timespec *res,
  * @param [out] res Result of operation.
  * @param [in] val1 First time value.
  * @param [in] val2 Second time value.
- * @return 0 - success or -1 on error.
+ * @return BOOL_TRUE - success, BOOL_FALSE on error.
  * @exception EINVAL Invalid arguments value.
  */
-int faux_timespec_sum(struct timespec *res,
+bool_t faux_timespec_sum(struct timespec *res,
 	const struct timespec *val1, const struct timespec *val2)
 {
 	assert(res);
@@ -99,13 +99,13 @@ int faux_timespec_sum(struct timespec *res,
 	assert(val2);
 	if (!res || !val1 || !val2) {
 		errno = EINVAL;
-		return -1;
+		return BOOL_FALSE;
 	}
 
 	res->tv_sec = val1->tv_sec + val2->tv_sec + ((val1->tv_nsec + val2->tv_nsec) / 1000000000l);
 	res->tv_nsec = (val1->tv_nsec + val2->tv_nsec) % 1000000000l;
 
-	return 0;
+	return BOOL_TRUE;
 }
 
 /** @brief Converts struct timespec value to nanoseconds.