Apply Tizen coding rule 98/90198/2 submit/tizen/20160929.030608
authorpr.jung <pr.jung@samsung.com>
Thu, 29 Sep 2016 02:52:25 +0000 (11:52 +0900)
committerpr.jung <pr.jung@samsung.com>
Thu, 29 Sep 2016 03:00:48 +0000 (12:00 +0900)
Change-Id: Ib8a1a4d008989f12eeff5956a9afda767cfa364a
Signed-off-by: pr.jung <pr.jung@samsung.com>
src/storage-common.c
src/storage-inhouse.c
src/storage-internal.c

index d6d12163b3aaee3bd5574eb85a96a4711d773efa..3885dcaabd18996f74e5f4ab7a64b8ba511479bc 100644 (file)
@@ -1,29 +1,48 @@
+/*
+ * libstorage
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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 <libmount.h>
 #include "common.h"
 
 int is_compat_bind_mount(void)
 {
-        struct libmnt_table *t = NULL;
-        int r = 0;
-        struct libmnt_fs *fs;
+       struct libmnt_table *t = NULL;
+       int r = 0;
+       struct libmnt_fs *fs;
 
-        t = mnt_new_table();
-        if(!t)
-                return 0;
+       t = mnt_new_table();
+       if (!t)
+               return 0;
 
-        r = mnt_table_parse_mtab(t, NULL);
-        if (r < 0) {
-                mnt_free_table(t);
-                return 0;
-        }
+       r = mnt_table_parse_mtab(t, NULL);
+       if (r < 0) {
+               mnt_free_table(t);
+               return 0;
+       }
 
-        fs = mnt_table_find_target(t, COMPAT_DIR, MNT_ITER_BACKWARD);
-        if (fs) {
+       fs = mnt_table_find_target(t, COMPAT_DIR, MNT_ITER_BACKWARD);
+       if (fs) {
                 // TODO : mnt_fs_get_root(fs) should be matched to tzplatform_getenv(TZ_USER_CONTENT).
                mnt_free_table(t);
                return 1;
-        }
+       }
 
-        mnt_free_table(t);
-        return 0;
+       mnt_free_table(t);
+       return 0;
 }
index e589b14e8d156430c0cea11a89385a6d94b80ddb..9216393ec1ca473aff994fc3cbbcae962101c096 100755 (executable)
  */
 API int storage_get_compat_internal_path(const char* origin, int len, char* compat)
 {
-       int r=-1;
+       int r = -1;
+       int str_len;
        const char* str;
 
+       if (!compat || !origin) {
+               _E("Invalid parameter");
+               return -1;
+       }
+
        // this API works on place where compat path is bind-mounted
-       if(!is_compat_bind_mount()){
-               _E("no compat bind mount");
+       if (!is_compat_bind_mount()) {
+               _E("No compat bind mount");
                return -1;
        }
 
        str = tzplatform_getenv(TZ_USER_CONTENT);
-       if(strncmp(origin,str,strlen(str))!=0){
-               _E("failed to match TZ_USER_CONTENT");
+       str_len = strlen(str);
+       if (strncmp(origin, str, str_len) != 0) {
+               _E("Failed to match TZ_USER_CONTENT");
                return -1;
        }
 
-       r = snprintf(compat,len,"%s/%s",COMPAT_DIR,origin+strlen(str));
-       if(r < 0){
-               _E("failed to create new path");
+       r = snprintf(compat, len, "%s/%s", COMPAT_DIR, origin + str_len);
+       if (r < 0) {
+               _E("Failed to create new path");
                return -1;
        }
 
@@ -94,20 +101,27 @@ API int storage_get_compat_internal_path(const char* origin, int len, char* comp
 API int storage_get_origin_internal_path(const char* compat, int len, char* origin)
 {
        int r;
+       int compat_len;
+
+       if (!compat || !origin) {
+               _E("Invalid parameter");
+               return -1;
+       }
 
        // this API works on place where compat path is bind-mounted
-       if(!is_compat_bind_mount()){
+       if (!is_compat_bind_mount()) {
                _E("no compat bind mount");
                return -1;
        }
 
-       if(strncmp(compat,COMPAT_DIR,strlen(COMPAT_DIR))!=0){
+       compat_len = strlen(COMPAT_DIR);
+       if (strncmp(compat, COMPAT_DIR, compat_len) != 0) {
                _E("failed to match COMPAT_DIR");
                return -1;
        }
 
-       r = snprintf(origin,len,"%s/%s",tzplatform_getenv(TZ_USER_CONTENT),compat+strlen(COMPAT_DIR));
-       if(r < 0){
+       r = snprintf(origin, len, "%s/%s", tzplatform_getenv(TZ_USER_CONTENT), compat + compat_len);
+       if (r < 0) {
                _E("failed to create new path");
                return -1;
        }
index a177878d254a9c9a01d0bc6cc2a1e7bc41d8a69d..7f5d359bf7756ddcdd083718b50945e9a7e14597 100755 (executable)
@@ -62,7 +62,7 @@ static const char *internal_get_root(void)
 {
        const char *ret;
 
-       if(is_compat_bind_mount())
+       if (is_compat_bind_mount())
                ret = COMPAT_DIR;
        else
                ret = tzplatform_getenv(TZ_USER_CONTENT);