From 3787dc20064156c13c6e0b342337e50dcef7d28e Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Mon, 19 Feb 2018 10:51:17 +0100 Subject: [PATCH] bindings: cxx: require default values for output requests Require users to provide default values to line_bulk::request() when direction is output. Signed-off-by: Bartosz Golaszewski --- bindings/cxx/line_bulk.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bindings/cxx/line_bulk.cpp b/bindings/cxx/line_bulk.cpp index ec0d724..106c307 100644 --- a/bindings/cxx/line_bulk.cpp +++ b/bindings/cxx/line_bulk.cpp @@ -104,6 +104,9 @@ void line_bulk::request(const line_request& config, const std::vector defau if (!default_vals.empty() && this->size() != default_vals.size()) throw ::std::invalid_argument("the number of default values must correspond with the number of lines"); + if (config.request_type == line_request::DIRECTION_OUTPUT && default_vals.empty()) + throw ::std::invalid_argument("default values are required for output mode"); + ::gpiod_line_request_config conf; ::gpiod_line_bulk bulk; int rv; -- 2.30.2