[glib: 1/6] Fix always false statement warning in glib/gdatetime.c




commit 33c29686690ee16fa437d64a479793e9fdc212e3
Author: Emmanuel Fleury <emmanuel fleury gmail com>
Date:   Fri May 14 10:47:40 2021 +0200

    Fix always false statement warning in glib/gdatetime.c
    
    glib/gdatetime.c:896:27: warning: comparison is always false due to limited range of data type
       if ((gint64) tv->tv_sec > G_MAXINT64 - 1 ||
                               ^

 glib/gdatetime.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/glib/gdatetime.c b/glib/gdatetime.c
index a31afe713..429cadefc 100644
--- a/glib/gdatetime.c
+++ b/glib/gdatetime.c
@@ -893,8 +893,9 @@ static GDateTime *
 g_date_time_new_from_timeval (GTimeZone      *tz,
                               const GTimeVal *tv)
 {
-  if ((gint64) tv->tv_sec > G_MAXINT64 - 1 ||
-      !UNIX_TO_INSTANT_IS_VALID ((gint64) tv->tv_sec + 1))
+  gint64 tv_sec = tv->tv_sec;
+
+  if (tv_sec > G_MAXINT64 - 1 || !UNIX_TO_INSTANT_IS_VALID (tv_sec + 1))
     return NULL;
 
   return g_date_time_from_instant (tz, tv->tv_usec +


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]