summaryrefslogtreecommitdiffstats
path: root/low-can-binding/utils/socketcan.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2019-11-21 16:13:52 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2020-01-09 15:55:03 +0100
commita4b14ff6fbd637f709eb874ee856974a5d764d63 (patch)
tree5a9e305e9bf1f50c7b6d29b24d8daf4ad7f3d00e /low-can-binding/utils/socketcan.cpp
parent52b04b1c1022b50f9d23692bef6c61b3fdcc1ae0 (diff)
socket: Raise an error if open function failed.
The socket opening wasn't tested and we fails later on another function using the wrongly opened socket. This would not happens anymore. Bug-AGL: SPEC-2988 Change-Id: I9b30bd9fc13b99277cbef6f7aeaddadc57ad0b18 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'low-can-binding/utils/socketcan.cpp')
-rw-r--r--low-can-binding/utils/socketcan.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/low-can-binding/utils/socketcan.cpp b/low-can-binding/utils/socketcan.cpp
index 50dfafb3..e8e01980 100644
--- a/low-can-binding/utils/socketcan.cpp
+++ b/low-can-binding/utils/socketcan.cpp
@@ -73,6 +73,9 @@ namespace utils
{
close();
socket_ = ::socket(domain, type, protocol);
+ if (socket_ < 0)
+ AFB_ERROR("Open failed. %s", strerror(errno));
+
return socket_;
}