[glib: 7/10] Fixing signedness in glib/gdate.c



commit 6e49b36cc2efe5c97fb8e0c5dbe7e02b6bf9beb2
Author: Emmanuel Fleury <emmanuel fleury u-bordeaux fr>
Date:   Sat Jan 26 22:48:27 2019 +0100

    Fixing signedness in glib/gdate.c
    
    glib/gdate.c: In function ‘g_date_add_months’:
    glib/gdate.c:1732:27: error: comparison of integer expressions of different signedness: ‘guint’ {aka 
‘unsigned int’} and ‘int’ [-Werror=sign-compare]
       g_return_if_fail (years <= G_MAXUINT16 - d->year);
                               ^~
    glib/gmacros.h:455:25: note: in definition of macro ‘G_LIKELY’
     #define G_LIKELY(expr) (expr)
                             ^~~~
    glib/gdate.c:1732:3: note: in expansion of macro ‘g_return_if_fail’
       g_return_if_fail (years <= G_MAXUINT16 - d->year);
       ^~~~~~~~~~~~~~~~
    glib/gdate.c: In function ‘g_date_add_years’:
    glib/gdate.c:1816:28: error: comparison of integer expressions of different signedness: ‘guint’ {aka 
‘unsigned int’} and ‘int’ [-Werror=sign-compare]
       g_return_if_fail (nyears <= G_MAXUINT16 - d->year);
                                ^~
    glib/gmacros.h:455:25: note: in definition of macro ‘G_LIKELY’
     #define G_LIKELY(expr) (expr)
                             ^~~~
    glib/gdate.c:1816:3: note: in expansion of macro ‘g_return_if_fail’
       g_return_if_fail (nyears <= G_MAXUINT16 - d->year);
       ^~~~~~~~~~~~~~~~

 glib/gdate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/glib/gdate.c b/glib/gdate.c
index 5457a3b8c..b33168018 100644
--- a/glib/gdate.c
+++ b/glib/gdate.c
@@ -1729,7 +1729,7 @@ g_date_add_months (GDate *d,
   years  = nmonths/12;
   months = nmonths%12;
 
-  g_return_if_fail (years <= G_MAXUINT16 - d->year);
+  g_return_if_fail (years <= (guint) (G_MAXUINT16 - d->year));
 
   d->month = months + 1;
   d->year  += years;
@@ -1813,7 +1813,7 @@ g_date_add_years (GDate *d,
     g_date_update_dmy (d);
 
   g_return_if_fail (d->dmy != 0);
-  g_return_if_fail (nyears <= G_MAXUINT16 - d->year);
+  g_return_if_fail (nyears <= (guint) (G_MAXUINT16 - d->year));
 
   d->year += nyears;
   


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