use for function instead of while: block is occured 01/69001/3
authorJeesun Kim <iamjs.kim@samsung.com>
Wed, 11 May 2016 05:16:17 +0000 (14:16 +0900)
committerjeesun kim <iamjs.kim@samsung.com>
Thu, 12 May 2016 02:41:20 +0000 (19:41 -0700)
Change-Id: I8498da862c36fb74e5d748cb35ad72ca851c3468

common/dbus/cal_dbus_helper.c
server/db/cal_db_plugin_event.c
server/db/cal_db_plugin_timezone.c
server/db/cal_db_plugin_todo.c
server/db/cal_db_util.c

index 0508c5c..84b1eb8 100644 (file)
@@ -244,13 +244,13 @@ static GVariant *_filter_to_gvariant(cal_composite_filter_s *f)
        return g_variant_builder_end(&builder);
 }
 
-static GVariant *_projection_to_gvariant(cal_query_s *p)
+static GVariant *_projection_to_gvariant(cal_query_s *q)
 {
        int i;
        GVariantBuilder builder;
        g_variant_builder_init(&builder, G_VARIANT_TYPE("au"));
-       for (i = 0; i < p->projection_count; i++)
-               g_variant_builder_add(&builder, "u", p->projection[i]);
+       for (i = 0; i < q->projection_count; i++)
+               g_variant_builder_add(&builder, "u", q->projection[i]);
 
        return g_variant_builder_end(&builder);
 }
@@ -1251,14 +1251,14 @@ static int _gvariant_to_projection(int count_projection, GVariant *arg_projectio
        GVariantIter *iter_projection = NULL;
        g_variant_get(arg_projection, "au", &iter_projection);
 
-       int i = 0;
        q->projection = calloc(count_projection, sizeof(unsigned int));
        if (NULL == q->projection) {
                ERR("calloc() Fail");
                return CALENDAR_ERROR_OUT_OF_MEMORY;
        }
-       while (g_variant_iter_loop(iter_projection, "u", &q->projection[i]))
-               i++;
+       int i = 0;
+       for (i = 0; i < count_projection; i++)
+               g_variant_iter_loop(iter_projection, "u", &q->projection[i]);
 
        q->projection_count = count_projection;
 
index e196a42..a35340d 100644 (file)
@@ -1972,6 +1972,22 @@ static void _cal_db_event_get_property_stmt(sqlite3_stmt *stmt,
                event->range_type = sqlite3_column_int(stmt, *stmt_count);
                break;
        case CAL_PROPERTY_EVENT_UNTIL:
+               event->until.type = sqlite3_column_int(stmt, *stmt_count);
+               if (event->until.type == CALENDAR_TIME_UTIME) {
+                       *stmt_count = *stmt_count+1;
+                       event->until.time.utime = sqlite3_column_int64(stmt, *stmt_count);
+                       *stmt_count = *stmt_count+1; /* until_datetime */
+               } else {
+                       *stmt_count = *stmt_count+1;
+                       *stmt_count = *stmt_count+1;
+                       temp = sqlite3_column_text(stmt, *stmt_count);
+                       if (temp) {
+                               sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME, &(event->until.time.date.year),
+                                               &(event->until.time.date.month), &(event->until.time.date.mday),
+                                               &(event->until.time.date.hour), &(event->until.time.date.minute),
+                                               &(event->until.time.date.second));
+                       }
+               }
                break;
        case CAL_PROPERTY_EVENT_COUNT:
                event->count = sqlite3_column_int(stmt, *stmt_count);
@@ -2095,8 +2111,11 @@ static void _cal_db_event_get_property_stmt(sqlite3_stmt *stmt,
        case CAL_PROPERTY_EVENT_CALENDAR_SYSTEM_TYPE:
                event->system_type = sqlite3_column_int(stmt, *stmt_count);
                break;
+       case CAL_PROPERTY_EVENT_IS_ALLDAY:
+               event->is_allday = sqlite3_column_int(stmt, *stmt_count);
+               break;
        default:
-               sqlite3_column_int(stmt, *stmt_count);
+               ERR("invalid (0x%x)", property);
                break;
        }
 
index bfb142e..cf165d3 100644 (file)
@@ -865,7 +865,7 @@ static void _cal_db_timezone_get_property_stmt(sqlite3_stmt *stmt,
                timezone->calendar_id = sqlite3_column_int(stmt, stmt_count);
                break;
        default:
-               sqlite3_column_int(stmt, stmt_count);
+               ERR("Invalid property(0x%x)", property);
                break;
        }
 
index a5493a3..1d2a9b9 100644 (file)
@@ -1587,6 +1587,22 @@ static void _cal_db_todo_get_property_stmt(sqlite3_stmt *stmt,
                todo->range_type = sqlite3_column_int(stmt, *stmt_count);
                break;
        case CAL_PROPERTY_TODO_UNTIL:
+               todo->until.type = sqlite3_column_int(stmt, *stmt_count);
+               if (todo->until.type == CALENDAR_TIME_UTIME) {
+                       *stmt_count = *stmt_count+1;
+                       todo->until.time.utime = sqlite3_column_int64(stmt, *stmt_count);
+                       *stmt_count = *stmt_count+1; /* until_datetime */
+               } else {
+                       *stmt_count = *stmt_count+1;
+                       *stmt_count = *stmt_count+1;
+                       temp = sqlite3_column_text(stmt, *stmt_count);
+                       if (temp) {
+                               sscanf((const char *)temp, CAL_FORMAT_LOCAL_DATETIME, &(todo->until.time.date.year),
+                                               &(todo->until.time.date.month), &(todo->until.time.date.mday),
+                                               &(todo->until.time.date.hour), &(todo->until.time.date.minute),
+                                               &(todo->until.time.date.second));
+                       }
+               }
                break;
        case CAL_PROPERTY_TODO_COUNT:
                todo->count = sqlite3_column_int(stmt, *stmt_count);
index 6885816..30e8b6e 100644 (file)
@@ -344,6 +344,7 @@ int cal_db_util_query_get_first_int_result(const char *query, GSList *bind_text,
                sqlite3_finalize(stmt);
                return CALENDAR_ERROR_NONE;
        }
+       sqlite3_finalize(stmt);
 
        switch (ret) {
        case SQLITE_DONE: