Patch Detail
Show a patch.
GET /api/1.1/patches/789/?format=api
{ "id": 789, "url": "https://patchwork.libcamera.org/api/1.1/patches/789/?format=api", "web_url": "https://patchwork.libcamera.org/patch/789/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20190323073125.25497-2-laurent.pinchart@ideasonboard.com>", "date": "2019-03-23T07:31:24", "name": "[libcamera-devel,1/2] cam: Separate options valid() and empty()", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "21ccac6beb8a2852f908f26002cd80529d899e69", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/789/mbox/", "series": [ { "id": 217, "url": "https://patchwork.libcamera.org/api/1.1/series/217/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=217", "date": "2019-03-23T07:31:23", "name": "Qt-based libcamera viewer", "version": 1, "mbox": "https://patchwork.libcamera.org/series/217/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/789/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/789/checks/", "tags": {}, "headers": { "Return-Path": "<laurent.pinchart@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6D34F600FD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 23 Mar 2019 08:31:43 +0100 (CET)", "from pendragon.ideasonboard.com (30.net042126252.t-com.ne.jp\n\t[42.126.252.30])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 459B02D0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 23 Mar 2019 08:31:42 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1553326303;\n\tbh=521FQ7hf2R2MS0Ig9U0g5GyMfngmpuazRUr/TRcyoEI=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=fQ0CaT/ccFcIvRxfdE0aROSpNAbSjRrc5Jv3Z2H82l2+NbSvStvZALtj1+NS0XuKm\n\tNjotLa5LbGKWtDN3g7JIhyRr9J4M1SP/4nIaz9humPJwfnS8u0nKDtXboiF0ig+vfc\n\tOzfBLxKxQK0rJnwXkY15YFng4dcOmaWrMmGXLrZ8=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sat, 23 Mar 2019 09:31:24 +0200", "Message-Id": "<20190323073125.25497-2-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.19.2", "In-Reply-To": "<20190323073125.25497-1-laurent.pinchart@ideasonboard.com>", "References": "<20190323073125.25497-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 1/2] cam: Separate options valid() and\n\tempty()", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.23", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "X-List-Received-Date": "Sat, 23 Mar 2019 07:31:43 -0000" }, "content": "An empty option list is not necessarily an error. Add a new empty()\nfunction to test the option list for emptiness, and modify the valid()\nfunction to only notify parsing errors. As a side effect this allows\naccessing partially parsed options, which may be useful in the future.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/cam/main.cpp | 7 +++++--\n src/cam/options.cpp | 34 +++++++++++++++-------------------\n src/cam/options.h | 5 ++++-\n 3 files changed, 24 insertions(+), 22 deletions(-)", "diff": "diff --git a/src/cam/main.cpp b/src/cam/main.cpp\nindex 1ca7862bf237..e7490c32f99a 100644\n--- a/src/cam/main.cpp\n+++ b/src/cam/main.cpp\n@@ -67,9 +67,12 @@ static int parseOptions(int argc, char *argv[])\n \tparser.addOption(OptList, OptionNone, \"List all cameras\", \"list\");\n \n \toptions = parser.parse(argc, argv);\n-\tif (!options.valid() || options.isSet(OptHelp)) {\n+\tif (!options.valid())\n+\t\treturn -EINVAL;\n+\n+\tif (options.empty() || options.isSet(OptHelp)) {\n \t\tparser.usage();\n-\t\treturn !options.valid() ? -EINVAL : -EINTR;\n+\t\treturn options.empty() ? -EINVAL : -EINTR;\n \t}\n \n \treturn 0;\ndiff --git a/src/cam/options.cpp b/src/cam/options.cpp\nindex 655aa36bb9c9..f053a31d6ea1 100644\n--- a/src/cam/options.cpp\n+++ b/src/cam/options.cpp\n@@ -39,10 +39,16 @@ const char *Option::typeName() const\n * OptionBase<T>\n */\n \n+template<typename T>\n+bool OptionsBase<T>::empty() const\n+{\n+\treturn values_.empty();\n+}\n+\n template<typename T>\n bool OptionsBase<T>::valid() const\n {\n-\treturn !values_.empty();\n+\treturn valid_;\n }\n \n template<typename T>\n@@ -100,12 +106,6 @@ bool OptionsBase<T>::parseValue(const T &opt, const Option &option,\n \treturn true;\n }\n \n-template<typename T>\n-void OptionsBase<T>::clear()\n-{\n-\tvalues_.clear();\n-}\n-\n template class OptionsBase<int>;\n template class OptionsBase<std::string>;\n \n@@ -165,21 +165,18 @@ KeyValueParser::Options KeyValueParser::parse(const char *arguments)\n \n \t\tif (optionsMap_.find(key) == optionsMap_.end()) {\n \t\t\tstd::cerr << \"Invalid option \" << key << std::endl;\n-\t\t\toptions.clear();\n-\t\t\tbreak;\n+\t\t\treturn options;\n \t\t}\n \n \t\tOptionArgument arg = optionsMap_[key].argument;\n \t\tif (value.empty() && arg == ArgumentRequired) {\n \t\t\tstd::cerr << \"Option \" << key << \" requires an argument\"\n \t\t\t\t << std::endl;\n-\t\t\toptions.clear();\n-\t\t\tbreak;\n+\t\t\treturn options;\n \t\t} else if (!value.empty() && arg == ArgumentNone) {\n \t\t\tstd::cerr << \"Option \" << key << \" takes no argument\"\n \t\t\t\t << std::endl;\n-\t\t\toptions.clear();\n-\t\t\tbreak;\n+\t\t\treturn options;\n \t\t}\n \n \t\tconst Option &option = optionsMap_[key];\n@@ -187,11 +184,11 @@ KeyValueParser::Options KeyValueParser::parse(const char *arguments)\n \t\t\tstd::cerr << \"Failed to parse '\" << value << \"' as \"\n \t\t\t\t << option.typeName() << \" for option \" << key\n \t\t\t\t << std::endl;\n-\t\t\toptions.clear();\n-\t\t\tbreak;\n+\t\t\treturn options;\n \t\t}\n \t}\n \n+\toptions.valid_ = true;\n \treturn options;\n }\n \n@@ -412,19 +409,18 @@ OptionsParser::Options OptionsParser::parse(int argc, char **argv)\n \t\t\tstd::cerr << argv[optind - 1] << std::endl;\n \n \t\t\tusage();\n-\t\t\toptions.clear();\n-\t\t\tbreak;\n+\t\t\treturn options;\n \t\t}\n \n \t\tconst Option &option = *optionsMap_[c];\n \t\tif (!options.parseValue(c, option, optarg)) {\n \t\t\tparseValueError(option);\n \t\t\tusage();\n-\t\t\toptions.clear();\n-\t\t\tbreak;\n+\t\t\treturn options;\n \t\t}\n \t}\n \n+\toptions.valid_ = true;\n \treturn options;\n }\n \ndiff --git a/src/cam/options.h b/src/cam/options.h\nindex 745f4a4a3a43..0b0444c2db42 100644\n--- a/src/cam/options.h\n+++ b/src/cam/options.h\n@@ -45,6 +45,9 @@ template<typename T>\n class OptionsBase\n {\n public:\n+\tOptionsBase() : valid_(false) {}\n+\n+\tbool empty() const;\n \tbool valid() const;\n \tbool isSet(const T &opt) const;\n \tconst OptionValue &operator[](const T &opt) const;\n@@ -54,9 +57,9 @@ private:\n \tfriend class OptionsParser;\n \n \tbool parseValue(const T &opt, const Option &option, const char *value);\n-\tvoid clear();\n \n \tstd::map<T, OptionValue> values_;\n+\tbool valid_;\n };\n \n class KeyValueParser\n", "prefixes": [ "libcamera-devel", "1/2" ] }