Show a patch.

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

{
    "id": 13939,
    "url": "https://patchwork.libcamera.org/api/patches/13939/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/13939/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20210926210554.20901-1-laurent.pinchart@ideasonboard.com>",
    "date": "2021-09-26T21:05:54",
    "name": "[libcamera-devel] simple-cam: Move camera detection check to where it belongs",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "b75fd500fe903df7dd9fea29b4eb1cf15e616d13",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/13939/mbox/",
    "series": [
        {
            "id": 2570,
            "url": "https://patchwork.libcamera.org/api/series/2570/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2570",
            "date": "2021-09-26T21:05:54",
            "name": "[libcamera-devel] simple-cam: Move camera detection check to where it belongs",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/2570/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/13939/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/13939/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>",
        "X-Original-To": "parsemail@patchwork.libcamera.org",
        "Delivered-To": "parsemail@patchwork.libcamera.org",
        "Received": [
            "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 92B8CBF01C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 26 Sep 2021 21:06:05 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id ABD4A6918E;\n\tSun, 26 Sep 2021 23:06:04 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CFB366012D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 26 Sep 2021 23:06:02 +0200 (CEST)",
            "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 58707EF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 26 Sep 2021 23:06:02 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"wpmBE/7Z\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1632690362;\n\tbh=aKeMvpk3MlFdgNyFyuivJuHzdbbZ5ipLmzU+SCxyAHc=;\n\th=From:To:Subject:Date:From;\n\tb=wpmBE/7ZBb3H8jiFzYbB4k6fNj7s6WhZA0xcgah75M10SZAcyolGlfit7rDeOYHuh\n\tAKRNAxqpKtJrbeYUXyP7aPkIHbBylwO3oH7/1e9G2Szxanfjxlt3WgHj4qZjepQmtK\n\t7vT4hMP5jBTKZ8AhFcWrqrtVYyeXA6sWqCMf1790=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 27 Sep 2021 00:05:54 +0300",
        "Message-Id": "<20210926210554.20901-1-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.32.0",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH] simple-cam: Move camera detection check\n\tto where it belongs",
        "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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Commit 14529b6d1c4a (\"simple-cam: Early return if no cameras are found\non the system\") added a check to ensure that at least one camera is\npresent in the system to avoid a crash otherwise. The check was however\nplaced towards the end of the main() function, way after the camera is\naccessed, possibly due to a rebase conflict. Move it before accessing\nthe first camera.\n\nWhile at it, replace usage of std::vector::size() with\nstd::vector::empty() which expresses the intent better.\n\nFixes: 14529b6d1c4a (\"simple-cam: Early return if no cameras are found on the system\")\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n simple-cam.cpp | 17 +++++++++--------\n 1 file changed, 9 insertions(+), 8 deletions(-)\n\n\nbase-commit: 1f795410c0d99aaa15c8155d7d16ae6357487a96\nprerequisite-patch-id: a9984c79d9b952f4004a670f8828600af70d732e\nprerequisite-patch-id: 8dcf991243c61f7931da9f18ed5acd4920ea32c5",
    "diff": "diff --git a/simple-cam.cpp b/simple-cam.cpp\nindex e374e45849dc..71a715a0c27d 100644\n--- a/simple-cam.cpp\n+++ b/simple-cam.cpp\n@@ -163,13 +163,21 @@ int main()\n \t * Application lock usage of Camera by 'acquiring' them.\n \t * Once done with it, application shall similarly 'release' the Camera.\n \t *\n-\t * As an example, use the first available camera in the system.\n+\t * As an example, use the first available camera in the system after\n+\t * making sure that at least one camera is available.\n \t *\n \t * Cameras can be obtained by their ID or their index, to demonstrate\n \t * this, the following code gets the ID of the first camera; then gets\n \t * the camera associated with that ID (which is of course the same as\n \t * cm->cameras()[0]).\n \t */\n+\tif (cm->cameras().empty()) {\n+\t\tstd::cout << \"No cameras were identified on the system.\"\n+\t\t\t  << std::endl;\n+\t\tcm->stop();\n+\t\treturn EXIT_FAILURE;\n+\t}\n+\n \tstd::string cameraId = cm->cameras()[0]->id();\n \tcamera = cm->get(cameraId);\n \tcamera->acquire();\n@@ -386,13 +394,6 @@ int main()\n \tfor (std::unique_ptr<Request> &request : requests)\n \t\tcamera->queueRequest(request.get());\n \n-\tif (!cm->cameras().size()) {\n-\t\tstd::cout << \"No cameras were identified on the system.\"\n-\t\t\t  << std::endl;\n-\t\tcm->stop();\n-\t\treturn EXIT_FAILURE;\n-\t}\n-\n \t/*\n \t * --------------------------------------------------------------------\n \t * Run an EventLoop\n",
    "prefixes": [
        "libcamera-devel"
    ]
}