bindings: cxx: don't check the chip's label and name for empty strings
authorBartosz Golaszewski <bartekgola@gmail.com>
Sun, 25 Feb 2018 13:18:56 +0000 (14:18 +0100)
committerBartosz Golaszewski <bartekgola@gmail.com>
Sun, 25 Feb 2018 13:18:56 +0000 (14:18 +0100)
The core library guarantees that a GPIO chip will have a name and
a label. No need to check if the returned strings are empty.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
bindings/cxx/chip.cpp

index c0204989021df296c8e979654c9fe53bf5b97296..7d4d80beead0b8f19484d4f6881e7fbdba8bfa85 100644 (file)
@@ -95,18 +95,14 @@ void chip::reset(void) noexcept
 {
        this->throw_if_noref();
 
-       const char* name = ::gpiod_chip_name(this->_m_chip.get());
-
-       return ::std::move(name ? ::std::string(name) : ::std::string());
+       return ::std::move(::std::string(::gpiod_chip_name(this->_m_chip.get())));
 }
 
 ::std::string chip::label(void) const
 {
        this->throw_if_noref();
 
-       const char* label = ::gpiod_chip_label(this->_m_chip.get());
-
-       return ::std::move(label ? ::std::string(label) : ::std::string());
+       return ::std::move(::std::string(::gpiod_chip_label(this->_m_chip.get())));
 }
 
 unsigned int chip::num_lines(void) const