Adjust coding rule and remove compile warning messages 07/57307/2 accepted/tizen/common/20160217.170703 accepted/tizen/ivi/20160218.023435 accepted/tizen/mobile/20160122.075727 accepted/tizen/tv/20160122.080143 accepted/tizen/wearable/20160122.080419 submit/tizen/20160122.030339 submit/tizen_common/20160217.131930 submit/tizen_ivi/20160217.000000 submit/tizen_ivi/20160217.000002
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 19 Jan 2016 01:56:51 +0000 (10:56 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 21 Jan 2016 00:23:43 +0000 (09:23 +0900)
Change-Id: I8b11dfc90bd3927f22e170410a7faba6b02179f2
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/db-schema.h
include/perf-measure.h
include/rua.h
include/rua_stat.h
src/perf-measure.c
src/rua.c
src/rua_stat.c
test/rua-test.c

index 87d34ca..3054493 100644 (file)
@@ -1,9 +1,5 @@
 /*
- *  RUA
- *
- * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +12,6 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- *
  */
 
 #ifndef __RUA_SCHEMA_H__
@@ -60,4 +55,4 @@ enum {
 
 
 
-#endif                         /* __RUA_SCHEMA_H__ */
+#endif /* __RUA_SCHEMA_H__ */
index 49dcc68..fbb252d 100644 (file)
@@ -1,9 +1,5 @@
 /*
- *  RUA
- *
- * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- *
  */
 
-#ifndef __PERF_MEASURE__
-#define __PERF_MEASURE__
+#ifndef __PERF_MEASURE_H__
+#define __PERF_MEASURE_H__
 
 #include <time.h>
 
-
-//#define PERF_MEASURE_ENABLE
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -48,19 +40,7 @@ unsigned int _perf_measure_end(const char *tag, unsigned int ts_start,
 
 #endif
 
-
-
-
-
-
-
-
-
-
-
-
-
 #ifdef __cplusplus
 }
 #endif
-#endif                         /*__PERF_MEASURE__*/
+#endif /* __PERF_MEASURE_H__ */
index 710d471..8c341c8 100755 (executable)
@@ -1,9 +1,5 @@
 /*
- *  RUA
- *
- * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +12,6 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- *
  */
 
 /**
@@ -68,8 +63,6 @@ struct rua_rec {
        time_t launch_time;             /**< application launching time */
 };
 
-
-
 /**
  * @brief      Delete history from DB
  * @return     0 on success, otherwise a nagative error value
index a20ffd7..c91d633 100755 (executable)
@@ -1,7 +1,5 @@
 /*
- *  RUA STAT
- *
- * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,7 +12,6 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- *
  */
 
 /**
@@ -61,4 +58,4 @@ API int rua_stat_get_stat_tags(char *caller,
 #ifdef __cplusplus
 }
 #endif
-#endif                         /*__RUA_STAT_H__*/
+#endif /*__RUA_STAT_H__*/
index 5168852..e1fa9e7 100644 (file)
@@ -1,9 +1,5 @@
 /*
- *  RUA
- *
- * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- *
  */
 
-
 #include <stdio.h>
 #include <sys/time.h>
 
index e0d93e2..8ba783e 100644 (file)
--- a/src/rua.c
+++ b/src/rua.c
@@ -1,9 +1,5 @@
 /*
- *  RUA
- *
- * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- *
- */
-
-/*
- * @file    rua.c
- * @version 0.1
  */
 
 #include <stdio.h>
@@ -149,9 +139,6 @@ int rua_add_history(struct rua_rec *rec)
        sqlite3_stmt *stmt;
        sqlite3 *db = NULL;
 
-       unsigned int timestamp;
-       timestamp = PERF_MEASURE_START("RUA");
-
        db = __db_init();
        if (db == NULL) {
                LOGE("Error db null");
@@ -189,13 +176,13 @@ int rua_add_history(struct rua_rec *rec)
                        RUA_HISTORY,
                        rec->pkg_name ? rec->pkg_name : "",
                        rec->app_path ? rec->app_path : "",
-                       rec->arg ? rec->arg : "", time(NULL));
+                       rec->arg ? rec->arg : "", (int)time(NULL));
        else
                /* update */
                snprintf(query, QUERY_MAXLEN,
                        "update %s set arg='%s', launch_time='%d' where pkg_name = '%s';",
                        RUA_HISTORY,
-                       rec->arg ? rec->arg : "", time(NULL), rec->pkg_name);
+                       rec->arg ? rec->arg : "", (int)time(NULL), rec->pkg_name);
 
        r = __exec(db, query);
        if (r == -1) {
@@ -204,7 +191,6 @@ int rua_add_history(struct rua_rec *rec)
                return -1;
        }
 
-       PERF_MEASURE_END("RUA", timestamp);
        db_util_close(db);
        return r;
 }
@@ -279,29 +265,24 @@ int rua_history_get_rec(struct rua_rec *rec, char **table, int nrows, int ncols,
        db_result = table + ((row + 1) * ncols);
 
        tmp = db_result[RUA_COL_ID];
-       if (tmp) {
+       if (tmp)
                rec->id = atoi(tmp);
-       }
 
        tmp = db_result[RUA_COL_PKGNAME];
-       if (tmp) {
+       if (tmp)
                rec->pkg_name = tmp;
-       }
 
        tmp = db_result[RUA_COL_APPPATH];
-       if (tmp) {
+       if (tmp)
                rec->app_path = tmp;
-       }
 
        tmp = db_result[RUA_COL_ARG];
-       if (tmp) {
+       if (tmp)
                rec->arg = tmp;
-       }
 
        tmp = db_result[RUA_COL_LAUNCHTIME];
-       if (tmp) {
+       if (tmp)
                rec->launch_time = atoi(tmp);
-       }
 
        return 0;
 }
@@ -344,7 +325,7 @@ int rua_is_latest_app(const char *pkg_name)
                        goto out;
                }
 
-               if (strncmp(pkg_name, ct, strlen(pkg_name)) == 0) {
+               if (strncmp(pkg_name, (const char *)ct, strlen(pkg_name)) == 0) {
                        r = 0;
                        goto out;
                }
index 5502daa..f00a78b 100755 (executable)
@@ -1,7 +1,5 @@
 /*
- *  RUA
- *
- * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,7 +12,6 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- *
  */
 
 /*
@@ -82,11 +79,12 @@ int __rua_stat_fini(void)
        return 0;
 }
 
-int __rua_stat_insert(char *caller, char *rua_stat_tag) {
-
+int __rua_stat_insert(char *caller, char *rua_stat_tag)
+{
        int r;
        char query[QUERY_MAXLEN];
        sqlite3_stmt *stmt = NULL;
+
        sqlite3_snprintf(QUERY_MAXLEN, query,
                "INSERT INTO rua_panel_stat (caller_panel, rua_stat_tag, score) VALUES (?,?,?)");
 
@@ -97,19 +95,19 @@ int __rua_stat_insert(char *caller, char *rua_stat_tag) {
        }
 
        r = sqlite3_bind_text(stmt, 1, caller, strlen(caller), SQLITE_STATIC);
-       if(r != SQLITE_OK) {
+       if (r != SQLITE_OK) {
                LOGE("caller bind error(%d) \n", r);
                goto out;
        }
 
        r = sqlite3_bind_text(stmt, 2, rua_stat_tag, strlen(rua_stat_tag), SQLITE_STATIC);
-       if(r != SQLITE_OK) {
+       if (r != SQLITE_OK) {
                LOGE("rua_stat_tag bind error(%d) \n", r);
                goto out;
        }
 
        r = sqlite3_bind_int(stmt, 3, WIN_SCORE);
-       if(r != SQLITE_OK) {
+       if (r != SQLITE_OK) {
                LOGE("arg bind error(%d) \n", r);
                goto out;
        }
@@ -120,25 +118,24 @@ int __rua_stat_insert(char *caller, char *rua_stat_tag) {
                goto out;
        }
 
-
-out :
-       if(stmt)
+out:
+       if (stmt)
                sqlite3_finalize(stmt);
 
        return r;
 }
 
-int __rua_stat_lose_score_update(char *caller, char *rua_stat_tag) {
-
+int __rua_stat_lose_score_update(char *caller, char *rua_stat_tag)
+{
        int r;
        char query[QUERY_MAXLEN];
        sqlite3_stmt *stmt = NULL;
+
        sqlite3_snprintf(QUERY_MAXLEN, query,
                "UPDATE rua_panel_stat SET score = score * %f WHERE caller_panel = ? AND rua_stat_tag != ?",
                LOSE_SCORE_RATE);
 
        LOGD("lose score update sql : %s", query);
-
        r = sqlite3_prepare(_db, query, sizeof(query), &stmt, NULL);
        if (r != SQLITE_OK) {
                LOGE("sqlite3_prepare error(%d , %d, %s)", r, sqlite3_extended_errcode(_db), sqlite3_errmsg(_db));
@@ -146,13 +143,13 @@ int __rua_stat_lose_score_update(char *caller, char *rua_stat_tag) {
        }
 
        r = sqlite3_bind_text(stmt, 1, caller, strlen(caller), SQLITE_STATIC);
-       if(r != SQLITE_OK) {
+       if (r != SQLITE_OK) {
                LOGE("caller bind error(%d) \n", r);
                goto out;
        }
 
        r = sqlite3_bind_text(stmt, 2, rua_stat_tag, strlen(rua_stat_tag), SQLITE_STATIC);
-       if(r != SQLITE_OK) {
+       if (r != SQLITE_OK) {
                LOGE("rua_stat_tag bind error(%d) \n", r);
                goto out;
        }
@@ -163,20 +160,19 @@ int __rua_stat_lose_score_update(char *caller, char *rua_stat_tag) {
                goto out;
        }
 
-
-out :
-       if(stmt)
+out:
+       if (stmt)
                sqlite3_finalize(stmt);
 
        return r;
-
 }
 
-int __rua_stat_win_score_update(char *caller, char *rua_stat_tag) {
-
+int __rua_stat_win_score_update(char *caller, char *rua_stat_tag)
+{
        int r;
        char query[QUERY_MAXLEN];
        sqlite3_stmt *stmt = NULL;
+
        sqlite3_snprintf(QUERY_MAXLEN, query,
                "UPDATE rua_panel_stat SET score = score + %d WHERE caller_panel = ? AND rua_stat_tag = ?",
                WIN_SCORE);
@@ -190,13 +186,13 @@ int __rua_stat_win_score_update(char *caller, char *rua_stat_tag) {
        }
 
        r = sqlite3_bind_text(stmt, 1, caller, strlen(caller), SQLITE_STATIC);
-       if(r != SQLITE_OK) {
+       if (r != SQLITE_OK) {
                LOGE("caller bind error(%d) \n", r);
                goto out;
        }
 
        r = sqlite3_bind_text(stmt, 2, rua_stat_tag, strlen(rua_stat_tag), SQLITE_STATIC);
-       if(r != SQLITE_OK) {
+       if (r != SQLITE_OK) {
                LOGE("rua_stat_tag bind error(%d) \n", r);
                goto out;
        }
@@ -207,20 +203,17 @@ int __rua_stat_win_score_update(char *caller, char *rua_stat_tag) {
                goto out;
        }
 
-
-out :
-       if(stmt)
+out:
+       if (stmt)
                sqlite3_finalize(stmt);
 
        return r;
-
 }
 
 int rua_stat_update(char *caller, char *rua_stat_tag)
 {
        int r;
        int affected_rows = 0;
-       sqlite3_stmt *stmt = NULL;
 
        LOGD("rua_stat_update start");
 
@@ -271,9 +264,10 @@ int rua_stat_update(char *caller, char *rua_stat_tag)
 }
 
 
-int rua_stat_get_stat_tags(char *caller, int (*rua_stat_tag_iter_fn)(const char *rua_stat_tag, void *data),
-               void *data) {
-
+int rua_stat_get_stat_tags(char *caller,
+               int (*rua_stat_tag_iter_fn)(const char *rua_stat_tag, void *data),
+               void *data)
+{
        int r;
        sqlite3_stmt *stmt;
        char query[QUERY_MAXLEN];
@@ -303,13 +297,12 @@ int rua_stat_get_stat_tags(char *caller, int (*rua_stat_tag_iter_fn)(const char
                goto out;
        }
 
-       while(sqlite3_step(stmt) == SQLITE_ROW) {
-
+       while (sqlite3_step(stmt) == SQLITE_ROW) {
                ct = sqlite3_column_text(stmt, 0);
-               if (ct == NULL || ct[0] == '\0') {
+               if (ct == NULL || ct[0] == '\0')
                        LOGW("sqlite3_column_text null");
-               }
-               rua_stat_tag_iter_fn(ct, data);
+
+               rua_stat_tag_iter_fn((const char *)ct, data);
        }
 
 out:
index bfd72c7..b84f742 100644 (file)
@@ -1,9 +1,5 @@
 /*
- *  RUA
- *
- * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +12,6 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- *
  */
 
 #include <stdio.h>
 
 #include "rua.h"
 
-int __add_history(char *pkgname)
+static int __add_history(char *pkgname)
 {
-       int ret = 0;
+       int ret;
        struct rua_rec rec;
-       const char *apppath = tzplatform_mkpath(TZ_SYS_RW_APP, pkgname);
 
        memset(&rec, 0, sizeof(rec));
        rec.pkg_name = pkgname;
-       rec.app_path = apppath;
-
-       ret = rua_init();
-       if (ret) {
-               fprintf(stderr, "error rua_init()\n");
-               return -1;
-       }
+       rec.app_path = (char *)tzplatform_mkpath(TZ_SYS_RW_APP, pkgname);
 
        ret = rua_add_history(&rec);
 
-       rua_fini();
-
        return ret;
 }