From 860b3b6f155b45481b5bab9acd1397b04a73e707 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Sun, 25 Feb 2018 14:18:56 +0100 Subject: [PATCH] bindings: cxx: don't check the chip's label and name for empty strings 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 --- bindings/cxx/chip.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/bindings/cxx/chip.cpp b/bindings/cxx/chip.cpp index c020498..7d4d80b 100644 --- a/bindings/cxx/chip.cpp +++ b/bindings/cxx/chip.cpp @@ -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 -- 2.30.2