diff options
author | Taeyoung Kim <ty317.kim@samsung.com> | 2015-12-29 14:02:45 +0900 |
---|---|---|
committer | Taeyoung Kim <ty317.kim@samsung.com> | 2015-12-31 14:45:52 +0900 |
commit | c8855c9f8a5203bc3cc4e8ddba563d796ecdc06e (patch) | |
tree | 60281c3e11e223ebebba66d954da7e35ae649802 | |
parent | 290fbb44b718abaf032c849e6ff415e4a0cda831 (diff) | |
download | deviced-c8855c9f8a5203bc3cc4e8ddba563d796ecdc06e.tar.gz deviced-c8855c9f8a5203bc3cc4e8ddba563d796ecdc06e.tar.bz2 deviced-c8855c9f8a5203bc3cc4e8ddba563d796ecdc06e.zip |
sysman: fix warnings which are occurred during compiling
- Log macros are changed to its own macro
- Return values are checked for write() operaiton
Change-Id: If5eab574172757ccd69b8ff8afa12e58a100c85f
Signed-off-by: Taeyoung Kim <ty317.kim@samsung.com>
-rw-r--r-- | src/libsysman/sysconf.c | 1 | ||||
-rw-r--r-- | src/libsysman/sysnoti.c | 33 |
2 files changed, 26 insertions, 8 deletions
diff --git a/src/libsysman/sysconf.c b/src/libsysman/sysconf.c index 856faa78..726097e2 100644 --- a/src/libsysman/sysconf.c +++ b/src/libsysman/sysconf.c @@ -18,6 +18,7 @@ #include <stdio.h> +#include <unistd.h> #include <dd-deviced.h> #include "sysman-priv.h" diff --git a/src/libsysman/sysnoti.c b/src/libsysman/sysnoti.c index d2724619..b2faead7 100644 --- a/src/libsysman/sysnoti.c +++ b/src/libsysman/sysnoti.c @@ -44,18 +44,35 @@ static inline int send_int(int fd, int val) static inline int send_str(int fd, char *str) { - int len; + int len = 0; int ret; + if (str == NULL) { - len = 0; ret = write(fd, &len, sizeof(int)); - } else { - len = strlen(str); - if (len > SYSMAN_MAXSTR) - len = SYSMAN_MAXSTR; - write(fd, &len, sizeof(int)); - ret = write(fd, str, len); + if (ret < 0) { + ret = -errno; + ERR("write() failed (%d)", ret); + } + return ret; + } + + len = strlen(str); + if (len > SYSMAN_MAXSTR) + len = SYSMAN_MAXSTR; + + ret = write(fd, &len, sizeof(int)); + if (ret < 0) { + ret = -errno; + ERR("write() failed (%d)", ret); + return ret; + } + + ret = write(fd, str, len); + if (ret < 0) { + ret = -errno; + ERR("write() failed (%d)", ret); } + return ret; } |