summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkibak.yoon <kibak.yoon@samsung.com>2013-10-22 19:12:14 +0900
committerJacek Bukarewicz <j.bukarewicz@samsung.com>2013-10-23 15:55:55 +0200
commit94f91ab6ad5c615e818b24c4db193efc09b427ee (patch)
treeae11ae147d7ccfc4a886215bf5d7be6800598691
parentd2dbdc7e801b265a71faf8a2f027d79e72b92424 (diff)
downloadlibsf-common-94f91ab6ad5c615e818b24c4db193efc09b427ee.tar.gz
libsf-common-94f91ab6ad5c615e818b24c4db193efc09b427ee.tar.bz2
libsf-common-94f91ab6ad5c615e818b24c4db193efc09b427ee.zip
clean code & delete code checking if array is nullHEADtizen
Change-Id: Ic9aba38c1ad1846e026ef3c027dfda657b847e6a Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
-rwxr-xr-xsrc/cpacket.cpp47
1 files changed, 20 insertions, 27 deletions
diff --git a/src/cpacket.cpp b/src/cpacket.cpp
index a2d6f60..fc447e7 100755
--- a/src/cpacket.cpp
+++ b/src/cpacket.cpp
@@ -35,7 +35,7 @@
cpacket::cpacket(int size)
{
char *ptr;
-
+
try {
ptr = new char[size + sizeof(packet_t)];
} catch (...) {
@@ -72,9 +72,10 @@ void cpacket::set_payload_size(int size)
{
if (!m_packet) {
ERR("error m_packet null!!");
- } else {
- m_packet->size = size;
+ return;
}
+
+ m_packet->size = size;
}
@@ -83,9 +84,10 @@ void cpacket::set_version(int version)
{
if (!m_packet) {
ERR("error m_packet null!!");
- } else {
- m_packet->version = version;
+ return;
}
+
+ m_packet->version = version;
}
@@ -95,9 +97,9 @@ int cpacket::version(void)
if (!m_packet) {
ERR("error m_packet null!!");
return -1;
- } else {
- return m_packet->version;
}
+
+ return m_packet->version;
}
@@ -106,9 +108,10 @@ void cpacket::set_cmd(int cmd)
{
if (!m_packet) {
ERR("error m_packet null!!");
- } else {
- m_packet->cmd = cmd;
+ return;
}
+
+ m_packet->cmd = cmd;
}
@@ -118,9 +121,9 @@ int cpacket::cmd(void)
if (!m_packet) {
ERR("error m_packet null!!");
return -1;
- } else {
- return m_packet->cmd;
}
+
+ return m_packet->cmd;
}
@@ -130,14 +133,9 @@ bool cpacket::copy_data(void *data)
if ( !m_packet ) {
ERR("error m_packet null!!");
return false;
- } else {
- if ( !(m_packet->data) ) {
- ERR("error m_packet->data null!!");
- return false;
- } else {
- memcpy(m_packet->data, data, m_packet->size);
- }
}
+
+ memcpy(m_packet->data, data, m_packet->size);
return true;
}
@@ -148,14 +146,9 @@ void *cpacket::data(void)
if ( !m_packet ) {
ERR("error m_packet null!!");
return NULL;
- } else {
- if ( !(m_packet->data) ) {
- ERR("error m_packet->data null!!");
- return NULL;
- } else {
- return m_packet->data;
- }
}
+
+ return m_packet->data;
}
@@ -179,9 +172,9 @@ int cpacket::size(void)
if (!m_packet) {
ERR("error m_packet null!!");
return -1;
- } else {
- return m_packet->size + sizeof(cpacket::packet_t);
}
+
+ return m_packet->size + sizeof(cpacket::packet_t);
}