Modify for Coding Rule
[platform/core/multimedia/libmm-session.git] / mm_session.c
index a10fc5a..4890afb 100644 (file)
@@ -54,7 +54,7 @@ int mm_session_init(int sessiontype)
        debug_log("type : %d", sessiontype);
 
        if (sessiontype < MM_SESSION_TYPE_MEDIA || sessiontype >= MM_SESSION_TYPE_NUM) {
-               debug_error("Invalid argument %d",sessiontype);
+               debug_error("Invalid argument %d", sessiontype);
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
@@ -110,11 +110,10 @@ int mm_session_update_option(session_update_type_t update_type, int options)
        }
        debug_log("[current] session_type: %d, session_option: %x", ltype, loption);
 
-       if (update_type == MM_SESSION_UPDATE_TYPE_ADD) {
+       if (update_type == MM_SESSION_UPDATE_TYPE_ADD)
                loption |= options;
-       } else if (update_type == MM_SESSION_UPDATE_TYPE_REMOVE) {
+       else if (update_type == MM_SESSION_UPDATE_TYPE_REMOVE)
                loption &= ~options;
-       }
 
        result = _mm_session_util_write_information(-1, ltype, loption);
        if (result) {
@@ -198,7 +197,7 @@ int mm_session_finish(void)
 
        /* Check monitor handle */
        result = _mm_session_util_delete_information(-1);
-       if(result != MM_ERROR_NONE)
+       if (result != MM_ERROR_NONE)
                return result;
 
        debug_fleave();
@@ -212,14 +211,14 @@ int _mm_session_util_delete_information(int app_pid)
        pid_t mypid;
        char filename[MAX_FILE_LENGTH];
 
-       if(app_pid == -1)
+       if (app_pid == -1)
                mypid = getpid();
        else
                mypid = (pid_t)app_pid;
 
        ////// DELETE SESSION TYPE /////////
        snprintf(filename, sizeof(filename)-1, "/tmp/mm_session_%d", mypid);
-       if(-1 ==  unlink(filename))
+       if (-1 ==  unlink(filename))
                return MM_ERROR_FILE_NOT_FOUND;
        ////// DELETE SESSION TYPE /////////
 
@@ -233,29 +232,28 @@ int _mm_session_util_write_type(int app_pid, int sessiontype)
        int fd = -1;
        char filename[MAX_FILE_LENGTH];
 
-       if(sessiontype < MM_SESSION_TYPE_MEDIA || sessiontype >= MM_SESSION_TYPE_NUM) {
+       if (sessiontype < MM_SESSION_TYPE_MEDIA || sessiontype >= MM_SESSION_TYPE_NUM)
                return MM_ERROR_INVALID_ARGUMENT;
-       }
 
-       if(app_pid == -1)
+       if (app_pid == -1)
                mypid = getpid();
        else
                mypid = (pid_t)app_pid;
 
        ////// WRITE SESSION TYPE /////////
        snprintf(filename, sizeof(filename)-1, "/tmp/mm_session_%d", mypid);
-       fd = open(filename, O_WRONLY | O_CREAT, 064);
-       if(fd < 0) {
-               debug_error("open() failed with %d",errno);
+       fd = open(filename, O_WRONLY | O_CREAT, 064);
+       if (fd < 0) {
+               debug_error("open() failed with %d", errno);
                return MM_ERROR_FILE_WRITE;
        }
        sessiontype = sessiontype << 16;
        write(fd, &sessiontype, sizeof(int));
-       if(0 > fchmod (fd, 00777)) {
+       if (0 > fchmod(fd, 00777))
                debug_error("fchmod failed with %d", errno);
-       } else {
+       else
                debug_warning("write sessiontype(%d) to /tmp/mm_session_%d", sessiontype >> 16, mypid);
-       }
+
        close(fd);
        ////// WRITE SESSION TYPE /////////
 
@@ -271,10 +269,10 @@ int _mm_session_util_read_type(int app_pid, int *sessiontype)
 
        debug_fenter();
 
-       if(sessiontype == NULL)
+       if (sessiontype == NULL)
                return MM_ERROR_INVALID_ARGUMENT;
 
-       if(app_pid == -1)
+       if (app_pid == -1)
                mypid = getpid();
        else
                mypid = (pid_t)app_pid;
@@ -282,9 +280,9 @@ int _mm_session_util_read_type(int app_pid, int *sessiontype)
        ////// READ SESSION TYPE /////////
        snprintf(filename, sizeof(filename)-1, "/tmp/mm_session_%d", mypid);
        fd = open(filename, O_RDONLY);
-       if(fd < 0) {
+       if (fd < 0)
                return MM_ERROR_INVALID_HANDLE;
-       }
+
        read(fd, sessiontype, sizeof(int));
        *sessiontype = *sessiontype >> 16;
        debug_warning("read sessiontype(%d) from /tmp/mm_session_%d", *sessiontype, mypid);
@@ -308,31 +306,28 @@ int _mm_session_util_write_information(int app_pid, int session_type, int flags)
            (session_type < MM_SESSION_TYPE_MEDIA || session_type >= MM_SESSION_TYPE_NUM)) {
                return MM_ERROR_INVALID_ARGUMENT;
        }
-       if(flags < 0) {
+       if (flags < 0)
                return MM_ERROR_INVALID_ARGUMENT;
-       }
 
-       if(app_pid == -1) {
+       if (app_pid == -1)
                mypid = getpid();
-       } else {
+       else
                mypid = (pid_t)app_pid;
-       }
 
        ////// WRITE SESSION INFO /////////
        snprintf(filename, sizeof(filename)-1, "/tmp/mm_session_%d", mypid);
-       fd = open(filename, O_WRONLY | O_CREAT, 0644 );
-       if(fd < 0) {
-               debug_error("open() failed with %d",errno);
+       fd = open(filename, O_WRONLY | O_CREAT, 0644);
+       if (fd < 0) {
+               debug_error("open() failed with %d", errno);
                return MM_ERROR_FILE_WRITE;
        }
 
        result_info = (flags) | (session_type << 16);
        write(fd, &result_info, sizeof(int));
-       if (0 > fchmod (fd, 00777)) {
+       if (0 > fchmod(fd, 00777))
                debug_error("fchmod failed with %d", errno);
-       } else {
+       else
                debug_warning("write session information(%x) to /tmp/mm_session_%d", result_info, mypid);
-       }
        close(fd);
        ////// WRITE SESSION INFO /////////
 
@@ -349,22 +344,19 @@ int _mm_session_util_read_information(int app_pid, int *session_type, int *flags
 
        debug_fenter();
 
-       if(session_type == NULL || flags == NULL) {
+       if (session_type == NULL || flags == NULL)
                return MM_ERROR_INVALID_ARGUMENT;
-       }
 
-       if(app_pid == -1) {
+       if (app_pid == -1)
                mypid = getpid();
-       } else {
+       else
                mypid = (pid_t)app_pid;
-       }
 
        ////// READ SESSION INFO /////////
        snprintf(filename, sizeof(filename)-1, "/tmp/mm_session_%d", mypid);
        fd = open(filename, O_RDONLY);
-       if(fd < 0) {
+       if (fd < 0)
                return MM_ERROR_INVALID_HANDLE;
-       }
        read(fd, &result_info, sizeof(int));
        *session_type = result_info >> 16;
        *flags = result_info & 0x0000ffff;