From 0f194302a5771ce77635ea5b920e3e88f074de4c Mon Sep 17 00:00:00 2001 From: Seungbae Shin Date: Mon, 11 Sep 2017 21:46:46 +0900 Subject: [PATCH] Modify for Coding Rule [Version] 0.2.13 [Profile] Common [Issue Type] Cleanup Change-Id: I8adad67f4b896bd5652c467dffd94a51fb6d22d6 --- mm_session.c | 68 +++++++++++++++++++------------------------- mm_session.h | 6 ++-- mm_session_private.h | 8 +++--- packaging/libmm-session.spec | 2 +- 4 files changed, 38 insertions(+), 46 deletions(-) diff --git a/mm_session.c b/mm_session.c index a10fc5a..4890afb 100644 --- a/mm_session.c +++ b/mm_session.c @@ -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, 0644 ); - 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; diff --git a/mm_session.h b/mm_session.h index 758e221..78da3b6 100644 --- a/mm_session.h +++ b/mm_session.h @@ -83,7 +83,7 @@ typedef enum { * @return This function returns MM_ERROR_NONE on success, or negative value * with error code. * @remark Session type is unique for each application (each PID actually). - * if application want to change session type, Finish session first and Init again + * if application want to change session type, Finish session first and Init again * @see MMSessionType mm_session_finish * @since * @pre There should be pre-initialized session type for caller application. @@ -139,11 +139,11 @@ int mm_session_init(int sessiontype); /** * This function finish application's Multimedia Session. * - * + * * @return This function returns MM_ERROR_NONE on success, or negative value * with error code. * @remark Session type is unique for each application (each PID actually). - * if application want to change session type, Finish session first and Init again + * if application want to change session type, Finish session first and Init again * @see mm_session_init * @pre A session type should be initialized for caller application. * @post A session type for caller application will be cleared. diff --git a/mm_session_private.h b/mm_session_private.h index 06ecac1..bde9374 100644 --- a/mm_session_private.h +++ b/mm_session_private.h @@ -88,8 +88,8 @@ int _mm_session_util_delete_information(int app_pid); * @return This function returns MM_ERROR_NONE on success, or negative value * with error code. * @remark This function is only for internal implementation do not use this at application - * Session type is unique for each application. - * if application want to change session type, Finish session first and Init again + * Session type is unique for each application. + * if application want to change session type, Finish session first and Init again * @see _mm_session_util_delete_information _mm_session_util_read_type * @since */ @@ -105,7 +105,7 @@ int _mm_session_util_write_type(int app_pid, int sessiontype); * @return This function returns MM_ERROR_NONE on success, or negative value * with error code. * @remark Session type is unique for each application. - * if application want to change session type, Finish session first and Init again + * if application want to change session type, Finish session first and Init again * @see _mm_session_util_write_type _mm_session_util_delete_information * @since */ @@ -122,7 +122,7 @@ int _mm_session_util_read_type(int app_pid, int *sessiontype); * @return This function returns MM_ERROR_NONE on success, or negative value * with error code. * @remark This function is only for internal implementation do not use this at application - * Session type and Session option are unique for each application. + * Session type and Session option are unique for each application. * @see _mm_session_util_delete_information _mm_session_util_read_information * @since */ diff --git a/packaging/libmm-session.spec b/packaging/libmm-session.spec index 6c9507f..426a4e3 100644 --- a/packaging/libmm-session.spec +++ b/packaging/libmm-session.spec @@ -1,6 +1,6 @@ Name: libmm-session Summary: Multimedia Session Library -Version: 0.2.12 +Version: 0.2.13 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 -- 2.7.4