[Groonga-commit] groonga/groonga at d09c6b7 [master] Fix a bug causing tv_sec overflow problem.

Back to archive index

Daijiro MORI null+****@clear*****
Thu Oct 24 18:36:30 JST 2013


Daijiro MORI	2013-10-24 18:36:30 +0900 (Thu, 24 Oct 2013)

  New Revision: d09c6b74d768ef661a5a5ecf61d968948c16b43e
  https://github.com/groonga/groonga/commit/d09c6b74d768ef661a5a5ecf61d968948c16b43e

  Message:
    Fix a bug causing tv_sec overflow problem.

  Modified files:
    lib/ctx.c
    lib/ctx.h

  Modified: lib/ctx.c (+4 -4)
===================================================================
--- lib/ctx.c    2013-10-23 17:27:20 +0900 (d5d7588)
+++ lib/ctx.c    2013-10-24 18:36:30 +0900 (781f81b)
@@ -92,7 +92,7 @@ grn_timeval_now(grn_ctx *ctx, grn_timeval *tv)
   if (clock_gettime(CLOCK_REALTIME, &t)) {
     SERR("clock_gettime");
   } else {
-    tv->tv_sec = (int32_t) t.tv_sec;
+    tv->tv_sec = t.tv_sec;
     tv->tv_nsec = t.tv_nsec;
   }
   return ctx->rc;
@@ -102,7 +102,7 @@ grn_timeval_now(grn_ctx *ctx, grn_timeval *tv)
   struct _timeb tb;
   time(&t);
   _ftime(&tb);
-  tv->tv_sec = (int32_t) t;
+  tv->tv_sec = t;
   tv->tv_nsec = tb.millitm * (GRN_TIME_NSEC_PER_SEC / 1000);
   return GRN_SUCCESS;
 #else /* WIN32 */
@@ -110,7 +110,7 @@ grn_timeval_now(grn_ctx *ctx, grn_timeval *tv)
   if (gettimeofday(&t, NULL)) {
     SERR("gettimeofday");
   } else {
-    tv->tv_sec = (int32_t) t.tv_sec;
+    tv->tv_sec = t.tv_sec;
     tv->tv_nsec = GRN_TIME_USEC_TO_NSEC(t.tv_usec);
   }
   return ctx->rc;
@@ -187,7 +187,7 @@ grn_str2timeval(const char *str, uint32_t str_len, grn_timeval *tv)
   }
   r1 = r2;
 
-  if ((tv->tv_sec = (int32_t) mktime(&tm)) == -1) { return GRN_INVALID_ARGUMENT; }
+  if ((tv->tv_sec = mktime(&tm)) == -1) { return GRN_INVALID_ARGUMENT; }
   if ((r1 + 1) < rend && *r1 == '.') { r1++; }
   uv = grn_atoi(r1, rend, &r2);
   while (r2 < r1 + 6) {

  Modified: lib/ctx.h (+1 -1)
===================================================================
--- lib/ctx.h    2013-10-23 17:27:20 +0900 (50df921)
+++ lib/ctx.h    2013-10-24 18:36:30 +0900 (572925c)
@@ -388,7 +388,7 @@ extern uint32_t grn_gtick;
 #define GRN_CTX_TEMPORARY_DISABLE_II_RESOLVE_SEL_AND (0x40)
 
 typedef struct {
-  int32_t tv_sec;
+  int64_t tv_sec;
   int32_t tv_nsec;
 } grn_timeval;
 
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index