modify coding rule 41/171041/3 accepted/tizen/unified/20180227.151549 submit/tizen/20180227.010636
authorINSUN PYO <insun.pyo@samsung.com>
Mon, 26 Feb 2018 06:33:36 +0000 (15:33 +0900)
committerINSUN PYO <insun.pyo@samsung.com>
Mon, 26 Feb 2018 06:41:10 +0000 (15:41 +0900)
Signed-off-by: INSUN PYO <insun.pyo@samsung.com>
Change-Id: Ifcb97b6ccce99a944ca2caf4b48bf79833379108

src/systemd-user-helper/systemd-user-helper.c

index 882f596..05b9db6 100644 (file)
@@ -74,13 +74,14 @@ static const char *systemd_arg[] = {
        NULL
 };
 
-int mac_smack_use(void) {
-        static int cached_use = -1;
+int mac_smack_use(void)
+{
+       static int cached_use = -1;
 
-        if (cached_use < 0)
-                cached_use = access("/sys/fs/smackfs/", F_OK) >= 0;
+       if (cached_use < 0)
+               cached_use = access("/sys/fs/smackfs/", F_OK) >= 0;
 
-        return cached_use;
+       return cached_use;
 }
 
 static int mount_user_ext(char *username)
@@ -94,7 +95,7 @@ static int mount_user_ext(char *username)
        int r;
 
        mnt_uid = atoi(username);
-       if(mnt_uid <= 0)
+       if (mnt_uid <= 0)
                return -1;
 
        r = asprintf(&mount_point, "/run/user_ext/%s", username);
@@ -106,12 +107,9 @@ static int mount_user_ext(char *username)
        (void) mkdir(mount_point, 0750);
 
        r = getgrnam_r(GRP_NAME_SYSTEM_SHARE, &grp_buf, buf, sizeof(buf), &p_grp);
-       if( r == 0 && p_grp != NULL)
-       {
+       if (r == 0 && p_grp != NULL) {
                mnt_gid = p_grp->gr_gid;
-       }
-       else
-       {
+       } else {
                free(mount_point);
                return -2;
        }
@@ -330,14 +328,12 @@ static int change_smack_for_user_session()
 
        fp = fopen("/proc/self/attr/current", "w");
 
-       if(fp == NULL)
-       {
+       if (fp == NULL) {
                r = -errno;
                return r;
        }
        r = fputs("User", fp);
-       if(r == EOF)
-       {
+       if (r == EOF) {
                fclose(fp);
                r = -errno;
                return r;
@@ -363,8 +359,7 @@ int run_child(int argc, const char *argv[], char* user_id)
                r = -errno;
        } else if (pid == 0) {
                r = change_smack_for_user_session();
-               if(r != 0)
-               {
+               if (r != 0) {
                        fprintf(stderr, "failed to change smack\n");
                        return r;
                }
@@ -396,10 +391,11 @@ int main(int argc, char *argv[])
        operation = argv[1];
        username = argv[2];
 
-       if (strcmp(operation,"stop") == 0) {
+       if (strcmp(operation, "stop") == 0)
                return stop_process(username);
-       } else if (strcmp(operation, "start") == 0) {
-       } else {
+       else if (strcmp(operation, "start") == 0)
+               ; /* do main code */
+       else {
                fprintf(stderr, "option is invalid(%s)\n", operation);
                return -2;
        }