Initialize variables 72/245172/3
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 5 Oct 2020 05:37:44 +0000 (14:37 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 5 Oct 2020 06:41:49 +0000 (15:41 +0900)
This patch removes using uninitialised bytes.

Change-Id: Ic147bad418888f62ecd31ed6d4c28cbc476f1032
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/lib/amd_launch.c
src/lib/amd_util.c

index 7879341b652ae94d410ac532eed326459a4d421a..8a9101dc150944e7507328e08f7f32aa5781c614 100644 (file)
@@ -368,13 +368,11 @@ static int __send_sigkill(int pid, uid_t uid)
 
 int _resume_app(int pid, request_h req)
 {
-       int dummy;
        int ret;
        uid_t target_uid = _request_get_target_uid(req);
 
-       ret = aul_sock_send_raw(pid, target_uid,
-                       APP_RESUME_BY_PID, (unsigned char *)&dummy, 0,
-                       AUL_SOCK_ASYNC);
+       ret = aul_sock_send_raw(pid, target_uid, APP_RESUME_BY_PID,
+                       NULL, 0, AUL_SOCK_ASYNC);
        if (ret < 0) {
                if (ret == -EAGAIN) {
                        _E("resume packet timeout error");
@@ -423,13 +421,11 @@ int _launch_resume_inst(int pid, request_h req)
 
 int _pause_app(int pid, request_h req)
 {
-       int dummy;
        int ret;
        uid_t target_uid = _request_get_target_uid(req);
 
-       ret = aul_sock_send_raw(pid, target_uid,
-                       APP_PAUSE_BY_PID, (unsigned char *)&dummy, 0,
-                       AUL_SOCK_ASYNC);
+       ret = aul_sock_send_raw(pid, target_uid, APP_PAUSE_BY_PID,
+                       NULL, 0, AUL_SOCK_ASYNC);
        if (ret < 0) {
                if (ret == -EAGAIN) {
                        _E("pause packet timeout error");
@@ -478,11 +474,10 @@ int _launch_pause_inst(int pid, request_h req)
 
 int _term_sub_app(int pid, uid_t uid)
 {
-       int dummy;
        int ret;
 
        ret = aul_sock_send_raw(pid, uid, APP_TERM_BY_PID_ASYNC,
-                       (unsigned char *)&dummy, 0, AUL_SOCK_NOREPLY);
+                       NULL, 0, AUL_SOCK_NOREPLY);
        if (ret < 0) {
                _E("terminate packet send error - use SIGKILL pid(%d)", pid);
                if (__send_sigkill(pid, uid) < 0) {
@@ -523,13 +518,12 @@ int _term_sub_inst(pid_t pid, const char *inst_id, uid_t uid)
 
 int _term_app(int pid, request_h req)
 {
-       int dummy;
        int ret;
        uid_t uid = _request_get_target_uid(req);
 
        _noti_send(AMD_NOTI_MSG_LAUNCH_TERM_APP_START, pid, 0, req, NULL);
        ret = aul_sock_send_raw(pid, uid, APP_TERM_BY_PID,
-                       (unsigned char *)&dummy, 0, AUL_SOCK_ASYNC);
+                       NULL, 0, AUL_SOCK_ASYNC);
        if (ret < 0) {
                _E("terminate packet send error - use SIGKILL pid(%d)", pid);
                if (__send_sigkill(pid, uid) < 0) {
@@ -576,12 +570,10 @@ int _launch_terminate_inst(int pid, request_h req)
 
 int _term_req_app(int pid, request_h req)
 {
-       int dummy;
        int ret;
 
        ret = aul_sock_send_raw(pid, _request_get_target_uid(req),
-                       APP_TERM_REQ_BY_PID, (unsigned char *)&dummy, 0,
-                       AUL_SOCK_ASYNC);
+                       APP_TERM_REQ_BY_PID, NULL, 0, AUL_SOCK_ASYNC);
        if (ret < 0) {
                _D("terminate req send error");
                _request_send_result(req, ret);
@@ -595,13 +587,12 @@ int _term_req_app(int pid, request_h req)
 
 int _term_bgapp(int pid, request_h req)
 {
-       int dummy;
        int ret;
        uid_t uid = _request_get_target_uid(req);
 
        _noti_send(AMD_NOTI_MSG_LAUNCH_TERM_BGAPP_START, pid, 0, req, NULL);
        ret = aul_sock_send_raw(pid, uid, APP_TERM_BGAPP_BY_PID,
-                       (unsigned char *)&dummy, sizeof(int), AUL_SOCK_ASYNC);
+                       NULL, 0, AUL_SOCK_ASYNC);
        if (ret < 0) {
                _E("terminate packet send error - use SIGKILL pid(%d)", pid);
                if (__send_sigkill(pid, uid) < 0) {
@@ -642,14 +633,12 @@ int _launch_terminate_bg_inst(int pid, request_h req)
 
 int _term_app_v2(int pid, request_h req, bool *pend)
 {
-       int dummy;
        int ret;
        uid_t uid = _request_get_target_uid(req);
 
        _noti_send(AMD_NOTI_MSG_LAUNCH_TERM_APP_START, pid, 0, req, NULL);
        ret = aul_sock_send_raw(pid, uid, APP_TERM_BY_PID_SYNC,
-                       (unsigned char *)&dummy, 0,
-                       AUL_SOCK_ASYNC | AUL_SOCK_NOREPLY);
+                       NULL, 0, AUL_SOCK_ASYNC | AUL_SOCK_NOREPLY);
        if (ret < 0) {
                _E("Failed to send the terminate packet - use SIGKILL pid(%d)",
                                pid);
@@ -1013,20 +1002,14 @@ static int __compare_signature(const struct appinfo *ai, int cmd,
 
 static void __prepare_to_suspend(int pid, uid_t uid)
 {
-       int dummy = 0;
-
        SECURE_LOGD("[__SUSPEND__] pid: %d, uid: %d", pid, uid);
-       aul_sock_send_raw(pid, uid, APP_SUSPEND, (unsigned char *)&dummy,
-                       sizeof(int), AUL_SOCK_NOREPLY);
+       aul_sock_send_raw(pid, uid, APP_SUSPEND, NULL, 0, AUL_SOCK_NOREPLY);
 }
 
 static void __prepare_to_wake_services(int pid, uid_t uid)
 {
-       int dummy = 0;
-
        SECURE_LOGD("[__SUSPEND__] pid: %d, uid: %d", pid, uid);
-       aul_sock_send_raw(pid, uid, APP_WAKE, (unsigned char *)&dummy,
-                       sizeof(int), AUL_SOCK_NOREPLY);
+       aul_sock_send_raw(pid, uid, APP_WAKE, NULL, 0, AUL_SOCK_NOREPLY);
 }
 
 static gboolean __check_service_only(gpointer user_data)
index 6d36ec1a6ceb81739ff567552fb98f8db6aa6f15..434ae63d9486b77a10b6d99cf32b608bdeca53a9 100644 (file)
@@ -114,7 +114,7 @@ static int __send_message(int sock, const struct iovec *vec, int vec_size,
 static int __dispatch_get_mp_socket_pair(request_h req)
 {
        int handles[2] = {0, 0};
-       struct iovec vec[3];
+       struct iovec vec[3] = { 0, };
        int msglen = 0;
        char buffer[1024];
        int ret = 0;
@@ -133,7 +133,7 @@ static int __dispatch_get_mp_socket_pair(request_h req)
 
        _D("amd send mp fd : [%d, %d]", handles[0], handles[1]);
        vec[0].iov_base = buffer;
-       vec[0].iov_len = strlen(buffer) + 1;
+       vec[0].iov_len = 1;
 
        msglen = __send_message(_request_get_fd(req), vec, 1, handles, 2);
        if (msglen < 0) {
@@ -182,7 +182,7 @@ static int __dispatch_get_dc_socket_pair(request_h req)
        char *socket_pair_key = NULL;
        int socket_pair_key_len;
        int *handles = NULL;
-       struct iovec vec[3];
+       struct iovec vec[3] = { 0, };
        int msglen = 0;
        char buffer[1024];
        bundle *kb = _request_get_bundle(req);