summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYunmi Ha <yunmi.ha@samsung.com>2021-04-20 14:15:03 +0900
committerYunmi Ha <yunmi.ha@samsung.com>2021-04-20 14:15:03 +0900
commit4e422be0d3d06691132d9a007d2b39c21e871a60 (patch)
tree06aa081c914b5a17f82d919183a92c83523a9b94
parent4a418cb678c7e75c03b9894176ad63bc15819839 (diff)
downloadsensor-tm1-4e422be0d3d06691132d9a007d2b39c21e871a60.tar.gz
sensor-tm1-4e422be0d3d06691132d9a007d2b39c21e871a60.tar.bz2
sensor-tm1-4e422be0d3d06691132d9a007d2b39c21e871a60.zip
Use system error instaed of sensor_error_e
Change-Id: Ib1d298e14fa5efb9eb72819ce6980beb0ad7c295 Signed-off-by: Yunmi Ha <yunmi.ha@samsung.com>
-rwxr-xr-xsrc/accel/accel_device.cpp10
-rwxr-xr-xsrc/proxi/proxi_device.cpp10
-rwxr-xr-xsrc/sensorhub/sensorhub.cpp10
-rwxr-xr-xtestcase/sensor_device_haltest.cpp31
4 files changed, 30 insertions, 31 deletions
diff --git a/src/accel/accel_device.cpp b/src/accel/accel_device.cpp
index fc4bf2b..12e9af8 100755
--- a/src/accel/accel_device.cpp
+++ b/src/accel/accel_device.cpp
@@ -144,7 +144,7 @@ int accel_device::get_poll_fd(void)
int accel_device::get_sensors(const sensor_info_t **sensors)
{
- retvm_if(sensors == NULL || sensors == nullptr, SENSOR_ERROR_INVALID_PARAMETER, "%s:NULL interface", SENSOR_NAME);
+ retvm_if(sensors == NULL || sensors == nullptr, -EINVAL, "%s:NULL interface", SENSOR_NAME);
*sensors = &sensor_info;
return 1;
@@ -313,7 +313,7 @@ bool accel_device::update_value_iio(void)
int accel_device::read_fd(uint32_t **ids)
{
- retvm_if(ids == NULL || ids == nullptr, SENSOR_ERROR_INVALID_PARAMETER, "%s:NULL interface", SENSOR_NAME);
+ retvm_if(ids == NULL || ids == nullptr, -EINVAL, "%s:NULL interface", SENSOR_NAME);
if (!update_value()) {
_D("Failed to update value");
@@ -331,9 +331,9 @@ int accel_device::read_fd(uint32_t **ids)
int accel_device::get_data(uint32_t id, sensor_data_t **data, int *length)
{
sensor_data_t *sensor_data;
- retvm_if(data == NULL || data == nullptr, SENSOR_ERROR_INVALID_PARAMETER, "%s:NULL data interface", SENSOR_NAME);
- retvm_if(length == NULL || length == nullptr, SENSOR_ERROR_INVALID_PARAMETER, "%s:NULL length interface", SENSOR_NAME);
- retvm_if(id == 0 || id > MAX_ID, SENSOR_ERROR_INVALID_PARAMETER, "%s:Invalid ID Received", SENSOR_NAME);
+ retvm_if(data == NULL || data == nullptr, -EINVAL, "%s:NULL data interface", SENSOR_NAME);
+ retvm_if(length == NULL || length == nullptr, -EINVAL, "%s:NULL length interface", SENSOR_NAME);
+ retvm_if(id == 0 || id > MAX_ID, -EINVAL, "%s:Invalid ID Received", SENSOR_NAME);
sensor_data = new (std::nothrow) sensor_data_t;
retvm_if(!sensor_data, -ENOMEM, "Memory allocation failed");
diff --git a/src/proxi/proxi_device.cpp b/src/proxi/proxi_device.cpp
index 520df51..eb67102 100755
--- a/src/proxi/proxi_device.cpp
+++ b/src/proxi/proxi_device.cpp
@@ -126,7 +126,7 @@ int proxi_device::get_poll_fd(void)
int proxi_device::get_sensors(const sensor_info_t **sensors)
{
- retvm_if(sensors == NULL || sensors == nullptr, SENSOR_ERROR_INVALID_PARAMETER, "%s:NULL interface", SENSOR_NAME);
+ retvm_if(sensors == NULL || sensors == nullptr, -EINVAL, "%s:NULL interface", SENSOR_NAME);
*sensors = &sensor_info;
return 1;
@@ -182,7 +182,7 @@ bool proxi_device::update_value_input_event(void)
int proxi_device::read_fd(uint32_t **ids)
{
- retvm_if(ids == NULL || ids == nullptr, SENSOR_ERROR_INVALID_PARAMETER, "%s:NULL interface", SENSOR_NAME);
+ retvm_if(ids == NULL || ids == nullptr, -EINVAL, "%s:NULL interface", SENSOR_NAME);
if (!update_value()) {
_D("Failed to update value");
@@ -200,9 +200,9 @@ int proxi_device::read_fd(uint32_t **ids)
int proxi_device::get_data(uint32_t id, sensor_data_t **data, int *length)
{
sensor_data_t *sensor_data;
- retvm_if(data == NULL || data == nullptr, SENSOR_ERROR_INVALID_PARAMETER, "%s:NULL data interface", SENSOR_NAME);
- retvm_if(length == NULL || length == nullptr, SENSOR_ERROR_INVALID_PARAMETER, "%s:NULL length interface", SENSOR_NAME);
- retvm_if(id == 0 || id > MAX_ID, SENSOR_ERROR_INVALID_PARAMETER, "%s:Invalid ID Received", SENSOR_NAME);
+ retvm_if(data == NULL || data == nullptr, -EINVAL, "%s:NULL data interface", SENSOR_NAME);
+ retvm_if(length == NULL || length == nullptr, -EINVAL, "%s:NULL length interface", SENSOR_NAME);
+ retvm_if(id == 0 || id > MAX_ID, -EINVAL, "%s:Invalid ID Received", SENSOR_NAME);
sensor_data = new (std::nothrow) sensor_data_t;
retvm_if(!sensor_data, -ENOMEM, "Memory allocation failed");
diff --git a/src/sensorhub/sensorhub.cpp b/src/sensorhub/sensorhub.cpp
index 0d90e7b..0d61e7f 100755
--- a/src/sensorhub/sensorhub.cpp
+++ b/src/sensorhub/sensorhub.cpp
@@ -58,7 +58,7 @@ int sensorhub_device::get_sensors(const sensor_info_t **sensors)
{
int size;
- retvm_if(sensors == NULL || sensors == nullptr, SENSOR_ERROR_INVALID_PARAMETER, "sensorhub_device:NULL interface");
+ retvm_if(sensors == NULL || sensors == nullptr, -EINVAL, "sensorhub_device:NULL interface");
size = manager->get_sensors(sensors);
return size;
@@ -185,7 +185,7 @@ bool sensorhub_device::set_attribute_str(uint32_t id, int32_t attribute, char *v
int sensorhub_device::read_fd(uint32_t **ids)
{
sensorhub_data_t data;
- retvm_if(ids == NULL || ids == nullptr, SENSOR_ERROR_INVALID_PARAMETER, "%s:NULL interface", SENSOR_NAME);
+ retvm_if(ids == NULL || ids == nullptr, -EINVAL, "%s:NULL interface", SENSOR_NAME);
// step 1
if (!controller->read_fd(data))
return 0;
@@ -223,9 +223,9 @@ int sensorhub_device::read_fd(uint32_t **ids)
int sensorhub_device::get_data(uint32_t id, sensor_data_t **data, int *length)
{
int remains = 1;
- retvm_if(data == NULL || data == nullptr, SENSOR_ERROR_INVALID_PARAMETER, "%s:NULL data interface", SENSOR_NAME);
- retvm_if(length == NULL || length == nullptr, SENSOR_ERROR_INVALID_PARAMETER, "%s:NULL length interface", SENSOR_NAME);
- retvm_if(id == 0 || id > MAX_ID, SENSOR_ERROR_INVALID_PARAMETER, "%s:Invalid ID Received", SENSOR_NAME);
+ retvm_if(data == NULL || data == nullptr, -EINVAL, "%s:NULL data interface", SENSOR_NAME);
+ retvm_if(length == NULL || length == nullptr, -EINVAL, "%s:NULL length interface", SENSOR_NAME);
+ retvm_if(id == 0 || id > MAX_ID, -EINVAL, "%s:Invalid ID Received", SENSOR_NAME);
sensorhub_sensor *sensor = manager->get_sensor(id);
if (!sensor) {
diff --git a/testcase/sensor_device_haltest.cpp b/testcase/sensor_device_haltest.cpp
index f101871..dfca4f9 100755
--- a/testcase/sensor_device_haltest.cpp
+++ b/testcase/sensor_device_haltest.cpp
@@ -39,7 +39,6 @@ using namespace std;
do {\
if (!sensor_supported) {\
cout << #name <<" SENSOR NOT SUPPORTED" << endl;\
- EXPECT_EQ(ret, SENSOR_ERROR_NOT_SUPPORTED);\
return;\
}\
} while (0)
@@ -217,7 +216,7 @@ TEST_F(AccelSensorHalTest, get_sensorsN)
{
SENSOR_SUPPORT_CHECK(ACCEL);
ret = sensor_handle->get_sensors(nullptr);
- EXPECT_EQ(ret, SENSOR_ERROR_INVALID_PARAMETER);
+ EXPECT_EQ(ret, -EINVAL);
}
@@ -361,7 +360,7 @@ TEST_F(AccelSensorHalTest, read_fdN)
{
SENSOR_SUPPORT_CHECK(ACCEL);
ret = sensor_handle->read_fd(nullptr);
- EXPECT_EQ(ret, SENSOR_ERROR_INVALID_PARAMETER);
+ EXPECT_EQ(ret, -EINVAL);
}
/**
@@ -409,15 +408,15 @@ TEST_F(AccelSensorHalTest, get_dataN)
sensor_data_t *data = nullptr;
int length = 0;
ret = sensor_handle->get_data(id, nullptr, &length);
- EXPECT_EQ(ret, SENSOR_ERROR_INVALID_PARAMETER);
+ EXPECT_EQ(ret, -EINVAL);
data = nullptr;
ret = sensor_handle->get_data(id, &data, nullptr);
- EXPECT_EQ(ret, SENSOR_ERROR_INVALID_PARAMETER);
+ EXPECT_EQ(ret, -EINVAL);
id = 0;
data = nullptr;
length = 0;
ret = sensor_handle->get_data(id, &data, &length);
- EXPECT_EQ(ret, SENSOR_ERROR_INVALID_PARAMETER);
+ EXPECT_EQ(ret, -EINVAL);
}
@@ -537,7 +536,7 @@ TEST_F(ProxiSensorHalTest, get_sensorsN)
{
SENSOR_SUPPORT_CHECK(PROXIMITY);
ret = sensor_handle->get_sensors(nullptr);
- EXPECT_EQ(ret, SENSOR_ERROR_INVALID_PARAMETER);
+ EXPECT_EQ(ret, -EINVAL);
}
@@ -685,15 +684,15 @@ TEST_F(ProxiSensorHalTest, get_dataN)
sensor_data_t *data = nullptr;
int length = 0;
ret = sensor_handle->get_data(id, nullptr, &length);
- EXPECT_EQ(ret, SENSOR_ERROR_INVALID_PARAMETER);
+ EXPECT_EQ(ret, -EINVAL);
data = nullptr;
ret = sensor_handle->get_data(id, &data, nullptr);
- EXPECT_EQ(ret, SENSOR_ERROR_INVALID_PARAMETER);
+ EXPECT_EQ(ret, -EINVAL);
id = 0;
data = nullptr;
length = 0;
ret = sensor_handle->get_data(id, &data, &length);
- EXPECT_EQ(ret, SENSOR_ERROR_INVALID_PARAMETER);
+ EXPECT_EQ(ret, -EINVAL);
}
#ifdef MANUAL_TEST
@@ -740,7 +739,7 @@ TEST_F(ProxiSensorHalTest, read_fdN)
{
SENSOR_SUPPORT_CHECK(PROXIMITY);
ret = sensor_handle->read_fd(nullptr);
- EXPECT_EQ(ret, SENSOR_ERROR_INVALID_PARAMETER);
+ EXPECT_EQ(ret, -EINVAL);
}
#endif //MANUAL_TEST
@@ -808,7 +807,7 @@ TEST_F(SensorHubHalTest, get_sensorsN)
{
SENSOR_SUPPORT_CHECK(SENSORHUB);
ret = sensor_handle->get_sensors(nullptr);
- EXPECT_EQ(ret, SENSOR_ERROR_INVALID_PARAMETER);
+ EXPECT_EQ(ret, -EINVAL);
}
@@ -952,7 +951,7 @@ TEST_F(SensorHubHalTest, read_fdN)
{
SENSOR_SUPPORT_CHECK(SENSORHUB);
ret = sensor_handle->read_fd(nullptr);
- EXPECT_EQ(ret, SENSOR_ERROR_INVALID_PARAMETER);
+ EXPECT_EQ(ret, -EINVAL);
}
/**
@@ -1000,15 +999,15 @@ TEST_F(SensorHubHalTest, get_dataN)
sensor_data_t *data = nullptr;
int length = 0;
ret = sensor_handle->get_data(id, nullptr, &length);
- EXPECT_EQ(ret, SENSOR_ERROR_INVALID_PARAMETER);
+ EXPECT_EQ(ret, -EINVAL);
data = nullptr;
ret = sensor_handle->get_data(id, &data, nullptr);
- EXPECT_EQ(ret, SENSOR_ERROR_INVALID_PARAMETER);
+ EXPECT_EQ(ret, -EINVAL);
id = 0;
data = nullptr;
length = 0;
ret = sensor_handle->get_data(id, &data, &length);
- EXPECT_EQ(ret, SENSOR_ERROR_INVALID_PARAMETER);
+ EXPECT_EQ(ret, -EINVAL);
}