sensord: change variable name of attribute-related functions 37/99937/2
authorkibak.yoon <kibak.yoon@samsung.com>
Thu, 24 Nov 2016 12:00:14 +0000 (21:00 +0900)
committerkibak.yoon <kibak.yoon@samsung.com>
Wed, 30 Nov 2016 13:06:12 +0000 (22:06 +0900)
- change name from value_len to len
- change name from attribute to attr

Change-Id: I7a2513f207c34fd564100b6bdd1d4f2798845ca8
Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
src/client/client.cpp
src/client/sensor_client_info.cpp
src/client/sensor_client_info.h
src/client/sensor_handle_info.cpp
src/client/sensor_handle_info.h
src/server/external_sensor_worker.cpp

index 7d22d9f..7fd43f5 100644 (file)
@@ -1135,7 +1135,7 @@ API int sensord_set_attribute_int(int handle, int attribute, int value)
        return change_attribute_int(handle, attribute, value);
 }
 
-API int sensord_set_attribute_str(int handle, int attribute, const char *value, int value_len)
+API int sensord_set_attribute_str(int handle, int attribute, const char *value, int len)
 {
        sensor_id_t sensor_id;
        command_channel *cmd_channel;
@@ -1154,22 +1154,22 @@ API int sensord_set_attribute_str(int handle, int attribute, const char *value,
                return -EPERM;
        }
 
-       retvm_if((value_len < 0) || (value == NULL), -EINVAL,
+       retvm_if((len < 0) || (value == NULL), -EINVAL,
                        "Invalid value_len: %d, value: %#x, handle: %d, %s, %s",
-                       value_len, value, handle, get_sensor_name(sensor_id), get_client_name());
+                       len, value, handle, get_sensor_name(sensor_id), get_client_name());
 
        client_id = sensor_client_info::get_instance().get_client_id();
        retvm_if((client_id < 0), -EPERM,
                        "Invalid client id : %d, handle: %d, %s, %s",
                        client_id, handle, get_sensor_name(sensor_id), get_client_name());
 
-       if (!cmd_channel->cmd_set_attribute_str(attribute, value, value_len)) {
+       if (!cmd_channel->cmd_set_attribute_str(attribute, value, len)) {
                _E("Sending cmd_set_attribute_str(%d, %d, %#x) failed for %s",
-                       client_id, value_len, value, get_client_name());
+                       client_id, len, value, get_client_name());
                return -EPERM;
        }
 
-       sensor_client_info::get_instance().set_attribute(handle, attribute, value, value_len);
+       sensor_client_info::get_instance().set_attribute(handle, attribute, value, len);
 
        return OP_SUCCESS;
 }
index 743cd29..2a755aa 100644 (file)
@@ -682,7 +682,7 @@ bool sensor_client_info::set_attribute(int handle, int attribute, int value)
        return true;
 }
 
-bool sensor_client_info::set_attribute(int handle, int attribute, const char *value, int value_len)
+bool sensor_client_info::set_attribute(int handle, int attribute, const char *value, int len)
 {
        AUTOLOCK(m_handle_info_lock);
 
@@ -693,17 +693,17 @@ bool sensor_client_info::set_attribute(int handle, int attribute, const char *va
                return false;
        }
 
-       auto it_attribute = it_handle->second.attributes_str.find(attribute);
+       auto it_attr = it_handle->second.attributes_str.find(attribute);
 
-       if (it_attribute != it_handle->second.attributes_str.end()) {
-               it_attribute->second->set(value, value_len);
+       if (it_attr != it_handle->second.attributes_str.end()) {
+               it_attr->second->set(value, len);
                return true;
        }
 
        attribute_info *info = new(std::nothrow) attribute_info();
        retvm_if(!info, false, "Failed to allocate memory");
 
-       info->set(value, value_len);
+       info->set(value, len);
        it_handle->second.attributes_str[attribute] = info;
 
        return true;
index 905d682..15f2677 100644 (file)
@@ -66,7 +66,7 @@ public:
        bool set_passive_mode(int handle, bool passive);
 
        bool set_attribute(int handle, int attribute, int value);
-       bool set_attribute(int handle, int attribute, const char *value, int value_len);
+       bool set_attribute(int handle, int attribute, const char *value, int len);
 
        bool set_sensor_pause_policy(int handle, int pause_policy);
        bool set_event_batch(int handle, unsigned int event_type, unsigned int interval, unsigned int latency);
index 9f2d562..5f10930 100644 (file)
@@ -40,15 +40,17 @@ attribute_info::~attribute_info()
        m_len = 0;
 }
 
-bool attribute_info::set(const char *value, unsigned int len)
+bool attribute_info::set(const char *value, int len)
 {
+       retvm_if(len < 0, false, "Invalid length");
+
        if (m_attr)
                delete m_attr;
 
        m_attr = new(std::nothrow) char[len];
        retvm_if(!m_attr, false, "Failed to allocate memory");
 
-       memcpy(m_attr, value, len);
+       memcpy(m_attr, value, (unsigned int)len);
        m_len = len;
 
        return true;
@@ -142,10 +144,10 @@ bool sensor_handle_info::delete_reg_event_info(unsigned int event_type)
 
 void sensor_handle_info::clear(void)
 {
-       sensor_attribute_str_map::iterator it_attribute;
+       sensor_attribute_str_map::iterator it_attr;
 
-       for (it_attribute = attributes_str.begin(); it_attribute != attributes_str.end(); ++it_attribute)
-               delete it_attribute->second;
+       for (it_attr = attributes_str.begin(); it_attr != attributes_str.end(); ++it_attr)
+               delete it_attr->second;
 
        attributes_int.clear();
        attributes_str.clear();
index 70cf5c9..6ede304 100644 (file)
@@ -34,7 +34,7 @@ public:
        ~attribute_info();
 
        char *get(void);
-       bool set(const char *value, unsigned int len);
+       bool set(const char *value, int len);
 
        unsigned int size(void);
 
index 67bb4d7..f62dc28 100644 (file)
@@ -95,7 +95,6 @@ bool external_sensor_worker::working(void *ctx)
        ret = inst->dispatch_command(header.cmd, payload);
 
        delete[] payload;
-
        return ret;
 }