From 92d961154e909bbcaa76a256d3e1af624afbf04b Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Mon, 31 Dec 2018 16:38:36 +0900 Subject: [PATCH] Fix coding rule violation and add app_name in usbhost_get_contents not to reuse app_pid Change-Id: If6efdb9d3f94fc9361e3f702c4ea3fea592a11d3 Signed-off-by: lokilee73 --- src/common/macro.h | 22 +++++++++++----------- src/crash/crash.c | 2 +- src/launcher/app.c | 3 +-- src/usb/usb-device.c | 16 +++++++++------- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/common/macro.h b/src/common/macro.h index 2d1b0de..e299ca0 100644 --- a/src/common/macro.h +++ b/src/common/macro.h @@ -71,17 +71,17 @@ /* App to launch a popup on a notification */ -#define SYSTEM_SIGNAL_SENDER "org.tizen.system-signal-sender" -#define SIGNAL_SENDER_TYPE "_SIGNAL_TYPE_" -#define SIGNAL_SENDER_TYPE_RECOVERY "recovery-popup" -#define SIGNAL_SENDER_TYPE_USBSTORAGE_UNMOUNT "usbstorage-unmount-popup" -#define SIGNAL_SENDER_TYPE_COOLDOWN "cooldown" -#define SIGNAL_SENDER_TYPE_ENCRYPT ODE_ENCRYPT -#define SIGNAL_SENDER_TYPE_DECRYPT ODE_DECRYPT -#define SIGNAL_SENDER_TYPE_ODE_UG "ode-setting-ug" -#define SIGNAL_SENDER_DEVICE_PATH "_DEVICE_PATH_" -#define SIGNAL_SENDER_ERROR_TYPE "_ERROR_TYPE_" -#define SIGNAL_SENDER_MEMORY_SPACE "_MEMORY_SPACE_" +#define SYSTEM_SIGNAL_SENDER "org.tizen.system-signal-sender" +#define SIGNAL_SENDER_TYPE "_SIGNAL_TYPE_" +#define SIGNAL_SENDER_TYPE_RECOVERY "recovery-popup" +#define SIGNAL_SENDER_TYPE_USBSTORAGE_UNMOUNT "usbstorage-unmount-popup" +#define SIGNAL_SENDER_TYPE_COOLDOWN "cooldown" +#define SIGNAL_SENDER_TYPE_ENCRYPT ODE_ENCRYPT +#define SIGNAL_SENDER_TYPE_DECRYPT ODE_DECRYPT +#define SIGNAL_SENDER_TYPE_ODE_UG "ode-setting-ug" +#define SIGNAL_SENDER_DEVICE_PATH "_DEVICE_PATH_" +#define SIGNAL_SENDER_ERROR_TYPE "_ERROR_TYPE_" +#define SIGNAL_SENDER_MEMORY_SPACE "_MEMORY_SPACE_" /* ODE */ #define ODE_ENCRYPT "encrypt" diff --git a/src/crash/crash.c b/src/crash/crash.c index 342b023..56d3c5f 100644 --- a/src/crash/crash.c +++ b/src/crash/crash.c @@ -87,7 +87,7 @@ out: snprintf(tname, len, "%s", name); free(name); - _D("get_app_name() is finished"); + _D("get_app_name() is finished"); return 0; } diff --git a/src/launcher/app.c b/src/launcher/app.c index 8ba4ec7..98ac05b 100644 --- a/src/launcher/app.c +++ b/src/launcher/app.c @@ -31,9 +31,8 @@ static int launch_app(char *appname, return -EINVAL; b = bundle_create(); - if (!b) { + if (!b) return -ENOMEM; - } if (key1 && value1) { ret = bundle_add(b, key1, value1); diff --git a/src/usb/usb-device.c b/src/usb/usb-device.c index bd4f931..e193269 100644 --- a/src/usb/usb-device.c +++ b/src/usb/usb-device.c @@ -140,7 +140,7 @@ static void usbhost_confirm_cancel_clicked(void *data, Evas_Object *obj, void *e static int usbhost_get_contents(bundle *b, char *content, unsigned int len) { int ret; - char *text, *app_id; + char *text = NULL, *app_pid = NULL, *app_name = NULL; pid_t pid; if (!b) { @@ -148,14 +148,16 @@ static int usbhost_get_contents(bundle *b, char *content, unsigned int len) return -EINVAL; } - app_id = (char *)bundle_get_val(b, "_APP_PID_"); - if (!app_id) { + app_pid = (char *)bundle_get_val(b, "_APP_PID_"); + if (!app_pid) { _E("Failed to get pid"); return -ENOENT; } - pid = atoi(app_id); - ret = app_manager_get_app_id(pid, &app_id); + pid = atoi(app_pid); + free(app_pid); + + ret = app_manager_get_app_id(pid, &app_name); if (ret != APP_MANAGER_ERROR_NONE) { _E("Failed to get app id(%d)", ret); return -ENOENT; @@ -163,11 +165,11 @@ static int usbhost_get_contents(bundle *b, char *content, unsigned int len) text = gl_text_get(0); if (text) { - snprintf(content, len, text, app_id); + snprintf(content, len, text, app_name); free(text); } - free(app_id); + free(app_name); return 0; } -- 2.7.4