[evolution] Add argument checks to weekday functions.



commit 959c04d0ceff552c5d9a551f79702c33bdac16a5
Author: Matthew Barnes <mbarnes redhat com>
Date:   Thu Mar 14 20:15:08 2013 -0400

    Add argument checks to weekday functions.

 e-util/e-misc-utils.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/e-util/e-misc-utils.c b/e-util/e-misc-utils.c
index 0f35099..776027d 100644
--- a/e-util/e-misc-utils.c
+++ b/e-util/e-misc-utils.c
@@ -1596,6 +1596,10 @@ GDateWeekday
 e_weekday_add_days (GDateWeekday weekday,
                     guint n_days)
 {
+       g_return_val_if_fail (
+               g_date_valid_weekday (weekday),
+               G_DATE_BAD_WEEKDAY);
+
        n_days %= 7;  /* Weekdays repeat every 7 days. */
 
        while (n_days-- > 0)
@@ -1617,6 +1621,10 @@ GDateWeekday
 e_weekday_subtract_days (GDateWeekday weekday,
                          guint n_days)
 {
+       g_return_val_if_fail (
+               g_date_valid_weekday (weekday),
+               G_DATE_BAD_WEEKDAY);
+
        n_days %= 7;  /* Weekdays repeat every 7 days. */
 
        while (n_days-- > 0)
@@ -1640,6 +1648,9 @@ e_weekday_get_days_between (GDateWeekday weekday1,
 {
        guint n_days = 0;
 
+       g_return_val_if_fail (g_date_valid_weekday (weekday1), 0);
+       g_return_val_if_fail (g_date_valid_weekday (weekday2), 0);
+
        while (weekday1 != weekday2) {
                n_days++;
                weekday1 = e_weekday_get_next (weekday1);


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