Show a patch.

GET /api/1.1/patches/2224/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2224,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/2224/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2224/",
    "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": "<20191025213255.2751-2-laurent.pinchart@ideasonboard.com>",
    "date": "2019-10-25T21:32:55",
    "name": "[libcamera-devel,2/2] libcamera: controls: Avoid exception in ControlList count() and find()",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "e1a136adf28cd7d92f088d84de77fc0a6cdeb430",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": {
        "id": 14,
        "url": "https://patchwork.libcamera.org/api/1.1/users/14/?format=api",
        "username": "pinchartl",
        "first_name": "Laurent",
        "last_name": "Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "mbox": "https://patchwork.libcamera.org/patch/2224/mbox/",
    "series": [
        {
            "id": 551,
            "url": "https://patchwork.libcamera.org/api/1.1/series/551/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=551",
            "date": "2019-10-25T21:32:54",
            "name": "[libcamera-devel,1/2] test: controls: Add ControlInfoMap test",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/551/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2224/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2224/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 9BD5F614FF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Oct 2019 23:33:07 +0200 (CEST)",
            "from pendragon.ideasonboard.com (143.121.2.93.rev.sfr.net\n\t[93.2.121.143])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3DE9099A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Oct 2019 23:33:07 +0200 (CEST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1572039187;\n\tbh=Wb7kncZOf6ol9m4hG99xyRfJ9ENctf05jp1fANDSsJg=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=oI2kAF51mIzkrmsE/shiXej99/Liae0gDE6ahEe3BSMspQG1vdk8Krvn/dQx5RB3z\n\tDJoCJMru348kpTdbZqI8pPC9DwElkcUHD92tevQFK7f1bcF3hdlfC9RRN9fD+t4emQ\n\tQE2yb9jFrmjDO850pfBZ/zJtGpVNFLJn9h1SuvWs=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sat, 26 Oct 2019 00:32:55 +0300",
        "Message-Id": "<20191025213255.2751-2-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.23.0",
        "In-Reply-To": "<20191025213255.2751-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20191025213255.2751-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 2/2] libcamera: controls: Avoid exception\n\tin ControlList count() and find()",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.29",
        "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": "Fri, 25 Oct 2019 21:33:07 -0000"
    },
    "content": "The ControlList count() and find() methods use at() to lookup the\ncontrol numerical ID in the idmap_. This causes an exception to be\nthrown if the ID doesn't exist in the map. Fix it by using the find()\nmethod instead.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/controls.cpp | 18 +++++++++++++++---\n 1 file changed, 15 insertions(+), 3 deletions(-)",
    "diff": "diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex 93ad2fc6a276..0c7cd449ad64 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -491,7 +491,11 @@ const ControlInfoMap::mapped_type &ControlInfoMap::at(unsigned int id) const\n  */\n ControlInfoMap::size_type ControlInfoMap::count(unsigned int id) const\n {\n-\treturn count(idmap_.at(id));\n+\tauto iter = idmap_.find(id);\n+\tif (iter == idmap_.end())\n+\t\treturn 0;\n+\n+\treturn count(iter->second);\n }\n \n /**\n@@ -502,7 +506,11 @@ ControlInfoMap::size_type ControlInfoMap::count(unsigned int id) const\n  */\n ControlInfoMap::iterator ControlInfoMap::find(unsigned int id)\n {\n-\treturn find(idmap_.at(id));\n+\tauto iter = idmap_.find(id);\n+\tif (iter == idmap_.end())\n+\t\treturn end();\n+\n+\treturn find(iter->second);\n }\n \n /**\n@@ -513,7 +521,11 @@ ControlInfoMap::iterator ControlInfoMap::find(unsigned int id)\n  */\n ControlInfoMap::const_iterator ControlInfoMap::find(unsigned int id) const\n {\n-\treturn find(idmap_.at(id));\n+\tauto iter = idmap_.find(id);\n+\tif (iter == idmap_.end())\n+\t\treturn end();\n+\n+\treturn find(iter->second);\n }\n \n /**\n",
    "prefixes": [
        "libcamera-devel",
        "2/2"
    ]
}