From af4f11ca4eaf37fbe5969e14d7cd8cecb2a32ab8 Mon Sep 17 00:00:00 2001 From: Sameer Prakash Pradhan Date: Thu, 12 Apr 2018 14:34:41 +0530 Subject: [PATCH] [UTC][calendar-service2][svace fix] Signed-off-by: Sameer Prakash Pradhan Change-Id: Ie543c060b899a031a1c81c8208fdd87d7122299d --- .../calendar-service2/db/utc-calendar-db-book.c | 2 + .../calendar-service2/db/utc-calendar-db-event.c | 11 +- ...-calendar-db-instance-localtime-book-extended.c | 3 +- .../db/utc-calendar-db-instance-localtime-book.c | 3 +- .../helper/utc-calendar-helper-event.c | 4 +- src/utc/calendar-service2/utc-calendar-list.c | 125 +++++++++++---------- .../calendar-service2/utc-calendar-recurrence.c | 24 +++- src/utc/calendar-service2/utc-calendar-reminder.c | 16 +++ src/utc/calendar-service2/utc-calendar-util.c | 68 +++++++++-- src/utc/calendar-service2/utc-calendar-vcalendar.c | 1 + 10 files changed, 177 insertions(+), 80 deletions(-) diff --git a/src/utc/calendar-service2/db/utc-calendar-db-book.c b/src/utc/calendar-service2/db/utc-calendar-db-book.c index 1cd3d62..8678be7 100755 --- a/src/utc/calendar-service2/db/utc-calendar-db-book.c +++ b/src/utc/calendar-service2/db/utc-calendar-db-book.c @@ -1516,6 +1516,8 @@ UTC_HIDDEN int utc_calendar_db_clean_after_sync_p_book(void) // create book calendar_record_h book = NULL; ret = calendar_record_create(_calendar_book._uri, &book); + assert_eq(ret, CALENDAR_ERROR_NONE); + int book_id = 0; calendar_db_insert_record(book, &book_id); calendar_record_destroy(book, true); diff --git a/src/utc/calendar-service2/db/utc-calendar-db-event.c b/src/utc/calendar-service2/db/utc-calendar-db-event.c index cc3f197..0fc757b 100755 --- a/src/utc/calendar-service2/db/utc-calendar-db-event.c +++ b/src/utc/calendar-service2/db/utc-calendar-db-event.c @@ -1696,7 +1696,9 @@ static int _add_record(time_t tm, char *summary, int alarm_sec, int *out_id) calendar_time_s et = {0}; calendar_time_s at = {0}; - calendar_record_create(_calendar_event._uri, &event); + int ret; + ret = calendar_record_create(_calendar_event._uri, &event); + assert_eq(ret, CALENDAR_ERROR_NONE); st.type = CALENDAR_TIME_UTIME; st.time.utime = tm; calendar_record_set_caltime(event, _calendar_event.start_time, st); @@ -1706,7 +1708,12 @@ static int _add_record(time_t tm, char *summary, int alarm_sec, int *out_id) calendar_record_set_str(event, _calendar_event.summary, summary); /* alarm */ - calendar_record_create(_calendar_alarm._uri, &alarm); + ret = calendar_record_create(_calendar_alarm._uri, &alarm); + if (CALENDAR_ERROR_NONE != ret) { + calendar_record_destroy(event, true); + } + assert_eq(ret, CALENDAR_ERROR_NONE); + calendar_record_set_int(alarm, _calendar_alarm.tick_unit, CALENDAR_ALARM_TIME_UNIT_SPECIFIC); at.type = CALENDAR_TIME_UTIME; at.time.utime = tm + alarm_sec; diff --git a/src/utc/calendar-service2/db/utc-calendar-db-instance-localtime-book-extended.c b/src/utc/calendar-service2/db/utc-calendar-db-instance-localtime-book-extended.c index 3b4f0f5..2f4e3d9 100755 --- a/src/utc/calendar-service2/db/utc-calendar-db-instance-localtime-book-extended.c +++ b/src/utc/calendar-service2/db/utc-calendar-db-instance-localtime-book-extended.c @@ -141,7 +141,8 @@ UTC_HIDDEN int utc_calendar_db_get_all_records_p_instance_localtime_book_extende assert_eq(ret, CALENDAR_ERROR_NONE); int get_count = 0; - calendar_db_get_count(_calendar_instance_localtime_calendar_book_extended._uri, &get_count); + ret = calendar_db_get_count(_calendar_instance_localtime_calendar_book_extended._uri, &get_count); + assert_eq(ret, CALENDAR_ERROR_NONE); // check ret = calendar_list_first(get_list); diff --git a/src/utc/calendar-service2/db/utc-calendar-db-instance-localtime-book.c b/src/utc/calendar-service2/db/utc-calendar-db-instance-localtime-book.c index 27a992a..969285c 100755 --- a/src/utc/calendar-service2/db/utc-calendar-db-instance-localtime-book.c +++ b/src/utc/calendar-service2/db/utc-calendar-db-instance-localtime-book.c @@ -141,7 +141,8 @@ UTC_HIDDEN int utc_calendar_db_get_all_records_p_instance_localtime_book(void) assert_eq(ret, CALENDAR_ERROR_NONE); int get_count = 0; - calendar_db_get_count(_calendar_instance_localtime_calendar_book._uri, &get_count); + ret = calendar_db_get_count(_calendar_instance_localtime_calendar_book._uri, &get_count); + assert_eq(ret, CALENDAR_ERROR_NONE); // check ret = calendar_list_first(get_list); diff --git a/src/utc/calendar-service2/helper/utc-calendar-helper-event.c b/src/utc/calendar-service2/helper/utc-calendar-helper-event.c index 9ba51ba..eb96a33 100755 --- a/src/utc/calendar-service2/helper/utc-calendar-helper-event.c +++ b/src/utc/calendar-service2/helper/utc-calendar-helper-event.c @@ -1119,11 +1119,11 @@ UTC_HIDDEN int utc_calendar_helper_event_check_mod_double(calendar_record_h reco double d = 0; ret = calendar_record_get_double(record, _calendar_event.latitude, &d); assert_eq(ret, CALENDAR_ERROR_NONE); - _check_double(&d, UTC_DOUBLE_MOD_LATITUDE); + ret = _check_double(&d, UTC_DOUBLE_MOD_LATITUDE); assert_eq(ret, CALENDAR_ERROR_NONE); ret = calendar_record_get_double(record, _calendar_event.longitude, &d); assert_eq(ret, CALENDAR_ERROR_NONE); - _check_double(&d, UTC_DOUBLE_MOD_LONGITUDE); + ret = _check_double(&d, UTC_DOUBLE_MOD_LONGITUDE); assert_eq(ret, CALENDAR_ERROR_NONE); return 0; } diff --git a/src/utc/calendar-service2/utc-calendar-list.c b/src/utc/calendar-service2/utc-calendar-list.c index 3a59b69..7a3363c 100755 --- a/src/utc/calendar-service2/utc-calendar-list.c +++ b/src/utc/calendar-service2/utc-calendar-list.c @@ -168,7 +168,8 @@ int utc_calendar_list_get_count_p(void) } calendar_record_h event = NULL; - calendar_record_create(_calendar_event._uri, &event); + ret = calendar_record_create(_calendar_event._uri, &event); + assert_eq(ret, CALENDAR_ERROR_NONE); calendar_list_h list = NULL; ret = calendar_list_create(&list); @@ -234,7 +235,7 @@ int utc_calendar_list_get_count_n(void) */ int utc_calendar_list_add_p(void) { - assert_eq(g_startup_err, CALENDAR_ERROR_NONE); + assert_eq(g_startup_err, CALENDAR_ERROR_NONE); int ret = 0; if (false == _is_feature_supported()) { @@ -245,13 +246,14 @@ int utc_calendar_list_add_p(void) calendar_record_h event = NULL; calendar_record_create(_calendar_event._uri, &event); + assert_eq(ret, CALENDAR_ERROR_NONE); calendar_list_h list = NULL; ret = calendar_list_create(&list); if (CALENDAR_ERROR_NONE != ret) { calendar_record_destroy(event, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); // list add ret = calendar_list_add(list, event); @@ -259,7 +261,7 @@ int utc_calendar_list_add_p(void) calendar_record_destroy(event, true); calendar_list_destroy(list, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); // get count int count = 0; @@ -267,7 +269,7 @@ int utc_calendar_list_add_p(void) if (CALENDAR_ERROR_NONE != ret) { calendar_list_destroy(list, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); calendar_list_destroy(list, true); if (1 != count) { @@ -283,7 +285,7 @@ int utc_calendar_list_add_p(void) */ int utc_calendar_list_add_n(void) { - assert_eq(g_startup_err, CALENDAR_ERROR_NONE); + assert_eq(g_startup_err, CALENDAR_ERROR_NONE); int ret = 0; if (false == _is_feature_supported()) { @@ -295,12 +297,12 @@ int utc_calendar_list_add_n(void) // case 1 calendar_record_h record = NULL; ret = calendar_list_add(NULL, record); - assert_eq(ret, CALENDAR_ERROR_INVALID_PARAMETER); + assert_eq(ret, CALENDAR_ERROR_INVALID_PARAMETER); // case 2 calendar_list_h list = NULL; ret = calendar_list_add(list, NULL); - assert_eq(ret, CALENDAR_ERROR_INVALID_PARAMETER); + assert_eq(ret, CALENDAR_ERROR_INVALID_PARAMETER); return 0; } @@ -311,7 +313,7 @@ int utc_calendar_list_add_n(void) */ int utc_calendar_list_remove_p(void) { - assert_eq(g_startup_err, CALENDAR_ERROR_NONE); + assert_eq(g_startup_err, CALENDAR_ERROR_NONE); int ret = 0; if (false == _is_feature_supported()) { @@ -321,27 +323,28 @@ int utc_calendar_list_remove_p(void) } calendar_record_h event = NULL; - calendar_record_create(_calendar_event._uri, &event); + ret = calendar_record_create(_calendar_event._uri, &event); + assert_eq(ret, CALENDAR_ERROR_NONE); calendar_list_h list = NULL; ret = calendar_list_create(&list); if (CALENDAR_ERROR_NONE != ret) { calendar_record_destroy(event, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); ret = calendar_list_add(list, event); if (CALENDAR_ERROR_NONE != ret) { calendar_record_destroy(event, true); calendar_list_destroy(list, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); ret = calendar_list_remove(list, event); if (CALENDAR_ERROR_NONE != ret) { calendar_list_destroy(list, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); // check int count = 0; @@ -349,7 +352,7 @@ int utc_calendar_list_remove_p(void) if (CALENDAR_ERROR_NONE != ret) { calendar_list_destroy(list, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); calendar_list_destroy(list, true); if (0 != count) { @@ -365,7 +368,7 @@ int utc_calendar_list_remove_p(void) */ int utc_calendar_list_remove_n(void) { - assert_eq(g_startup_err, CALENDAR_ERROR_NONE); + assert_eq(g_startup_err, CALENDAR_ERROR_NONE); int ret = 0; if (false == _is_feature_supported()) { @@ -377,12 +380,12 @@ int utc_calendar_list_remove_n(void) // case 1 calendar_record_h record = NULL; ret = calendar_list_remove(NULL, record); - assert_eq(ret, CALENDAR_ERROR_INVALID_PARAMETER); + assert_eq(ret, CALENDAR_ERROR_INVALID_PARAMETER); // case 2 calendar_list_h list = NULL; ret = calendar_list_remove(list, NULL); - assert_eq(ret, CALENDAR_ERROR_INVALID_PARAMETER); + assert_eq(ret, CALENDAR_ERROR_INVALID_PARAMETER); return 0; } @@ -393,7 +396,7 @@ int utc_calendar_list_remove_n(void) */ int utc_calendar_list_get_current_record_p_p(void) { - assert_eq(g_startup_err, CALENDAR_ERROR_NONE); + assert_eq(g_startup_err, CALENDAR_ERROR_NONE); int ret = 0; if (false == _is_feature_supported()) { @@ -404,40 +407,40 @@ int utc_calendar_list_get_current_record_p_p(void) calendar_record_h event = NULL; ret = calendar_record_create(_calendar_event._uri, &event); - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); ret = utc_calendar_helper_event_set_new(event); if (CALENDAR_ERROR_NONE != ret) { calendar_record_destroy(event, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); calendar_list_h list = NULL; ret = calendar_list_create(&list); if (CALENDAR_ERROR_NONE != ret) { calendar_record_destroy(event, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); ret = calendar_list_add(list, event); if (CALENDAR_ERROR_NONE != ret) { calendar_record_destroy(event, true); calendar_list_destroy(list, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); // get - ret = calendar_list_first(list); - assert_eq(ret, CALENDAR_ERROR_NONE); + ret = calendar_list_first(list); + assert_eq(ret, CALENDAR_ERROR_NONE); ret = calendar_list_get_current_record_p(list, &event); - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); ret = utc_calendar_helper_event_check_new(event); if (CALENDAR_ERROR_NONE != ret) { calendar_list_destroy(list, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); calendar_list_destroy(list, true); return 0; } @@ -449,7 +452,7 @@ int utc_calendar_list_get_current_record_p_p(void) */ int utc_calendar_list_get_current_record_p_n(void) { - assert_eq(g_startup_err, CALENDAR_ERROR_NONE); + assert_eq(g_startup_err, CALENDAR_ERROR_NONE); int ret = 0; if (false == _is_feature_supported()) { @@ -461,12 +464,12 @@ int utc_calendar_list_get_current_record_p_n(void) // case 1 calendar_record_h event = NULL; ret = calendar_list_get_current_record_p(NULL, &event); - assert_eq(ret, CALENDAR_ERROR_INVALID_PARAMETER); + assert_eq(ret, CALENDAR_ERROR_INVALID_PARAMETER); // case 2 calendar_list_h list = NULL; ret = calendar_list_get_current_record_p(list, NULL); - assert_eq(ret, CALENDAR_ERROR_INVALID_PARAMETER); + assert_eq(ret, CALENDAR_ERROR_INVALID_PARAMETER); return 0; } @@ -477,7 +480,7 @@ int utc_calendar_list_get_current_record_p_n(void) */ int utc_calendar_list_prev_p(void) { - assert_eq(g_startup_err, CALENDAR_ERROR_NONE); + assert_eq(g_startup_err, CALENDAR_ERROR_NONE); int ret = 0; if (false == _is_feature_supported()) { @@ -488,7 +491,7 @@ int utc_calendar_list_prev_p(void) calendar_list_h list = NULL; ret = calendar_list_create(&list); - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); calendar_record_h event = NULL; // add new @@ -496,68 +499,68 @@ int utc_calendar_list_prev_p(void) if (CALENDAR_ERROR_NONE != ret) { calendar_list_destroy(list, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); ret = utc_calendar_helper_event_set_new(event); if (CALENDAR_ERROR_NONE != ret) { calendar_list_destroy(list, true); calendar_record_destroy(event, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); ret = calendar_list_add(list, event); if (CALENDAR_ERROR_NONE != ret) { calendar_list_destroy(list, true); calendar_record_destroy(event, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); // add mod ret = calendar_record_create(_calendar_event._uri, &event); if (CALENDAR_ERROR_NONE != ret) { calendar_list_destroy(list, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); ret = utc_calendar_helper_event_set_mod(event); if (CALENDAR_ERROR_NONE != ret) { calendar_list_destroy(list, true); calendar_record_destroy(event, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); ret = calendar_list_add(list, event); if (CALENDAR_ERROR_NONE != ret) { calendar_list_destroy(list, true); calendar_record_destroy(event, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); // check: set last and prev - ret = calendar_list_last(list); + ret = calendar_list_last(list); if (CALENDAR_ERROR_NONE != ret) { calendar_list_destroy(list, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); // prev - ret = calendar_list_prev(list); + ret = calendar_list_prev(list); if (CALENDAR_ERROR_NONE != ret) { calendar_list_destroy(list, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); ret = calendar_list_get_current_record_p(list, &event); if (CALENDAR_ERROR_NONE != ret) { calendar_list_destroy(list, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); ret = utc_calendar_helper_event_check_new(event); if (CALENDAR_ERROR_NONE != ret) { calendar_list_destroy(list, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); calendar_list_destroy(list, true); return 0; } @@ -569,7 +572,7 @@ int utc_calendar_list_prev_p(void) */ int utc_calendar_list_prev_n(void) { - assert_eq(g_startup_err, CALENDAR_ERROR_NONE); + assert_eq(g_startup_err, CALENDAR_ERROR_NONE); int ret = 0; if (false == _is_feature_supported()) { @@ -578,8 +581,8 @@ int utc_calendar_list_prev_n(void) return 0; } - ret = calendar_list_prev(NULL); - assert_eq(ret, CALENDAR_ERROR_INVALID_PARAMETER); + ret = calendar_list_prev(NULL); + assert_eq(ret, CALENDAR_ERROR_INVALID_PARAMETER); return 0; } @@ -590,7 +593,7 @@ int utc_calendar_list_prev_n(void) */ int utc_calendar_list_next_p(void) { - assert_eq(g_startup_err, CALENDAR_ERROR_NONE); + assert_eq(g_startup_err, CALENDAR_ERROR_NONE); int ret = 0; if (false == _is_feature_supported()) { @@ -601,7 +604,7 @@ int utc_calendar_list_next_p(void) calendar_list_h list = NULL; ret = calendar_list_create(&list); - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); calendar_record_h event = NULL; // add new @@ -609,74 +612,74 @@ int utc_calendar_list_next_p(void) if (CALENDAR_ERROR_NONE != ret) { calendar_list_destroy(list, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); ret = utc_calendar_helper_event_set_new(event); if (CALENDAR_ERROR_NONE != ret) { calendar_list_destroy(list, true); calendar_record_destroy(event, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); ret = calendar_list_add(list, event); if (CALENDAR_ERROR_NONE != ret) { calendar_list_destroy(list, true); calendar_record_destroy(event, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); // add mod ret = calendar_record_create(_calendar_event._uri, &event); if (CALENDAR_ERROR_NONE != ret) { calendar_list_destroy(list, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); ret = utc_calendar_helper_event_set_mod(event); if (CALENDAR_ERROR_NONE != ret) { calendar_list_destroy(list, true); calendar_record_destroy(event, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); ret = calendar_list_add(list, event); if (CALENDAR_ERROR_NONE != ret) { calendar_list_destroy(list, true); calendar_record_destroy(event, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); // check: set first and next - ret = calendar_list_first(list); + ret = calendar_list_first(list); if (CALENDAR_ERROR_NONE != ret) { calendar_list_destroy(list, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); // next - ret = calendar_list_next(list); + ret = calendar_list_next(list); if (CALENDAR_ERROR_NONE != ret) { calendar_list_destroy(list, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); ret = calendar_list_get_current_record_p(list, &event); if (CALENDAR_ERROR_NONE != ret) { calendar_list_destroy(list, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); ret = utc_calendar_helper_event_check_mod(event); if (CALENDAR_ERROR_NONE != ret) { calendar_list_destroy(list, true); } - assert_eq(ret, CALENDAR_ERROR_NONE); + assert_eq(ret, CALENDAR_ERROR_NONE); calendar_list_destroy(list, true); return 0; } /** - * @testcase utc_calendar_list_next_n + * @test:case utc_calendar_list_next_n * @since_tizen 2.3 * @description Test fail moving a calendar list to the next position with invalid parameters. */ diff --git a/src/utc/calendar-service2/utc-calendar-recurrence.c b/src/utc/calendar-service2/utc-calendar-recurrence.c index 6c2dd97..845e15e 100755 --- a/src/utc/calendar-service2/utc-calendar-recurrence.c +++ b/src/utc/calendar-service2/utc-calendar-recurrence.c @@ -74,8 +74,12 @@ time_t __get_utime(int y, int m, int d, int h, int n, int s) void _create_event(calendar_record_h *out_event) { calendar_record_h event = NULL; - calendar_record_create(_calendar_event._uri, &event); - + int ret; + ret = calendar_record_create(_calendar_event._uri, &event); + if (CALENDAR_ERROR_NONE != ret){ + fprintf(stderr, "Calendar record create error at %s:%d\n", __FILE__, __LINE__); + return; + } const char *set_tzid = "Asia/Seoul"; calendar_record_set_str(event, _calendar_event.start_tzid, set_tzid); @@ -155,7 +159,12 @@ void _create_event(calendar_record_h *out_event) // alarm calendar_record_h alarm = NULL; - calendar_record_create(_calendar_alarm._uri, &alarm); + ret = calendar_record_create(_calendar_alarm._uri, &alarm); + if (CALENDAR_ERROR_NONE != ret) { + fprintf(stderr, "Calendar record create error at %s:%d\n", __FILE__, __LINE__); + calendar_record_destroy(event, true); + return; + } int set_alarm_tick = 5; calendar_record_set_int(alarm, _calendar_alarm.tick, set_alarm_tick); int set_alarm_unit = CALENDAR_ALARM_TIME_UNIT_MINUTE; @@ -173,8 +182,13 @@ void _create_event(calendar_record_h *out_event) // attendee calendar_record_h attendee = NULL; - calendar_record_create(_calendar_attendee._uri, &attendee); - + ret = calendar_record_create(_calendar_attendee._uri, &attendee); + if (CALENDAR_ERROR_NONE != ret) { + fprintf(stderr, "Calendar record create error at %s:%d\n", __FILE__, __LINE__); + calendar_record_destroy(event, true); + calendar_record_destroy(alarm, true); + return; + } const char *set_attendee_number = "010-1234-1234"; calendar_record_set_str(attendee, _calendar_attendee.number, set_attendee_number); int set_attendee_cutype = CALENDAR_ATTENDEE_CUTYPE_GROUP; diff --git a/src/utc/calendar-service2/utc-calendar-reminder.c b/src/utc/calendar-service2/utc-calendar-reminder.c index 1bdd122..161a173 100755 --- a/src/utc/calendar-service2/utc-calendar-reminder.c +++ b/src/utc/calendar-service2/utc-calendar-reminder.c @@ -129,6 +129,10 @@ static int _add_reminder_utime_in_event(int64_t utime, int unit, int recurrence, calendar_record_h event = NULL; ret = calendar_record_create(_calendar_event._uri, &event); + if (CALENDAR_ERROR_NONE != ret) { + calendar_record_destroy(alarm, true); + } + assert_eq(ret, CALENDAR_ERROR_NONE); if (CALENDAR_ALARM_TIME_UNIT_SPECIFIC != unit) { ret = calendar_record_set_caltime(event, _calendar_event.start_time, start_time); assert_eq(ret, CALENDAR_ERROR_NONE); @@ -217,6 +221,10 @@ static int _add_reminder_localtime_in_event(struct tm *local, int unit, int recu calendar_record_h event = NULL; ret = calendar_record_create(_calendar_event._uri, &event); + if (CALENDAR_ERROR_NONE != ret) { + calendar_record_destroy(alarm, true); + } + assert_eq(ret, CALENDAR_ERROR_NONE); if (CALENDAR_ALARM_TIME_UNIT_SPECIFIC != unit) { ret = calendar_record_set_caltime(event, _calendar_event.start_time, start_time); assert_eq(ret, CALENDAR_ERROR_NONE); @@ -291,6 +299,10 @@ static int _add_reminder_utime_in_todo(int64_t utime, int unit, int recurrence, calendar_record_h todo = NULL; ret = calendar_record_create(_calendar_todo._uri, &todo); + if (CALENDAR_ERROR_NONE != ret) { + calendar_record_destroy(alarm, true); + } + assert_eq(ret, CALENDAR_ERROR_NONE); if (CALENDAR_ALARM_TIME_UNIT_SPECIFIC != unit) { ret = calendar_record_set_caltime(todo, _calendar_todo.due_time, due_time); assert_eq(ret, CALENDAR_ERROR_NONE); @@ -357,6 +369,10 @@ static int _add_reminder_localtime_in_todo(struct tm *local, int unit, int recur calendar_record_h todo = NULL; ret = calendar_record_create(_calendar_todo._uri, &todo); + if (CALENDAR_ERROR_NONE != ret) { + calendar_record_destroy(alarm, true); + } + assert_eq(ret, CALENDAR_ERROR_NONE); if (CALENDAR_ALARM_TIME_UNIT_SPECIFIC != unit) { ret = calendar_record_set_caltime(todo, _calendar_todo.due_time, due_time); assert_eq(ret, CALENDAR_ERROR_NONE); diff --git a/src/utc/calendar-service2/utc-calendar-util.c b/src/utc/calendar-service2/utc-calendar-util.c index 29f4518..0fa95cf 100755 --- a/src/utc/calendar-service2/utc-calendar-util.c +++ b/src/utc/calendar-service2/utc-calendar-util.c @@ -35,12 +35,23 @@ void _clean_db_book(void) return; int i; - calendar_list_first(list); + int ret; + ret = calendar_list_first(list); + if (CALENDAR_ERROR_NONE != ret){ + calendar_list_destroy(list, true); + return; + } for(i = 0; i < count; i++){ int id = 0; calendar_record_h book = NULL; calendar_list_get_current_record_p(list, &book); - calendar_record_get_int(book, _calendar_book.id, &id); + ret = calendar_record_get_int(book, _calendar_book.id, &id); + if (CALENDAR_ERROR_NONE != ret){ + fprintf(stderr, "Current record error at %s:%d\n", __FILE__, __LINE__); + calendar_list_destroy(list, true); + calendar_list_destroy(book, true); + return; + } if (id <= DEFAULT_BIRTHDAY_CALENDAR_BOOK_ID) { calendar_list_next(list); continue; @@ -66,11 +77,25 @@ void _clean_db_timezone(void) ids = (int*) calloc(count, sizeof(int)); int i; - calendar_list_first(list); + int ret; + ret = calendar_list_first(list); + if (CALENDAR_ERROR_NONE != ret){ + fprintf(stderr, "Calendar list error at %s:%d\n", __FILE__, __LINE__); + calendar_list_destroy(list, true); + free(ids); + return; + } for(i = 0; i < count; i++){ calendar_record_h timezone = NULL; calendar_list_get_current_record_p(list, &timezone); - calendar_record_get_int(timezone, _calendar_timezone.id, &(ids[i])); + ret = calendar_record_get_int(timezone, _calendar_timezone.id, &(ids[i])); + if (CALENDAR_ERROR_NONE != ret){ + fprintf(stderr, "Current record error at %s:%d\n", __FILE__, __LINE__); + calendar_list_destroy(list, true); + calendar_list_destroy(timezone, true); + free(ids); + return; + } calendar_list_next(list); } calendar_list_destroy(list, true); @@ -96,11 +121,24 @@ void _clean_db_event(void) ids = (int*) calloc(count, sizeof(int)); int i; - calendar_list_first(list); + int ret; + ret = calendar_list_first(list); + if (CALENDAR_ERROR_NONE != ret){ + fprintf(stderr, "Calendar list error at %s:%d\n", __FILE__, __LINE__); + calendar_list_destroy(list, true); + free(ids); + return; + } for(i = 0; i < count; i++){ calendar_record_h event = NULL; calendar_list_get_current_record_p(list, &event); - calendar_record_get_int(event, _calendar_event.id, &(ids[i])); + ret = calendar_record_get_int(event, _calendar_event.id, &(ids[i])); + if (CALENDAR_ERROR_NONE != ret){ + fprintf(stderr, "Calendar record get error at %s:%d\n", __FILE__, __LINE__); + calendar_list_destroy(list, true); + calendar_list_destroy(event, true); + return; + } calendar_list_next(list); } calendar_list_destroy(list, true); @@ -126,11 +164,25 @@ void _clean_db_todo(void) ids = (int*) calloc(count, sizeof(int)); int i; - calendar_list_first(list); + int ret; + ret = calendar_list_first(list); + if (CALENDAR_ERROR_NONE != ret){ + fprintf(stderr, "Calendar list error at %s:%d\n", __FILE__, __LINE__); + calendar_list_destroy(list, true); + free(ids); + return; + } for(i = 0; i < count; i++){ calendar_record_h todo = NULL; calendar_list_get_current_record_p(list, &todo); - calendar_record_get_int(todo, _calendar_todo.id, &(ids[i])); + ret = calendar_record_get_int(todo, _calendar_todo.id, &(ids[i])); + if (CALENDAR_ERROR_NONE != ret){ + fprintf(stderr, "Calendar record get error at %s:%d\n", __FILE__, __LINE__); + calendar_list_destroy(list, true); + calendar_list_destroy(todo, true); + free(ids); + return; + } calendar_list_next(list); } calendar_list_destroy(list, true); diff --git a/src/utc/calendar-service2/utc-calendar-vcalendar.c b/src/utc/calendar-service2/utc-calendar-vcalendar.c index 3776d61..3a9e59c 100755 --- a/src/utc/calendar-service2/utc-calendar-vcalendar.c +++ b/src/utc/calendar-service2/utc-calendar-vcalendar.c @@ -71,6 +71,7 @@ void utc_calendar_vcalendar_startup(void) PRINT_UTC_LOG("[Line : %d][%s] 'DEVICE_SUITE_TARGET_30' Values Received = %s\\n", __LINE__, API_NAMESPACE, pszValue); int ics_path_len = strlen(pszValue) + strlen(ics_file) + 6; ics_path = (char*)malloc(ics_path_len); + CHECK_HANDLE(ics_path,"malloc:failure:utc_calendar_vcalendar_startup"); snprintf(ics_path, ics_path_len, "%s/res/%s", pszValue, ics_file); } else -- 2.7.4