From be072780a2dff05458774ee6fcd29fed720308a1 Mon Sep 17 00:00:00 2001 From: "jy910.yun" Date: Thu, 27 Jun 2013 16:45:09 +0900 Subject: [PATCH] revise error handling issues argument cannot be negative (NEGATIVE_RETURNS) Change-Id: I5c663a51e6ae82e886c132d84bff3df817e86d5f Signed-off-by: jy910.yun --- CMakeLists.txt | 4 ---- packaging/system-server.spec | 6 ------ src/core/device-change-handler.c | 1 + src/core/udev.h | 10 ++++++++- src/shared/haptic.c | 42 ++++++++++++++++++------------------ udev-rules/91-system-server.rules.in | 42 ------------------------------------ 6 files changed, 31 insertions(+), 74 deletions(-) delete mode 100644 udev-rules/91-system-server.rules.in diff --git a/CMakeLists.txt b/CMakeLists.txt index f771336..8546bfe 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,10 +145,7 @@ IF( $ENV{ARCH} MATCHES "arm" ) ENDIF() ADD_DEFINITIONS("-DDEBUG -DENABLE_DLOG_OUT") -SET(UDEV_RULES_PATH share/system-server/udev-rules) -SET(UDEV_RULES udev-rules/91-system-server.rules) -CONFIGURE_FILE(${UDEV_RULES}.in ${UDEV_RULES} @ONLY) CONFIGURE_FILE(device-daemon.in device-daemon @ONLY) # libdeviced @@ -169,7 +166,6 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} "-ldl" "-lm" "-ludev") INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) INSTALL(FILES ${MOVINAND_FORMAT} DESTINATION bin) -INSTALL(FILES ${UDEV_RULES} DESTINATION ${UDEV_RULES_PATH}) INSTALL(PROGRAMS ${CMAKE_BINARY_DIR}/device-daemon DESTINATION bin) INSTALL(FILES system-server.conf DESTINATION /etc/dbus-1/system.d) INSTALL(FILES ${CMAKE_SOURCE_DIR}/packaging/system-server.rule DESTINATION /opt/etc/smack/accesses.d) diff --git a/packaging/system-server.spec b/packaging/system-server.spec index 291b995..6e351c9 100755 --- a/packaging/system-server.spec +++ b/packaging/system-server.spec @@ -245,11 +245,6 @@ heynotitool set device_hdmi_chgdet heynotitool set device_keyboard_chgdet -mkdir -p /etc/udev/rules.d -if ! [ -L /etc/udev/rules.d/91-system-server.rules ]; then - ln -s %{_datadir}/system-server/udev-rules/91-system-server.rules /etc/udev/rules.d/91-system-server.rules -fi - systemctl daemon-reload if [ $1 == 1 ]; then systemctl restart system-server.service @@ -298,7 +293,6 @@ systemctl daemon-reload %{_libdir}/systemd/system/regpmon.service %{_libdir}/systemd/system/graphical.target.wants/zbooting-done.service %{_libdir}/systemd/system/zbooting-done.service -%{_datadir}/system-server/udev-rules/91-system-server.rules %{_datadir}/system-server/sys_pci_noti/res/locale/*/LC_MESSAGES/*.mo %config %{_sysconfdir}/dbus-1/system.d/system-server.conf diff --git a/src/core/device-change-handler.c b/src/core/device-change-handler.c index 129bc88..39bb30c 100644 --- a/src/core/device-change-handler.c +++ b/src/core/device-change-handler.c @@ -46,6 +46,7 @@ #include "sys_pci_noti/sys_pci_noti.h" #include "udev.h" #include "common.h" +#include "proc/proc-handler.h" #define PREDEF_USBCON "usbcon" #define PREDEF_EARJACKCON "earjack_predef_internal" diff --git a/src/core/udev.h b/src/core/udev.h index d2f9f0e..e92fb30 100644 --- a/src/core/udev.h +++ b/src/core/udev.h @@ -22,10 +22,18 @@ /* input device */ #define INPUT_SUBSYSTEM "input" -#define INPUT_PATH "*/input[0-9]*/event[0-9]*" +#define INPUT_PATH "*/input[0-9]*/event[0-9]*" #define ADD "add" #define REMOVE "remove" /* switch device */ #define SWITCH_SUBSYSTEM "switch" + +/* block device */ +#define BLOCK_SUBSYSTEM "block" +#define MMC_PATH "*/mmcblk[0-9]" + +/* host device */ +#define HOST_SUBSYSTEM "host_notify" + #endif /* __UDEV_H__ */ diff --git a/src/shared/haptic.c b/src/shared/haptic.c index 5f2addb..09ffd8c 100644 --- a/src/shared/haptic.c +++ b/src/shared/haptic.c @@ -55,7 +55,7 @@ static unsigned char* convert_file_to_buffer(const char *file_name, int *size) { FILE *pf; long file_size; - unsigned char *pdata; + unsigned char *pdata = NULL; if (!file_name) return NULL; @@ -67,35 +67,35 @@ static unsigned char* convert_file_to_buffer(const char *file_name, int *size) return NULL; } - if (fseek(pf, 0, SEEK_END)) { - _E("fseek failed : %s", strerror(errno)); - fclose(pf); - return NULL; - } + if (fseek(pf, 0, SEEK_END)) + goto error; file_size = ftell(pf); - if (fseek(pf, 0, SEEK_SET)) { - _E("fseek failed : %s", strerror(errno)); - fclose(pf); - return NULL; - } + if (fseek(pf, 0, SEEK_SET)) + goto error; + + if (file_size < 0) + goto error; pdata = (unsigned char*)malloc(file_size); - if (!pdata) { - fclose(pf); - return NULL; - } + if (!pdata) + goto error; - if (fread(pdata, 1, file_size, pf) != file_size) { - _E("fread failed : %s", strerror(errno)); - free(pdata); - fclose(pf); - return NULL; - } + if (fread(pdata, 1, file_size, pf) != file_size) + goto err_free; fclose(pf); *size = file_size; return pdata; + +err_free: + free(pdata); + +error: + fclose(pf); + + _E("failed to convert file to buffer (%s)", strerror(errno)); + return NULL; } static int save_data(const unsigned char *data, int size, const char *file_path) diff --git a/udev-rules/91-system-server.rules.in b/udev-rules/91-system-server.rules.in deleted file mode 100644 index 49ea8ec..0000000 --- a/udev-rules/91-system-server.rules.in +++ /dev/null @@ -1,42 +0,0 @@ -#MMC -ACTION=="add", KERNEL=="mmcblk[0-9]", SUBSYSTEM=="block", RUN+="@PREFIX@/bin/sys_event mmcblk_add" -ACTION=="remove", KERNEL=="mmcblk[0-9]", SUBSYSTEM=="block", RUN+="@PREFIX@/bin/sys_event mmcblk_remove" - -#Process Monitor -#ACTION=="change" SUBSYSTEM=="pmon", RUN+="@PREFIX@/bin/restart" - -#Jack -ACTION=="change" DEVPATH=="/devices/platform/jack", ENV{CHGDET}=="cdrom" RUN+="@PREFIX@/bin/start_composite.sh" - -#USB Host Device -ACTION=="add", SUBSYSTEM=="usb_device", RUN+="/usr/bin/sys_event device_usb_host_add" -ACTION=="remove", SUBSYSTEM=="usb_device", RUN+="/usr/bin/sys_event device_usb_host_remove" -ACTION=="change", SUBSYSTEM=="host_notify", ENV{STATE}=="ADD", RUN+="@PREFIX@/bin/vconftool set -t int memory/sysman/usbhost_status 1 -f" -ACTION=="change", SUBSYSTEM=="host_notify", ENV{STATE}=="REMOVE", RUN+="@PREFIX@/bin/vconftool set -t int memory/sysman/usbhost_status 0 -f" -ACTION=="change", SUBSYSTEM=="host_notify", ENV{STATE}=="OVERCURRENT", RUN+="@PREFIX@/bin/vconftool set -t int memory/sysman/usbhost_status 2 -f" - -#USB Storage -ACTION=="add", KERNEL=="sd[a-z][0-9]", SUBSYSTEM=="block", RUN+="@PREFIX@/bin/vconftool set -t string memory/private/sysman/added_storage_uevent %N -f" -ACTION=="remove", KERNEL=="sd[a-z][0-9]", SUBSYSTEM=="block", RUN+="@PREFIX@/bin/vconftool set -t string memory/private/sysman/removed_storage_uevent $name -f" - -#charge -ACTION=="change" DEVPATH=="/devices/platform/samsung-battery/power_supply/battery" RUN+="/usr/bin/sys_event device_charge_chgdet" -ACTION=="change" DEVPATH=="/devices/platform/charger-manager.0" RUN+="@PREFIX@/bin/sys_event device_charge_chgdet" -ACTION=="change" DEVPATH=="/devices/virtual/power_supply/battery" RUN+="/usr/bin/sys_event device_charge_chgdet" -ACTION=="change" DEVPATH=="/devices/platform/sec-battery/power_supply/battery" RUN+="/usr/bin/sys_event device_charge_chgdet" - -#USB Keyboard -ACTION=="add" SUBSYSTEM=="input" DEVPATH=="*/input[1-9]*/event[1-9]*" ENV{ID_BUS}=="usb" ENV{ID_INPUT_KEYBOARD}=="?*" RUN+="/usr/bin/sys_event device_keyboard_add" -ACTION=="remove" SUBSYSTEM=="input" DEVPATH=="*/input[1-9]*/event[1-9]*" ENV{ID_BUS}=="usb" ENV{ID_INPUT_KEYBOARD}=="?*" RUN+="/usr/bin/sys_event device_keyboard_remove" -ACTION=="add" SUBSYSTEM=="input" DEVPATH=="*/input[1-9]*/event[1-9]*" ENV{ID_BUS}=="usb" ENV{ID_INPUT_MOUSE}=="?*" RUN+="/usr/bin/sys_event device_mouse_add" -ACTION=="remove" SUBSYSTEM=="input" DEVPATH=="*/input[1-9]*/event[1-9]*" ENV{ID_BUS}=="usb" ENV{ID_INPUT_MOUSE}=="?*" RUN+="/usr/bin/sys_event device_mouse_remove" - -#PCI keyboard -ACTION=="add" SUBSYSTEM=="input" DEVPATH=="*/virtio[1-9]*/input/input[1-9]*/event[1-9]*" ENV{ID_PATH}=="*virtio-pci*" ENV{ID_INPUT_KEYBOARD}=="?*" RUN+="/usr/bin/sys_event device_pci_keyboard_add" -ACTION=="remove" SUBSYSTEM=="input" DEVPATH=="*/virtio[1-9]*/input/input[1-9]*/event[1-9]*" ENV{ID_PATH}=="*virtio-pci*" ENV{ID_INPUT_KEYBOARD}=="?*" RUN+="/usr/bin/sys_event device_pci_keyboard_remove" - -#Smart debug bridge -ACTION=="add", KERNEL=="samsung_sdb", SYMLINK+="tizen_sdb" - -# Since power_manager is running as app user, make sure this user can read the input device nodes -SUBSYSTEM=="input" DEVPATH=="*/input[0-9]*/event[0-9]*" GROUP="video" -- 2.7.4