Apply coding guide:modified sign > -> < 42/46642/1
authorJeesun Kim <iamjs.kim@samsung.com>
Tue, 12 May 2015 04:37:09 +0000 (13:37 +0900)
committerJeesun Kim <iamjs.kim@samsung.com>
Mon, 24 Aug 2015 09:58:32 +0000 (18:58 +0900)
Change-Id: I9b27c6f81a5f39966d824361f4e40fd578ea08dc

30 files changed:
common/cal_inotify.c
common/cal_list.c
common/cal_query.c
common/cal_record.c
common/cal_record_calendar.c
common/cal_record_extended.c
common/cal_time.cpp
common/cal_vcalendar_make.c
common/cal_vcalendar_parse.c
common/ipc/cal_ipc_marshal.c
native/cal_calendar.h
native/cal_db.c
native/cal_db_event.c
native/cal_db_instance.c
native/cal_db_plugin_alarm.c
native/cal_db_plugin_attendee.c
native/cal_db_plugin_calendar.c
native/cal_db_plugin_event.c
native/cal_db_plugin_extended.c
native/cal_db_plugin_instance_allday.c
native/cal_db_plugin_instance_allday_extended.c
native/cal_db_plugin_instance_normal.c
native/cal_db_plugin_instance_normal_extended.c
native/cal_db_plugin_search.c
native/cal_db_plugin_timezone.c
native/cal_db_plugin_todo.c
native/cal_db_rrule.c
native/cal_db_timezone.c
server/cal_server_alarm.c
server/cal_server_contacts.c

index 407ba9e..b20832e 100644 (file)
@@ -150,7 +150,7 @@ static gboolean _inotify_gio_cb(GIOChannel *src, GIOCondition cond, gpointer dat
                                        else
                                                return TRUE;
                                }
-                               if (ret > ie.len)
+                               if (ie.len < ret)
                                {
                                        ie.len = 0;
                                }
@@ -215,7 +215,7 @@ int cal_inotify_initialize(void)
        cal_mutex_lock(CAL_MUTEX_INOTIFY);
        calendar_inoti_count++;
 
-       if (calendar_inoti_count > 1)
+       if (1 < calendar_inoti_count)
        {
                DBG("inotify count =%d",calendar_inoti_count);
                cal_mutex_unlock(CAL_MUTEX_INOTIFY);
@@ -505,7 +505,7 @@ void cal_inotify_finalize(void)
        cal_mutex_lock(CAL_MUTEX_INOTIFY);
        calendar_inoti_count--;
 
-       if (calendar_inoti_count > 0)
+       if (0 < calendar_inoti_count)
        {
                DBG("inotify count =%d",calendar_inoti_count);
                cal_mutex_unlock(CAL_MUTEX_INOTIFY);
@@ -527,7 +527,7 @@ void cal_inotify_finalize(void)
                noti_list = NULL;
        }
 
-       if (inoti_fd >= 0)
+       if (0 <= inoti_fd)
        {
                close(inoti_fd);
                inoti_fd = -1;
index f802079..920eb5e 100644 (file)
@@ -319,7 +319,7 @@ int cal_list_get_nth_record_p(cal_list_s *list_s, int index, calendar_record_h *
                return CALENDAR_ERROR_NONE;
        }
 
-       ERR("Check index(%d) > count(%d)", index, list_s->count);
+       ERR("Check count(%d) < index(%d)", list_s->count, index);
        return CALENDAR_ERROR_NO_DATA;
 }
 
index 41c259a..feee1aa 100644 (file)
@@ -189,7 +189,7 @@ int cal_query_clone(calendar_query_h query, calendar_query_h* out_query)
                cal_filter_clone((calendar_filter_h)que->filter,(calendar_filter_h*)&out_filter);
        }
 
-       if (que->projection_count > 0)
+       if (0 < que->projection_count)
        {
                out_que->projection = calloc(que->projection_count, sizeof(unsigned int));
                RETVM_IF(NULL == out_que->projection, CALENDAR_ERROR_OUT_OF_MEMORY, "calloc() Fail");
index b000f2e..d129a96 100644 (file)
@@ -96,7 +96,7 @@ static inline void _cal_record_set_property_flag(calendar_record_h record, unsig
                int count = 0;
                cal_view_get_property_info(_record->view_uri,&count);
 
-               if (count > 0)
+               if (0 < count)
                {
                        _record->properties_flags = calloc(count, sizeof(char));
                        _record->properties_max_count = count;
index fe408f9..4fa26d6 100644 (file)
@@ -313,7 +313,7 @@ static int _cal_record_calendar_set_int(calendar_record_h record, unsigned int p
                (cal_rec->visibility) = value;
                break;
        case CAL_PROPERTY_CALENDAR_ACCOUNT_ID:
-               RETVM_IF(cal_rec->index > 0, CALENDAR_ERROR_INVALID_PARAMETER, "property_id(%d) is a write-once value (calendar)", property_id);
+               RETVM_IF(0 < cal_rec->index, CALENDAR_ERROR_INVALID_PARAMETER, "property_id(%d) is a write-once value (calendar)", property_id);
                (cal_rec->account_id) = value;
                break;
        case CAL_PROPERTY_CALENDAR_STORE_TYPE:
index 39be46e..255a348 100644 (file)
@@ -209,7 +209,7 @@ static int _cal_record_extended_set_int(calendar_record_h record, unsigned int p
                (rec->id) = value;
                break;
        case CAL_PROPERTY_EXTENDED_RECORD_ID:
-               RETVM_IF(rec->id > 0, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter : property_id(%d) is a write-once value (calendar)", property_id);
+               RETVM_IF(0 < rec->id, CALENDAR_ERROR_INVALID_PARAMETER, "Invalid parameter : property_id(%d) is a write-once value (calendar)", property_id);
                (rec->record_id) = value;
                break;
        case CAL_PROPERTY_EXTENDED_RECORD_TYPE:
index 720a7c6..d6b6472 100644 (file)
@@ -364,7 +364,7 @@ UCalendar *cal_time_open_ucal(int calendar_system_type, const char *tzid, int wk
                return NULL;
        }
 
-       if (wkst >= CALENDAR_SUNDAY && wkst <= CALENDAR_SATURDAY)
+       if (CALENDAR_SUNDAY <= wkst && wkst <= CALENDAR_SATURDAY)
        {
                DBG("set wkst(%d)", wkst);
                ucal_setAttribute(ucal, UCAL_FIRST_DAY_OF_WEEK, wkst);
@@ -386,7 +386,7 @@ UCalendar *cal_time_get_ucal(const char *tzid, int wkst)
                return NULL;
        }
 
-       if (wkst >= CALENDAR_SUNDAY && wkst <= CALENDAR_SATURDAY)
+       if (CALENDAR_SUNDAY <= wkst && wkst <= CALENDAR_SATURDAY)
        {
                ucal_setAttribute(ucal, UCAL_FIRST_DAY_OF_WEEK, wkst);
        }
index 8f447a3..075a23e 100644 (file)
@@ -303,7 +303,7 @@ static const char* vl_tick(calendar_alarm_time_unit_type_e unit, int tick)
        static char buf[32] = {0};
 
        int i = 0;
-       if (tick > 0) {
+       if (0 < tick) {
                *buf = '-';
                i++;
 
@@ -528,7 +528,7 @@ int _cal_vcalendar_make_rrule_append_mday(char *buf, int buf_len, char *mday)
 
                p = t[i];
                num = atoi(p);
-               len += snprintf(buf +len, buf_len -len, "%d%s ", num, num > 0 ? "" : "-");
+               len += snprintf(buf +len, buf_len -len, "%d%s ", num, 0 < num? "": "-");
        }
        g_strfreev(t);
 
@@ -587,7 +587,7 @@ static void _cal_vcalendar_make_rrule_append_setpos(calendar_record_h record, ch
                int sign = 0;
                while (i <= len) {
                        // extract -1, 1 from 1SU,-1SU
-                       if ((byday[i] >= '1' && byday[i] <= '9')) {
+                       if ('1' <= byday[i] && byday[i] <= '9') {
                                is_working = false;
                                digit++;
                        } else if ('+' == byday[i]) {
@@ -645,7 +645,7 @@ void _cal_vcalendar_make_rrule_append_text_wday(int rrule_type, char *buf, int b
                        p++;
 
                j = 0;
-               while (p[j] == '+' || p[j] == '-' || (p[j] >= '1' && p[j] <= '9')) // get number length
+               while (p[j] == '+' || p[j] == '-' || ('1' <= p[j] && p[j] <= '9')) // get number length
                        j++;
                if (strstr(buf, p +j)) // already appended
                        continue;
@@ -661,7 +661,7 @@ void _cal_vcalendar_make_rrule_append_wkst(char *buf, int buf_len, calendar_reco
        const char wday[7][3] = {"SU", "MO", "TU", "WE", "TH", "FR", "SA"};
        int wkst = 0;
        calendar_record_get_int(record, _calendar_event.wkst, &wkst);
-       if (wkst < CALENDAR_SUNDAY || wkst > CALENDAR_SATURDAY)
+       if (wkst < CALENDAR_SUNDAY || CALENDAR_SATURDAY < wkst)
                return;
 
        DBG("wkst(%d) [%s]", wkst, wday[wkst - 1]);
@@ -701,10 +701,10 @@ int _cal_vcalendar_make_rrule_append_wday(int rrule_type, char *buf, int buf_len
 
                p = t[i];
                j = 0; // get number
-               while (p[j] == '+' || p[j] == '-' || (p[j] >= '1' && p[j] <= '9'))
+               while (p[j] == '+' || p[j] == '-' || ('1' <= p[j] && p[j] <= '9'))
                        j++;
 
-               if (j > 0)
+               if (0 < j)
                {
                        if (CALENDAR_RECURRENCE_WEEKLY == rrule_type)
                        {
@@ -974,7 +974,7 @@ static void __make_rrule_ver1(cal_make_s *b, calendar_record_h record)
        int interval = 1;
        ret = calendar_record_get_int(record, _calendar_event.interval, &interval);
        RETM_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() Fail(%d)", ret);
-       interval = interval > 0 ? interval : 1;
+       interval = 0 < interval ? interval : 1;
 
        char *byyearday = NULL;
        ret = calendar_record_get_str_p(record, _calendar_event.byyearday, &byyearday);
@@ -1097,7 +1097,7 @@ static void __make_rrule_ver2(cal_make_s *b, calendar_record_h record)
        int interval = 1;
        ret = calendar_record_get_int(record, _calendar_event.interval, &interval);
        WARN_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() Fail(%d)", ret);
-       interval = interval > 0 ? interval : 1;
+       interval = 0 < interval ? interval : 1;
        snprintf(tmp, sizeof(tmp), ";INTERVAL=%d", interval);
        _cal_vcalendar_make_set_str(b, tmp);
 
@@ -1185,7 +1185,7 @@ static void __make_rrule_ver2(cal_make_s *b, calendar_record_h record)
        int wkst = 0;
        ret = calendar_record_get_int(record, _calendar_event.wkst, &wkst);
        WARN_IF(CALENDAR_ERROR_NONE != ret, "calendar_record_get_int() Fail(%d)", ret);
-       if (wkst >= CALENDAR_SUNDAY && wkst <= CALENDAR_SATURDAY) {
+       if (CALENDAR_SUNDAY <= wkst && wkst <= CALENDAR_SATURDAY) {
                _cal_vcalendar_make_set_str(b, ";WKST=");
                switch (wkst) {
                case CALENDAR_SUNDAY:
index 0ab680c..88e96a8 100644 (file)
@@ -373,7 +373,7 @@ static inline void __adjust_tzid(char *p)
        int i = 0;
        while (*(p +i)) {
                if ('-' == *(p +i)) {
-                       if ('1' <= *(p +i +1) && '9' >= *(p +i +1)) {
+                       if ('1' <= *(p +i +1) && *(p +i +1) <= '9') {
                                i++;
                        } else {
                                *(p +i) = '/';
@@ -1150,7 +1150,7 @@ static void __work_component_property_priority(char *value, calendar_record_h re
        RET_IF('\0' == *value);
        RET_IF(NULL == record);
        RET_IF(NULL == ud);
-       RETM_IF(*value < '0' || *value > '9', "out of range[%s]", value);
+       RETM_IF(*value < '0' || '9' < *value, "out of range[%s]", value);
 
        int ret = 0;
        int modified_priority = __decode_priority(value, ud);
@@ -1989,7 +1989,7 @@ static void __work_component_property_dalarm(char *value, calendar_record_h reco
                if (index) index++;
                if (NULL == t[i] || '\0' == *t[i]) continue;
 
-               if ('0' <= *t[i] && *t[i] <= '9' && strlen(t[i]) > strlen("PTM")) { // runTime
+               if ('0' <= *t[i] && *t[i] <= '9' && strlen("PTM") < strlen(t[i])) { // runTime
                        index = 1;
                        calendar_time_s caltime = {0};
                        __get_caltime(t[i], &caltime, ud);
@@ -2063,7 +2063,7 @@ static void __work_component_property_malarm(char *value, calendar_record_h reco
                if (index) index++;
                if (NULL == t[i] || '\0' == *t[i]) continue;
 
-               if ('0' <= *t[i] && *t[i] <= '9' && strlen(t[i]) > strlen("PTM")) { // runTime
+               if ('0' <= *t[i] && *t[i] <= '9' && strlen("PTM") < strlen(t[i])) { // runTime
                        index = 1;
                        calendar_time_s caltime = {0};
                        __get_caltime(t[i], &caltime, ud);
@@ -2144,7 +2144,7 @@ static void __work_component_property_aalarm(char *value, calendar_record_h reco
                if (index) index++;
                if (NULL == t[i] || '\0' == *t[i]) continue;
 
-               if ('0' <= *t[i] && *t[i] <= '9' && strlen(t[i]) > strlen("PTM")) { // runTime
+               if ('0' <= *t[i] && *t[i] <= '9' && strlen("PTM") < strlen(t[i])) { // runTime
                        index = 1;
                        calendar_time_s caltime = {0};
                        __get_caltime(t[i], &caltime, ud);
@@ -2343,7 +2343,7 @@ static void __work_component_property_valarm_trigger(char *value, calendar_recor
                } else if (!strncmp(t[i], "VALUE", strlen("VALUE"))) {
                        // do nothing
                } else {
-                       if ('0' <= *t[i] && *t[i] <= '9' && strlen(t[i]) >= strlen("YYYYDDMM")) {
+                       if ('0' <= *t[i] && *t[i] <= '9' && strlen("YYYYDDMM") <= strlen(t[i])) {
                                calendar_time_s caltime = {0};
                                __get_caltime(t[i], &caltime, ud);
                                ret = cal_record_set_caltime(alarm, _calendar_alarm.alarm_time, caltime);
@@ -2354,9 +2354,11 @@ static void __work_component_property_valarm_trigger(char *value, calendar_recor
                                int unit = 0;
                                int tick = 0;
                                __decode_duration(t[i], strlen(t[i]), &tick, &unit);
-                               if (CALENDAR_ALARM_TIME_UNIT_SPECIFIC == unit || tick > 0) {
-                                       if (CALENDAR_ALARM_TIME_UNIT_SPECIFIC == unit) DBG("alarm tick is second, changed as specific.");
-                                       if (tick > 0) DBG("alarm is set after start/end time(%d).", tick);
+                               if (CALENDAR_ALARM_TIME_UNIT_SPECIFIC == unit || 0 < tick) {
+                                       if (CALENDAR_ALARM_TIME_UNIT_SPECIFIC == unit)
+                                               DBG("alarm tick is second, changed as specific.");
+                                       if (0 < tick)
+                                               DBG("alarm is set after start/end time(%d).", tick);
 
                                        calendar_time_s caltime = {0};
                                        if (VCAL_RELATED_NONE == related) {
index 3715f19..0e2d1f0 100644 (file)
@@ -666,7 +666,7 @@ int cal_ipc_unmarshal_record_common(const pims_ipc_data_h ipc_data, cal_record_s
                return CALENDAR_ERROR_NO_DATA;
        }
        common->properties_max_count = *(unsigned int*)ret_pims;
-       if (common->properties_max_count > 0) {
+       if (0 < common->properties_max_count) {
                unsigned char *tmp_properties_flags;
                ret_pims = pims_ipc_data_get(ipc_data,&size);
                if (NULL == ret_pims) {
@@ -820,7 +820,7 @@ int cal_ipc_marshal_record_common(const cal_record_s* common, pims_ipc_data_h ip
                return CALENDAR_ERROR_NO_DATA;
        }
 
-       if (common->properties_max_count > 0) {
+       if (0 < common->properties_max_count) {
                if(pims_ipc_data_put(ipc_data,(void*)common->properties_flags,sizeof(char)*common->properties_max_count) < 0) {
                        ERR("cal_ipc_marshal fail");
                        return CALENDAR_ERROR_NO_DATA;
@@ -895,7 +895,7 @@ int cal_ipc_unmarshal_query(const pims_ipc_data_h ipc_data, calendar_query_h *qu
                goto ERROR_RETURN;
        }
 
-       if (que->projection_count > 0) {
+       if (0 < que->projection_count) {
                que->projection = (unsigned int*)calloc(que->projection_count, sizeof(int));
                if (que->projection == NULL) {
                        ERR("calloc() Fail");
index dfb17ed..3fb97b0 100644 (file)
@@ -20,8 +20,8 @@
 #ifndef __CALENDAR_SVC_CALENDAR_H__
 #define __CALENDAR_SVC_CALENDAR_H__
 
-void cal_calendar_internal_disconnect(const char *zone_name);
-int cal_connect(const char *zone_name);
-int cal_disconnect(const char *zone_name);
+void cal_calendar_internal_disconnect(void);
+int cal_connect(void);
+int cal_disconnect(void);
 
 #endif // __CALENDAR_SVC_CALENDAR_H__
index 0792cdb..7dbdef3 100755 (executable)
@@ -711,14 +711,10 @@ API int calendar_db_clean_after_sync(int calendar_book_id,  int calendar_db_vers
        }
 
        /* delete event table */
-       len = snprintf(query, sizeof(query), "DELETE FROM %s "
-                       "WHERE is_deleted = 1 AND calendar_id = %d",
-                       CAL_TABLE_SCHEDULE,
-                       calendar_book_id);
-       if (calendar_db_version > 0)
-       {
+       len = snprintf(query, sizeof(query), "DELETE FROM %s WHERE is_deleted = 1 AND calendar_id = %d",
+                       CAL_TABLE_SCHEDULE, calendar_book_id);
+       if (0 < calendar_db_version)
                len = snprintf(query+len, sizeof(query)-len, " AND changed_ver <= %d", calendar_db_version);
-       }
 
        dbret = cal_db_util_query_exec(query);
        DBG("%s",query);
@@ -855,7 +851,7 @@ API int calendar_db_insert_records(calendar_list_h list, int** ids, int* count)
                DBG("insert with id(%d)", _ids[i]);
                calendar_list_next(list);
 
-               if (i > bulk)
+               if (bulk < i)
                {
                        bulk += (_count / div + 1);
                        cal_db_util_end_trans(true);
@@ -938,7 +934,7 @@ API int calendar_db_update_records(calendar_list_h list)
                DBG("update record");
                calendar_list_next(list);
 
-               if (i > bulk)
+               if (bulk < i)
                {
                        bulk += (count / div + 1);
                        cal_db_util_end_trans(true);
@@ -1169,7 +1165,7 @@ API int calendar_db_replace_vcalendars(const char* vcalendar_stream, int *record
                }
                calendar_list_next(list);
 
-               if (i > bulk)
+               if (bulk < i)
                {
                        bulk += (count / div + 1);
                        cal_db_util_end_trans(true);
@@ -1211,13 +1207,9 @@ API int calendar_db_replace_record(calendar_record_h record, int record_id)
        ret = plugin_cb->replace_record(record, record_id);
 
        if (CALENDAR_ERROR_NONE == ret)
-       {
                ret = cal_db_util_end_trans(true);
-       }
        else
-       {
                cal_db_util_end_trans(false);
-       }
 
        return ret;
 }
index d88b3e7..bf63381 100644 (file)
@@ -59,9 +59,8 @@ int cal_db_event_update_original_event_version(int original_event_id, int versio
        cal_db_util_error_e dbret = CAL_DB_OK;
 
        DBG("original_event(%d) changed_ver updated", original_event_id);
-       if (original_event_id > 0) {
-               snprintf(query, sizeof(query), "UPDATE %s SET "
-                               "changed_ver = %d, has_exception = 1 WHERE id = %d ",
+       if (0 < original_event_id) {
+               snprintf(query, sizeof(query), "UPDATE %s SET changed_ver=%d, has_exception = 1 WHERE id=%d ",
                                CAL_TABLE_SCHEDULE, version, original_event_id);
 
                dbret = cal_db_util_query_exec(query);
@@ -92,40 +91,46 @@ int cal_db_event_check_value_validation(cal_event_s *event)
 
        switch (event->start.type) {
        case CALENDAR_TIME_UTIME:
-               if (event->start.time.utime > event->end.time.utime) {
-                       ERR("normal start(%lld) > end(%lld)",
-                                       event->start.time.utime, event->end.time.utime);
+               if (event->end.time.utime < event->start.time.utime) {
+                       ERR("normal end(%lld) < start(%lld)",
+                                       event->end.time.utime, event->start.time.utime);
                        return CALENDAR_ERROR_INVALID_PARAMETER;
                }
                break;
 
        case CALENDAR_TIME_LOCALTIME:
                // check invalid value
-               if (event->start.time.date.month < 1 || event->start.time.date.month > 12) {
+               if (event->start.time.date.month < 1 || 12 < event->start.time.date.month) {
                        ERR("check start month(input:%d)", event->start.time.date.month);
                        return CALENDAR_ERROR_INVALID_PARAMETER;
                }
-               else if (event->start.time.date.mday < 1 || event->start.time.date.mday > 31) {
+               else if (event->start.time.date.mday < 1 || 31 < event->start.time.date.mday) {
                        ERR("check start mday(input:%d)", event->start.time.date.mday);
                        return CALENDAR_ERROR_INVALID_PARAMETER;
                }
-               else if (event->end.time.date.month < 1 || event->end.time.date.month > 12) {
+               else if (event->end.time.date.month < 1 || 12 < event->end.time.date.month) {
                        ERR("check end month(input:%d)", event->end.time.date.month);
                        return CALENDAR_ERROR_INVALID_PARAMETER;
                }
-               else if (event->end.time.date.mday < 1 || event->end.time.date.mday > 31) {
+               else if (event->end.time.date.mday < 1 || 31 < event->end.time.date.mday) {
                        ERR("check end mday(input:%d)", event->end.time.date.mday);
                        return CALENDAR_ERROR_INVALID_PARAMETER;
                } else { // handle hour, minute, second
-                       if (event->start.time.date.hour < 0 || event->start.time.date.hour > 24) event->start.time.date.hour = 0;
-                       if (event->start.time.date.minute < 0 || event->start.time.date.minute > 60) event->start.time.date.minute = 0;
-                       if (event->start.time.date.second < 0 || event->start.time.date.second > 60) event->start.time.date.second = 0;
-                       if (event->end.time.date.hour < 0 || event->end.time.date.hour > 24) event->end.time.date.hour = 0;
-                       if (event->end.time.date.minute < 0 || event->end.time.date.minute > 60) event->end.time.date.minute = 0;
-                       if (event->end.time.date.second < 0 || event->end.time.date.second > 60) event->end.time.date.second = 0;
+                       if (event->start.time.date.hour < 0 || 24 < event->start.time.date.hour)
+                               event->start.time.date.hour = 0;
+                       if (event->start.time.date.minute < 0 || 60 < event->start.time.date.minute)
+                               event->start.time.date.minute = 0;
+                       if (event->start.time.date.second < 0 || 60 < event->start.time.date.second)
+                               event->start.time.date.second = 0;
+                       if (event->end.time.date.hour < 0 || 24 < event->end.time.date.hour)
+                               event->end.time.date.hour = 0;
+                       if (event->end.time.date.minute < 0 || 60 < event->end.time.date.minute)
+                               event->end.time.date.minute = 0;
+                       if (event->end.time.date.second < 0 || 60 < event->end.time.date.second)
+                               event->end.time.date.second = 0;
                }
 
-               // check start > end; convert long long int.
+               // check end < start; convert long long int.
                slli = cal_time_convert_itol(NULL,
                                event->start.time.date.year, event->start.time.date.month, event->start.time.date.mday,
                                event->start.time.date.hour, event->start.time.date.minute, event->start.time.date.second);
@@ -133,8 +138,8 @@ int cal_db_event_check_value_validation(cal_event_s *event)
                                event->end.time.date.year, event->end.time.date.month, event->end.time.date.mday,
                                event->end.time.date.hour, event->end.time.date.minute, event->end.time.date.second);
 
-               if (slli - elli > 1) { // 1 is to ignore milliseconds
-                       ERR("allday start(%lld) > end(%lld)", slli, elli);
+               if (1 < slli - elli) { // 1 is to ignore milliseconds
+                       ERR("allday end(%lld) < start(%lld)", elli, slli);
                        return CALENDAR_ERROR_INVALID_PARAMETER;
                }
                break;
@@ -698,7 +703,7 @@ int cal_db_event_insert_record(calendar_record_h record, int original_event_id,
                (long long int)0, 0, //event->completed_time, event->progress,
                event->start.type, event->start.type == CALENDAR_TIME_UTIME ? event->start.time.utime : 0,
                event->end.type, event->end.type == CALENDAR_TIME_UTIME ? event->end.time.utime : 0,
-               event->freq > 0 ? 1 : 0,
+               0 < event->freq ? 1 : 0,
                (0 < event->attendee_list->count) ? 1 : 0,
                has_alarm,
                event->system_type,
@@ -834,7 +839,7 @@ int cal_db_event_insert_record(calendar_record_h record, int original_event_id,
                cal_db_rrule_insert_record(event_id, rrule);
                CAL_FREE(rrule);
        }
-       if (original_event_id > 0) {
+       if (0 < original_event_id) {
                cal_record_set_int(record, _calendar_event.original_event_id, original_event_id);
        }
        cal_db_instance_publish_record(record);
index 86b163f..226d95c 100644 (file)
@@ -368,33 +368,19 @@ static int _cal_db_instance_update_exdate_mod(int original_event_id, char *recur
 
 static inline int __cal_db_instance_has_after(calendar_time_s *t1, calendar_time_s *t2)
 {
-       if (t1->type == CALENDAR_TIME_UTIME) {
-               if (t1->time.utime > t2->time.utime)
-                       return 1;
-               else
-                       return 0;
-       }
+       if (t1->type == CALENDAR_TIME_UTIME)
+               return t1->time.utime < t2->time.utime ? 0 : 1;
 
        DBG("%d %d %d /%d %d %d", t1->time.date.year, t1->time.date.month, t1->time.date.mday,
                        t2->time.date.year, t2->time.date.month, t2->time.date.mday);
-       if (t1->time.date.year > t2->time.date.year) {
-               DBG("exit year");
-               return 1;
-       } else if (t1->time.date.year < t2->time.date.year) {
-               return 0;
-       } else {
-               if (t1->time.date.month > t2->time.date.month) {
-                       return 1;
-               } else if (t1->time.date.month < t2->time.date.month) {
-                       return 0;
-               } else {
-                       if (t1->time.date.mday > t2->time.date.mday) {
-                               return 1;
-                       } else {
-                               return 0;
-                       }
+
+       if (t1->time.date.year == t2->time.date.year) {
+               if (t1->time.date.month == t2->time.date.month) {
+                       return t1->time.date.mday < t2->time.date.mday ? 0 : 1;
                }
+               return t1->time.date.month < t2->time.date.month ? 0 : 1;
        }
+       return t1->time.date.year < t2->time.date.year ? 0 : 1;
 }
 
 static inline int _cal_db_instance_convert_mday(const char *str, int *mday)
@@ -405,7 +391,7 @@ static inline int _cal_db_instance_convert_mday(const char *str, int *mday)
        RETV_IF(*str, CALENDAR_ERROR_INVALID_PARAMETER);
 
        d = atoi(str);
-       RETVM_IF(d < 1 || d > 31, CALENDAR_ERROR_INVALID_PARAMETER, "day(%d)", d);
+       RETVM_IF(d < 1 || 31 < d, CALENDAR_ERROR_INVALID_PARAMETER, "day(%d)", d);
 
        DBG("get mday[%s] and convert to int(%d)", str, d);
        *mday = d;
@@ -499,8 +485,8 @@ static int _cal_db_instance_get_duration(UCalendar *ucal, calendar_time_s *st, c
 
        switch (st->type) {
        case CALENDAR_TIME_UTIME:
-               if (st->time.utime > et->time.utime) {
-                       ERR("check time: start(%lld) > end(%lld)", st->time.utime, et->time.utime);
+               if ( et->time.utime < st->time.utime) {
+                       ERR("check time: end(%lld < start(%lld)", et->time.utime, st->time.utime);
                        return CALENDAR_ERROR_INVALID_PARAMETER;
                }
                _duration = et->time.utime - st->time.utime;
@@ -551,7 +537,7 @@ static int _cal_db_instance_insert_record(UCalendar *ucal, long long int duratio
                __get_allday_date(event, ucal, &y, &m, &d, &h, &n, &s);
                snprintf(buf_s, sizeof(buf_s), CAL_FORMAT_LOCAL_DATETIME, y, m, d, h, n, s);
 
-               if (duration > 0) {
+               if (0 < duration) {
                        UCalendar *ucal2 = NULL;
                        ucal2 = ucal_clone(ucal, &ec);
                        ucal_add(ucal2, UCAL_SECOND, duration, &ec);
@@ -599,8 +585,8 @@ static int __get_until_from_range(cal_event_s *event, calendar_time_s *until)
                case CALENDAR_TIME_UTIME:
                        range = cal_time_convert_itol(NULL, CAL_ENDLESS_LIMIT_YEAR,
                                        CAL_ENDLESS_LIMIT_MONTH, CAL_ENDLESS_LIMIT_MDAY, 0, 0, 0);
-                       if (event->until.time.utime > range) {
-                               DBG("until time(%lld) > max, so set max(%lld)", event->until.time.utime, range);
+                       if (range < event->until.time.utime) {
+                               DBG("range max < until time(%lld), so set max(%lld)", event->until.time.utime, range);
                                until->time.utime = range;
                        } else {
                                until->time.utime = event->until.time.utime;
@@ -608,7 +594,7 @@ static int __get_until_from_range(cal_event_s *event, calendar_time_s *until)
                        break;
 
                case CALENDAR_TIME_LOCALTIME:
-                       until->time.date.year = event->until.time.date.year > CAL_ENDLESS_LIMIT_YEAR ?
+                       until->time.date.year = CAL_ENDLESS_LIMIT_YEAR < event->until.time.date.year ?
                                CAL_ENDLESS_LIMIT_YEAR : event->until.time.date.year;
                        until->time.date.month = event->until.time.date.month;
                        until->time.date.mday = event->until.time.date.mday;
@@ -655,7 +641,7 @@ static bool __check_bysetpos_to_skip(int index, int *bysetpos, int bysetpos_len,
                return false;
 
        for (i = 0; i < bysetpos_len; i++) {
-               if (bysetpos[i] > 0) {
+               if (0 < bysetpos[i]) {
                        if (bysetpos[i] == (index + 1)) {
                                return false;
                        }
@@ -710,7 +696,7 @@ static bool __check_out_of_range(long long int current_utime, cal_event_s *event
        {
        case CALENDAR_RANGE_UNTIL:
        case CALENDAR_RANGE_NONE:
-               if (current_utime > until_utime) {
+               if (until_utime < current_utime) {
                        DBG("(%lld) (%lld)", current_utime, until_utime);
                        return true;
                }
@@ -718,13 +704,13 @@ static bool __check_out_of_range(long long int current_utime, cal_event_s *event
 
        case CALENDAR_RANGE_COUNT:
                (*count)++;
-               if (*count > event->count) {
+               if (event->count < *count) {
                        DBG("(%d) (%d)", *count, event->count);
                        return true;
                }
 
-               if (current_utime > CAL_ENDLESS_LIMIT_UTIME) { // event count is remained, it should not go over LIMIT
-                       DBG("stopped because dtstart(%lld) > LIMIT UTIME(%lld)", current_utime, (long long int)CAL_ENDLESS_LIMIT_UTIME);
+               if (CAL_ENDLESS_LIMIT_UTIME < current_utime) { // event count is remained, it should not go over LIMIT
+                       DBG("stopped because LIMIT UTIME(%lld) < dtstart(%lld)", (long long int)CAL_ENDLESS_LIMIT_UTIME, current_utime);
                        return true;
                }
                break;
@@ -924,7 +910,7 @@ static int _cal_db_instance_publish_yearly_weekno(UCalendar *ucal, cal_event_s *
                ucal_set(ucal, UCAL_DATE, 1);
                int wkst = ucal_getAttribute(ucal, UCAL_FIRST_DAY_OF_WEEK);
                int first_wday = ucal_get(ucal, UCAL_DAY_OF_WEEK, &ec);
-               extra_weekno = ((first_wday+7-wkst)%7) > 3 ? 1 : 0;
+               extra_weekno = 3 < ((first_wday+7-wkst)%7) ? 1 : 0;
 
                ucal_setMillis(ucal, ms2sec(start_point), &ec); // set start point
 
@@ -1045,7 +1031,7 @@ static int _cal_db_instance_publish_yearly_wday(UCalendar *ucal, cal_event_s *ev
                int i, j, k;
                for (i = 0; i < bymonth_len; i++) {
 
-                       if (strlen(t[0]) > 2) { // -3SU, +2SA
+                       if (2 < strlen(t[0])) { // -3SU, +2SA
                                for (j = 0; j < byday_len; j++) {
                                        if (0 == strlen(t[j])) continue;
                                        // get nth, wday
@@ -1057,7 +1043,7 @@ static int _cal_db_instance_publish_yearly_wday(UCalendar *ucal, cal_event_s *ev
                                        int wday_int = __convert_wday_to_int(wday);
 
                                        // set nth, wday
-                                       if (nth > 0) {
+                                       if (0 < nth) {
                                                ucal_set(ucal, UCAL_DAY_OF_WEEK, wday_int);
                                                ucal_set(ucal, UCAL_DAY_OF_WEEK_IN_MONTH, 1);
                                                ucal_set(ucal, UCAL_MONTH, false == has_bymonth ? 0 : (bymonth[i] - 1));
@@ -1251,7 +1237,7 @@ static int _cal_db_instance_publish_yearly_mday(UCalendar *ucal, cal_event_s *ev
                int i, j;
                for (j = 0; j < bymonth_len; j++) {
                        for (i = 0 ; i < bymonthday_len; i++) {
-                               if (bymonthday[i] > 0) {
+                               if (0 < bymonthday[i]) {
                                        ucal_set(ucal, UCAL_MONTH, bymonth[j] - 1);
                                        ucal_set(ucal, UCAL_DATE, bymonthday[i]);
                                        int get_mday = ucal_get(ucal, UCAL_DATE, &ec);
@@ -1300,10 +1286,10 @@ static int _cal_db_instance_publish_record_yearly(UCalendar *ucal, cal_event_s *
        RETV_IF(NULL == ucal, CALENDAR_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER);
 
-       if (event->byyearday && strlen(event->byyearday) > 0) {
+       if (event->byyearday && 0 < strlen(event->byyearday)) {
                _cal_db_instance_publish_yearly_yday(ucal, event, duration);
 
-       } else if (event->byweekno && strlen(event->byweekno) > 0) {
+       } else if (event->byweekno && 0 < strlen(event->byweekno)) {
                _cal_db_instance_publish_yearly_weekno(ucal, event, duration);
 
        } else {
@@ -1381,7 +1367,7 @@ static int _cal_db_instance_publish_monthly_wday(UCalendar *ucal, cal_event_s *e
                ucal_setMillis(ucal, ucal_getMillis(ucal, &ec), &ec); // set start point
 
                int i, j, k;
-               if (strlen(t[0]) > 2) { // -3SU, +2SA
+               if (2 < strlen(t[0])) { // -3SU, +2SA
                        for (i = 0; i < byday_len; i++) {
                                if (0 == strlen(t[i])) continue;
                                // get nth, wday
@@ -1393,8 +1379,8 @@ static int _cal_db_instance_publish_monthly_wday(UCalendar *ucal, cal_event_s *e
                                int wday_int = __convert_wday_to_int(wday);
 
                                // set nth, wday
-                               if (nth > 0) {
-                                       if (nth > 4) {
+                               if (0 < nth) {
+                                       if (4 < nth) {
                                                ucal_set(ucal, UCAL_DAY_OF_WEEK, wday_int);
                                                ucal_set(ucal, UCAL_DAY_OF_WEEK_IN_MONTH, -1);
 
@@ -1575,7 +1561,7 @@ static int _cal_db_instance_publish_monthly_mday(UCalendar *ucal, cal_event_s *e
 
                int i;
                for (i = 0 ; i < bymonthday_len; i++) {
-                       if (bymonthday[i] > 0) {
+                       if (0 < bymonthday[i]) {
                                ucal_set(ucal, UCAL_MONTH, ucal_get(ucal, UCAL_MONTH, &ec));
                                ucal_set(ucal, UCAL_DATE, bymonthday[i]);
                                int get_mday = ucal_get(ucal, UCAL_DATE, &ec);
@@ -1621,12 +1607,11 @@ static int _cal_db_instance_publish_record_monthly(UCalendar *ucal, cal_event_s
        RETV_IF(NULL == ucal, CALENDAR_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER);
 
-       if (event->byday && strlen(event->byday) > 0) {
+       if (event->byday && 0 < strlen(event->byday))
                _cal_db_instance_publish_monthly_wday(ucal, event, duration);
-
-       } else {
+       else
                _cal_db_instance_publish_monthly_mday(ucal, event, duration);
-       }
+
        return CALENDAR_ERROR_NONE;
 }
 
@@ -1814,7 +1799,7 @@ static int _cal_db_instance_publish_record_details(UCalendar *ucal, cal_event_s
        _cal_db_instance_get_duration(ucal, &event->start, &event->end, &duration);
        WARN_IF(duration < 0, "Invalid duration (%lld)", duration);
 
-       if (event->original_event_id > 0)
+       if (0 < event->original_event_id)
        {
                DBG("this is exception event so publish only one instance");
                exception_freq = event->freq;
@@ -1852,7 +1837,7 @@ static int _cal_db_instance_publish_record_details(UCalendar *ucal, cal_event_s
                break;
        }
 
-       if (event->original_event_id > 0)
+       if (0 < event->original_event_id)
        {
                DBG("return freq for exception event");
                event->freq = exception_freq;
index 3f771be..28a2820 100644 (file)
@@ -134,10 +134,10 @@ static int _cal_db_alarm_get_all_records(int offset, int limit, calendar_list_h*
        ret = calendar_list_create(out_list);
        RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
 
-       if (offset > 0) {
+       if (0 < offset) {
                snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
        }
-       if (limit > 0) {
+       if (0 < limit) {
                snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
        }
        snprintf(query, sizeof(query), "SELECT *, rowid FROM %s %s %s",
@@ -388,7 +388,7 @@ static int _cal_db_alarm_get_records_with_query(calendar_query_h query, int offs
                        sqlite3_finalize(stmt);
                        return ret;
                }
-               if (que->projection_count > 0) {
+               if (0 < que->projection_count) {
                        cal_record_set_projection(record,
                                        que->projection, que->projection_count, que->property_count);
 
index a427082..3a4b76f 100644 (file)
@@ -109,10 +109,10 @@ static int _cal_db_attendee_get_all_records(int offset, int limit, calendar_list
        ret = calendar_list_create(out_list);
        RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
 
-       if (limit > 0)  {
+       if (0 < limit)  {
                snprintf(limitquery, sizeof(limitquery), "LIMIT %d ", limit);
        }
-       if (offset > 0) {
+       if (0 < offset) {
                snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d ", offset);
        }
        snprintf(query, sizeof(query), "SELECT *, rowid FROM %s %s %s ",
@@ -353,7 +353,7 @@ static int _cal_db_attendee_get_records_with_query(calendar_query_h query, int o
                        sqlite3_finalize(stmt);
                        return ret;
                }
-               if (que->projection_count > 0) {
+               if (0 < que->projection_count) {
                        cal_record_set_projection(record,
                                        que->projection, que->projection_count, que->property_count);
 
index 047734b..270b681 100644 (file)
@@ -370,7 +370,7 @@ static int _cal_db_calendar_delete_record(int id)
 
        count += count2;
 
-       if(count > 1000)
+       if(1000 < count)
        {
                snprintf(query, sizeof(query), "UPDATE %s SET deleted = 1 WHERE id = %d",
                                CAL_TABLE_CALENDAR, id);
@@ -543,9 +543,9 @@ static int _cal_db_calendar_get_all_records(int offset, int limit, calendar_list
        ret = calendar_list_create(out_list);
        RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
 
-       if (offset > 0)
+       if (0 < offset)
                snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
-       if (limit > 0)
+       if (0 < limit)
                snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
 
        char *query_str = NULL;
@@ -649,11 +649,11 @@ static int _cal_db_calendar_get_records_with_query(calendar_query_h query, int o
 
        // limit, offset
        char buf[32] = {0};
-       if (limit > 0) {
+       if (0 < limit) {
                snprintf(buf, sizeof(buf), "LIMIT %d", limit);
                cal_db_append_string(&query_str, buf);
 
-               if (offset > 0) {
+               if (0 < offset) {
                        snprintf(buf, sizeof(buf), "OFFSET %d", offset);
                        cal_db_append_string(&query_str, buf);
                }
@@ -708,7 +708,7 @@ static int _cal_db_calendar_get_records_with_query(calendar_query_h query, int o
                        return ret;
                }
 
-               if (que->projection_count > 0) {
+               if (0 < que->projection_count) {
                        cal_record_set_projection(record,
                                        que->projection, que->projection_count, que->property_count);
 
index d724c5d..a341956 100644 (file)
@@ -635,7 +635,7 @@ static int __update_record(calendar_record_h record, int is_dirty_in_time)
                event->start.type == CALENDAR_TIME_UTIME ? event->start.time.utime : 0,
                event->end.type,
                event->end.type == CALENDAR_TIME_UTIME ? event->end.time.utime : 0,
-               event->freq > 0 ? 1 : 0,
+               0 < event->freq ? 1 : 0,
                (event->attendee_list && 0 < event->attendee_list->count)? 1: 0,
                has_alarm,
                event->system_type,
@@ -964,7 +964,7 @@ int cal_db_event_delete_record(int id)
                return CALENDAR_ERROR_PERMISSION_DENIED;
        }
 
-       if (original_event_id > 0)
+       if (0 < original_event_id)
        {
                // start:add record to exdate if this record is exception mod.
                _cal_db_event_add_exdate(original_event_id, recurrence_id);
@@ -1058,11 +1058,11 @@ static int _cal_db_event_get_all_records(int offset, int limit, calendar_list_h*
        ret = calendar_list_create(out_list);
        RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
 
-       if (offset > 0)
+       if (0 < offset)
        {
                snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
        }
-       if (limit > 0)
+       if (0 < limit)
        {
                snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
        }
@@ -1232,12 +1232,12 @@ static int _cal_db_event_get_records_with_query(calendar_query_h query, int offs
 
        // limit, offset
        char buf[32] = {0};
-       if (limit > 0)
+       if (0 < limit)
        {
                snprintf(buf, sizeof(buf), "LIMIT %d", limit);
                cal_db_append_string(&query_str, buf);
 
-               if (offset > 0)
+               if (0 < offset)
                {
                        snprintf(buf, sizeof(buf), "OFFSET %d", offset);
                        cal_db_append_string(&query_str, buf);
@@ -1303,17 +1303,10 @@ static int _cal_db_event_get_records_with_query(calendar_query_h query, int offs
                        CAL_FREE(query_str);
                        return ret;
                }
-               if (que->projection_count > 0)
-               {
-                       cal_record_set_projection(record,
-                                       que->projection, que->projection_count, que->property_count);
-
-                       _cal_db_event_get_projection_stmt(stmt,
-                                       que->projection, que->projection_count,
-                                       record);
-               }
-               else
-               {
+               if (0 < que->projection_count) {
+                       cal_record_set_projection(record, que->projection, que->projection_count, que->property_count);
+                       _cal_db_event_get_projection_stmt(stmt, que->projection, que->projection_count, record);
+               } else {
                        cal_event_s *event = NULL;
                        _cal_db_event_get_stmt(stmt,true,record, &exception, &extended);
                        event = (cal_event_s*)(record);
@@ -1691,7 +1684,7 @@ static int _cal_db_event_replace_record(calendar_record_h record, int id)
                event->start.type == CALENDAR_TIME_UTIME ? event->start.time.utime : 0,
                event->end.type,
                event->end.type == CALENDAR_TIME_UTIME ? event->end.time.utime : 0,
-               event->freq > 0 ? 1 : 0,
+               0 < event->freq ? 1 : 0,
                (event->attendee_list && 0 < event->attendee_list->count) ? 1 : 0,
                has_alarm,
                event->system_type,
@@ -2692,7 +2685,7 @@ static int _cal_db_event_exception_update(cal_list_s *exception_list_s, int orig
                        int exception_id = 0;
                        ret = calendar_record_get_int(exception,_calendar_event.id, &exception_id);
                        DBG("exception(%d)", exception_id);
-                       if (exception_id > 0 && exception_id != original_id) { // update
+                       if (0 < exception_id && exception_id != original_id) { // update
                                bool bchanged = false;
                                cal_record_s *_record = NULL;
                                const cal_property_info_s* property_info = NULL;
@@ -2816,12 +2809,12 @@ static int _cal_db_event_exdate_insert_normal(int event_id, const char* original
        int len1 = 0, len2 = 0, i = 0, j = 0;
 
        int input_ver = cal_db_util_get_next_ver();
-       if (exdate != NULL && strlen(exdate) > 0)
+       if (exdate != NULL && 0 < strlen(exdate))
        {
                patterns1 = g_strsplit_set(exdate, " ,", -1);
                len1 = g_strv_length(patterns1);
        }
-       if (original_exdate != NULL && strlen(original_exdate) > 0)
+       if (original_exdate != NULL && 0 < strlen(original_exdate))
        {
                patterns2 = g_strsplit_set(original_exdate, " ,", -1);
                len2 = g_strv_length(patterns2);
@@ -2848,7 +2841,7 @@ static int _cal_db_event_exdate_insert_normal(int event_id, const char* original
                        char query[CAL_DB_SQL_MAX_LEN] = {0};
                        long long int start_utime = 0;
                        char datetime[16] = {0};
-                       if (strlen(patterns1[i]) > strlen("YYYYMMDD"))
+                       if (strlen("YYYYMMDD") < strlen(patterns1[i]))
                        {
                                //DBG("NORMAL instance");
                                int y, mon, d, h, min, s;
index 0679309..caeb0e2 100644 (file)
@@ -267,11 +267,11 @@ static int _cal_db_extended_get_all_records(int offset, int limit, calendar_list
        ret = calendar_list_create(out_list);
        RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
 
-       if (offset > 0)
+       if (0 < offset)
        {
                snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
        }
-       if (limit > 0)
+       if (0 < limit)
        {
                snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
        }
@@ -444,7 +444,7 @@ static int _cal_db_extended_get_records_with_query(calendar_query_h query, int o
                        sqlite3_finalize(stmt);
                        return ret;
                }
-               if (que->projection_count > 0)
+               if (0 < que->projection_count)
                {
                        cal_record_set_projection(record,
                                        que->projection, que->projection_count, que->property_count);
index 104a21f..5360af7 100644 (file)
@@ -108,9 +108,9 @@ static int _cal_db_instance_allday_get_all_records(int offset, int limit, calend
        ret = calendar_list_create(out_list);
        RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
 
-       if (offset > 0)
+       if (0 < offset)
                snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
-       if (limit > 0)
+       if (0 < limit)
                snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
 
        char *query_str = NULL;
@@ -242,12 +242,12 @@ static int _cal_db_instance_allday_get_records_with_query(calendar_query_h query
 
        // limit, offset
        char buf[32] = {0};
-       if (limit > 0)
+       if (0 < limit)
        {
                snprintf(buf, sizeof(buf), "LIMIT %d", limit);
                cal_db_append_string(&query_str, buf);
 
-               if (offset > 0)
+               if (0 < offset)
                {
                        snprintf(buf, sizeof(buf), "OFFSET %d", offset);
                        cal_db_append_string(&query_str, buf);
@@ -313,7 +313,7 @@ static int _cal_db_instance_allday_get_records_with_query(calendar_query_h query
                        CAL_FREE(query_str);
                        return ret;
                }
-               if (que->projection_count > 0)
+               if (0 < que->projection_count)
                {
                        cal_record_set_projection(record,
                                        que->projection, que->projection_count, que->property_count);
@@ -508,7 +508,7 @@ static void _cal_db_instance_allday_get_stmt(sqlite3_stmt *stmt,calendar_record_
        instance->sensitivity = sqlite3_column_int(stmt, count++);
 
        instance->has_rrule = sqlite3_column_int(stmt, count++);
-       if (instance->has_rrule > 0)
+       if (0 < instance->has_rrule)
        {
                instance->has_rrule = 1;
        }
@@ -590,7 +590,7 @@ static void _cal_db_instance_allday_get_property_stmt(sqlite3_stmt *stmt,
                break;
        case CAL_PROPERTY_INSTANCE_ALLDAY_HAS_RRULE:
                instance->has_rrule = sqlite3_column_int(stmt, *stmt_count);
-               if (instance->has_rrule > 0)
+               if (0 < instance->has_rrule)
                {
                        instance->has_rrule = 1;
                }
index a82a932..935e180 100755 (executable)
@@ -73,14 +73,10 @@ static int _cal_db_instance_allday_extended_get_all_records(int offset, int limi
        ret = calendar_list_create(out_list);
        RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
 
-       if (offset > 0)
-       {
+       if (0 < offset)
                snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
-       }
-       if (limit > 0)
-       {
+       if (0 < limit)
                snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
-       }
 
        char *query_str = NULL;
        cal_db_append_string(&query_str, "SELECT * FROM");
@@ -197,12 +193,12 @@ static int _cal_db_instance_allday_extended_get_records_with_query(calendar_quer
 
        // limit, offset
        char buf[32] = {0};
-       if (limit > 0)
+       if (0 < limit)
        {
                snprintf(buf, sizeof(buf), "LIMIT %d", limit);
                cal_db_append_string(&query_str, buf);
 
-               if (offset > 0)
+               if (0 < offset)
                {
                        snprintf(buf, sizeof(buf), "OFFSET %d", offset);
                        cal_db_append_string(&query_str, buf);
@@ -268,17 +264,10 @@ static int _cal_db_instance_allday_extended_get_records_with_query(calendar_quer
                        CAL_FREE(query_str);
                        return ret;
                }
-               if (que->projection_count > 0)
-               {
-                       cal_record_set_projection(record,
-                                       que->projection, que->projection_count, que->property_count);
-
-                       _cal_db_instance_allday_extended_get_projection_stmt(stmt,
-                                       que->projection, que->projection_count,
-                                       record);
-               }
-               else
-               {
+               if (0 < que->projection_count) {
+                       cal_record_set_projection(record, que->projection, que->projection_count, que->property_count);
+                       _cal_db_instance_allday_extended_get_projection_stmt(stmt, que->projection, que->projection_count, record);
+               } else {
                        _cal_db_instance_allday_extended_get_stmt(stmt,record);
                }
 
@@ -447,7 +436,7 @@ static void _cal_db_instance_allday_extended_get_stmt(sqlite3_stmt *stmt,calenda
        instance->sensitivity = sqlite3_column_int(stmt, count++);
 
        instance->has_rrule = sqlite3_column_int(stmt, count++);
-       if (instance->has_rrule > 0)
+       if (0 < instance->has_rrule)
        {
                instance->has_rrule = 1;
        }
@@ -546,7 +535,7 @@ static void _cal_db_instance_allday_extended_get_property_stmt(sqlite3_stmt *stm
                break;
        case CAL_PROPERTY_INSTANCE_ALLDAY_EXTENDED_HAS_RRULE:
                instance->has_rrule = sqlite3_column_int(stmt, *stmt_count);
-               if (instance->has_rrule > 0)
+               if (0 < instance->has_rrule)
                {
                        instance->has_rrule = 1;
                }
index 710c007..08074b5 100644 (file)
@@ -107,9 +107,9 @@ static int _cal_db_instance_normal_get_all_records(int offset, int limit, calend
        ret = calendar_list_create(out_list);
        RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
 
-       if (offset > 0)
+       if (0 < offset)
                snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
-       if (limit > 0)
+       if (0 < limit)
                snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
 
        char *query_str = NULL;
@@ -241,12 +241,12 @@ static int _cal_db_instance_normal_get_records_with_query(calendar_query_h query
 
        // limit, offset
        char buf[32] = {0};
-       if (limit > 0)
+       if (0 < limit)
        {
                snprintf(buf, sizeof(buf), "LIMIT %d", limit);
                cal_db_append_string(&query_str, buf);
 
-               if (offset > 0)
+               if (0 < offset)
                {
                        snprintf(buf, sizeof(buf), "OFFSET %d", offset);
                        cal_db_append_string(&query_str, buf);
@@ -311,7 +311,7 @@ static int _cal_db_instance_normal_get_records_with_query(calendar_query_h query
                        sqlite3_finalize(stmt);
                        return ret;
                }
-               if (que->projection_count > 0)
+               if (0 < que->projection_count)
                {
                        cal_record_set_projection(record,
                                        que->projection, que->projection_count, que->property_count);
@@ -490,7 +490,7 @@ static void _cal_db_instance_normal_get_stmt(sqlite3_stmt *stmt, calendar_record
        instance->sensitivity = sqlite3_column_int(stmt, count++);
 
        instance->has_rrule = sqlite3_column_int(stmt, count++);
-       if (instance->has_rrule > 0)
+       if (0 < instance->has_rrule)
        {
                instance->has_rrule = 1;
        }
@@ -558,7 +558,7 @@ static void _cal_db_instance_normal_get_property_stmt(sqlite3_stmt *stmt,
                break;
        case CAL_PROPERTY_INSTANCE_NORMAL_HAS_RRULE:
                instance->has_rrule = sqlite3_column_int(stmt, *stmt_count);
-               if (instance->has_rrule > 0)
+               if (0 < instance->has_rrule)
                {
                        instance->has_rrule = 1;
                }
index 93afe0f..8170be3 100755 (executable)
@@ -72,9 +72,9 @@ static int _cal_db_instance_normal_extended_get_all_records(int offset, int limi
        ret = calendar_list_create(out_list);
        RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
 
-       if (offset > 0)
+       if (0 < offset)
                snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
-       if (limit > 0)
+       if (0 < limit)
                snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
 
        char *query_str = NULL;
@@ -192,12 +192,12 @@ static int _cal_db_instance_normal_extended_get_records_with_query(calendar_quer
 
        // limit, offset
        char buf[32] = {0};
-       if (limit > 0)
+       if (0 < limit)
        {
                snprintf(buf, sizeof(buf), "LIMIT %d", limit);
                cal_db_append_string(&query_str, buf);
 
-               if (offset > 0)
+               if (0 < offset)
                {
                        snprintf(buf, sizeof(buf), "OFFSET %d", offset);
                        cal_db_append_string(&query_str, buf);
@@ -263,7 +263,7 @@ static int _cal_db_instance_normal_extended_get_records_with_query(calendar_quer
                        return ret;
                }
 
-               if (que->projection_count > 0)
+               if (0 < que->projection_count)
                {
                        cal_record_set_projection(record,
                                        que->projection, que->projection_count, que->property_count);
@@ -427,7 +427,7 @@ static void _cal_db_instance_normal_extended_get_stmt(sqlite3_stmt *stmt,calenda
        instance->sensitivity = sqlite3_column_int(stmt, count++);
 
        instance->has_rrule = sqlite3_column_int(stmt, count++);
-       if (instance->has_rrule > 0)
+       if (0 < instance->has_rrule)
        {
                instance->has_rrule = 1;
        }
@@ -513,7 +513,7 @@ static void _cal_db_instance_normal_extended_get_property_stmt(sqlite3_stmt *stm
                break;
        case CAL_PROPERTY_INSTANCE_NORMAL_EXTENDED_HAS_RRULE:
                instance->has_rrule = sqlite3_column_int(stmt, *stmt_count);
-               if (instance->has_rrule > 0)
+               if (0 < instance->has_rrule)
                {
                        instance->has_rrule = 1;
                }
index 9f8eb8d..26ac738 100644 (file)
@@ -90,7 +90,7 @@ static int _cal_db_search_get_records_with_query(calendar_query_h query, int off
        }
 
        // make projection
-       if (que->projection_count > 0)
+       if (0 < que->projection_count)
        {
                ret = cal_db_query_create_projection(query, &projection);
        }
@@ -137,12 +137,12 @@ static int _cal_db_search_get_records_with_query(calendar_query_h query, int off
 
        // limit, offset
        char buf[32] = {0};
-       if (limit > 0)
+       if (0 < limit)
        {
                snprintf(buf, sizeof(buf), "LIMIT %d", limit);
                cal_db_append_string(&query_str, buf);
 
-               if (offset > 0)
+               if (0 < offset)
                {
                        snprintf(buf, sizeof(buf), "OFFSET %d", offset);
                        cal_db_append_string(&query_str, buf);
@@ -208,7 +208,7 @@ static int _cal_db_search_get_records_with_query(calendar_query_h query, int off
                        CAL_FREE(query_str);
                        return ret;
                }
-               if (que->projection_count > 0)
+               if (0 < que->projection_count)
                {
                        _cal_db_search_get_projection_stmt(stmt,que->projection,que->projection_count,
                                        record);
@@ -474,7 +474,7 @@ static int _cal_db_search_make_projection(calendar_query_h query, char **project
        if (field_name)
                len += snprintf(out_projection+len, sizeof(out_projection)-len, "%s", field_name);
 
-       if (len >= sizeof(out_projection))
+       if (sizeof(out_projection) <= len)
        {
                ERR("buf len max");
                return CALENDAR_ERROR_SYSTEM;
@@ -493,7 +493,7 @@ static int _cal_db_search_make_projection(calendar_query_h query, char **project
                if (field_name)
                {
                        len += snprintf(out_projection+len, sizeof(out_projection)-len, ", %s", field_name);
-                       if (len >= sizeof(out_projection))
+                       if (sizeof(out_projection) <= len)
                        {
                                ERR("buf len max");
                                return CALENDAR_ERROR_SYSTEM;
index b9c6755..6e43904 100644 (file)
@@ -133,7 +133,7 @@ static int _cal_db_timezone_insert_record(calendar_record_h record, int* id)
                int timezone_id = sqlite3_column_int(stmt, index++);
                sqlite3_finalize(stmt);
 
-               if (count > 0)
+               if (0 < count)
                {
                        DBG("Already exist which tzid name[%s] id(%d)", timezone->standard_name, timezone_id);
                        *id = timezone_id;
@@ -431,11 +431,11 @@ static int _cal_db_timezone_get_all_records(int offset, int limit, calendar_list
        ret = calendar_list_create(out_list);
        RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
 
-       if (offset > 0)
+       if (0 < offset)
        {
                snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
        }
-       if (limit > 0)
+       if (0 < limit)
        {
                snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
        }
@@ -623,7 +623,7 @@ static int _cal_db_timezone_get_records_with_query(calendar_query_h query, int o
                        sqlite3_finalize(stmt);
                        return ret;
                }
-               if (que->projection_count > 0)
+               if (0 < que->projection_count)
                {
                        cal_record_set_projection(record,
                                        que->projection, que->projection_count, que->property_count);
index b4550f2..aaf73c6 100644 (file)
@@ -174,7 +174,7 @@ static int _cal_db_todo_insert_record(calendar_record_h record, int* id)
                todo->completed_time, todo->progress,
                todo->start.type, todo->start.type == CALENDAR_TIME_UTIME ? todo->start.time.utime : 0,
                todo->due.type, todo->due.type == CALENDAR_TIME_UTIME ? todo->due.time.utime : 0,
-               todo->freq > 0 ? 1 : 0,
+               0 < todo->freq ? 1 : 0,
                has_alarm,
                todo->system_type,
                todo->updated,
@@ -968,11 +968,11 @@ static int _cal_db_todo_get_all_records(int offset, int limit, calendar_list_h*
        ret = calendar_list_create(out_list);
        RETVM_IF(CALENDAR_ERROR_NONE != ret, ret, "calendar_list_create() Fail(%d)", ret);
 
-       if (offset > 0)
+       if (0 < offset)
        {
                snprintf(offsetquery, sizeof(offsetquery), "OFFSET %d", offset);
        }
-       if (limit > 0)
+       if (0 < limit)
        {
                snprintf(limitquery, sizeof(limitquery), "LIMIT %d", limit);
        }
@@ -1130,12 +1130,12 @@ static int _cal_db_todo_get_records_with_query(calendar_query_h query, int offse
 
        // limit, offset
        char buf[32] = {0};
-       if (limit > 0)
+       if (0 < limit)
        {
                snprintf(buf, sizeof(buf), "LIMIT %d", limit);
                cal_db_append_string(&query_str, buf);
 
-               if (offset > 0)
+               if (0 < offset)
                {
                        snprintf(buf, sizeof(buf), "OFFSET %d", offset);
                        cal_db_append_string(&query_str, buf);
@@ -1203,7 +1203,7 @@ static int _cal_db_todo_get_records_with_query(calendar_query_h query, int offse
                        CAL_FREE(query_str);
                        return ret;
                }
-               if (que->projection_count > 0)
+               if (0 < que->projection_count)
                {
                        cal_record_set_projection(record,
                                        que->projection, que->projection_count, que->property_count);
index a61f9da..6b006e4 100644 (file)
@@ -38,7 +38,7 @@ void cal_db_rrule_set_default(calendar_record_h record)
        case CALENDAR_RECURRENCE_DAILY:
                break;
        case CALENDAR_RECURRENCE_WEEKLY:
-               if (event->byday && strlen(event->byday) > 0)
+               if (event->byday && 0 < strlen(event->byday))
                {
                        break;
                }
@@ -49,10 +49,10 @@ void cal_db_rrule_set_default(calendar_record_h record)
                break;
 
        case CALENDAR_RECURRENCE_MONTHLY:
-               if (event->bymonthday && strlen(event->bymonthday) > 0) {
+               if (event->bymonthday && 0 < strlen(event->bymonthday)) {
                        break;
                }
-               else if (event->byday && strlen(event->byday) > 0) {
+               else if (event->byday && 0 < strlen(event->byday)) {
                        break;
                }
 
@@ -62,13 +62,13 @@ void cal_db_rrule_set_default(calendar_record_h record)
                break;
 
        case CALENDAR_RECURRENCE_YEARLY:
-               if (event->bymonth && strlen(event->bymonth) > 0) {
+               if (event->bymonth && 0 < strlen(event->bymonth)) {
                        break;
                }
-               else if (event->byyearday && strlen(event->byyearday) > 0) {
+               else if (event->byyearday && 0 < strlen(event->byyearday)) {
                        break;
                }
-               else if (event->byweekno && strlen(event->byweekno) > 0) {
+               else if (event->byweekno && 0 < strlen(event->byweekno)) {
                        break;
                }
 
@@ -456,7 +456,7 @@ static int _cal_db_rrule_has_record(int id, int *has_record)
                return ret;
        }
 
-       *has_record = count > 0 ? 1 : 0;
+       *has_record = 0 < count ? 1 : 0;
        return CALENDAR_ERROR_NONE;
 }
 
index b124946..edc1181 100644 (file)
 #include "cal_db.h"
 #include "cal_db_util.h"
 
-void cal_db_timezone_search_with_tzid(const char *zone_name, char *tzid, int *timezone_id)
+void cal_db_timezone_search_with_tzid(char *tzid, int *timezone_id)
 {
-       RET_IF(NULL == zone_name);
        RET_IF(NULL == tzid);
        RET_IF('\0' == *tzid);
        RET_IF(NULL == timezone_id);
 
        char query[CAL_DB_SQL_MAX_LEN] = {0};
        snprintf(query, sizeof(query), "SELECT id FROM %s WHERE standard_name='%s'", CAL_TABLE_TIMEZONE, tzid);
-       cal_db_util_query_get_first_int_result(zone_name, query, NULL, timezone_id);
+       cal_db_util_query_get_first_int_result(query, NULL, timezone_id);
 }
index 4b9a4c8..cc5521c 100644 (file)
@@ -664,7 +664,7 @@ static gint _cal_server_alarm_sort_cb(gconstpointer a, gconstpointer b)
        struct _alarm_data_s *p2 = (struct _alarm_data_s *)b;
        DBG("%lld) > (%lld)",p1->alert_utime, p2->alert_utime);
 
-       return p1->alert_utime > p2->alert_utime ? 1 : -1;
+       return p1->alert_utime < p2->alert_utime ? -1 : 1;
 }
 
 static GFunc _cal_server_alarm_print_cb(gpointer data, gpointer user_data)
index 8519b0d..d72e4b3 100644 (file)
@@ -125,7 +125,7 @@ static int _cal_server_contacts_set_new_event(int id, char *label, int date, cha
                return ret;
        }
 
-       if (account_id > 0) {
+       if (0 < account_id) {
                snprintf(buf, sizeof(buf), "%d", account_id);
                ret = calendar_record_set_str(event, _calendar_event.sync_data4, buf);
                if (CALENDAR_ERROR_NONE != ret) {
@@ -172,7 +172,7 @@ static int cal_server_contacts_insert_event(int id)
                contacts_record_destroy(contact, true);
                return CALENDAR_ERROR_SYSTEM;
        }
-       if (address_book_id > 0) { // default phone addressbook is 0
+       if (0 < address_book_id) { // default phone addressbook is 0
                DBG("address_book_id(%d)", address_book_id);
                contacts_record_h address_book = NULL;
                ret = contacts_db_get_record(_contacts_address_book._uri, address_book_id, &address_book);
@@ -431,7 +431,7 @@ void cal_server_contacts_delete(int account_id)
        }
        DBG("event count(%d)\n", count);
 
-       if (count > 0) {
+       if (0 < count) {
                record_id_array = (int *)calloc(count, sizeof(int));
                if (NULL == record_id_array) {
                        ERR("calloc() Fail");