Patch Detail
Show a patch.
GET /api/patches/134/?format=api
{ "id": 134, "url": "https://patchwork.libcamera.org/api/patches/134/?format=api", "web_url": "https://patchwork.libcamera.org/patch/134/", "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": "<20190102120256.7769-2-jacopo@jmondi.org>", "date": "2019-01-02T12:02:56", "name": "[libcamera-devel,2/2] libcamera: Use 'struct' for structure types", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "9cad920e2eae3a1d7aef4690b85a530013a1ec32", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/134/mbox/", "series": [ { "id": 50, "url": "https://patchwork.libcamera.org/api/series/50/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=50", "date": "2019-01-02T12:02:55", "name": "[libcamera-devel,1/2] libcamera: media_device: Minor cleanup in findInterface()", "version": 1, "mbox": "https://patchwork.libcamera.org/series/50/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/134/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/134/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[217.70.183.198])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1248960B0C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 2 Jan 2019 13:02:58 +0100 (CET)", "from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 9AFD9C000A;\n\tWed, 2 Jan 2019 12:02:57 +0000 (UTC)" ], "X-Originating-IP": "2.224.242.101", "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 2 Jan 2019 13:02:56 +0100", "Message-Id": "<20190102120256.7769-2-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20190102120256.7769-1-jacopo@jmondi.org>", "References": "<20190102120256.7769-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 2/2] libcamera: Use 'struct' for structure\n\ttypes", "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": "Wed, 02 Jan 2019 12:02:58 -0000" }, "content": "Add back the 'struct' keyword for structure types.\nC++ allows omitting the 'struct' keywork. Add it back to make clear\nwe're dealing with structures and not class types.\n\nWhile at there re-align lines to first open brace, or angular brace for\ncasts, and re-sort lines to have the longest one first in populate()\nfunction.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/media_device.cpp | 33 ++++++++++++++++-----------------\n 1 file changed, 16 insertions(+), 17 deletions(-)\n\n--\n2.20.1", "diff": "diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\nindex 34206c8..715d971 100644\n--- a/src/libcamera/media_device.cpp\n+++ b/src/libcamera/media_device.cpp\n@@ -205,10 +205,10 @@ void MediaDevice::close()\n int MediaDevice::populate()\n {\n \tstruct media_v2_topology topology = { };\n+\tstruct media_v2_interface *interfaces = nullptr;\n \tstruct media_v2_entity *ents = nullptr;\n \tstruct media_v2_link *links = nullptr;\n \tstruct media_v2_pad *pads = nullptr;\n-\tstruct media_v2_interface *interfaces = nullptr;\n \t__u64 version = -1;\n \tint ret;\n\n@@ -219,10 +219,10 @@ int MediaDevice::populate()\n \t */\n \twhile (true) {\n \t\ttopology.topology_version = 0;\n+\t\ttopology.ptr_interfaces = reinterpret_cast<__u64>(interfaces);\n \t\ttopology.ptr_entities = reinterpret_cast<__u64>(ents);\n \t\ttopology.ptr_links = reinterpret_cast<__u64>(links);\n \t\ttopology.ptr_pads = reinterpret_cast<__u64>(pads);\n-\t\ttopology.ptr_interfaces = reinterpret_cast<__u64>(interfaces);\n\n \t\tret = ioctl(fd_, MEDIA_IOC_G_TOPOLOGY, &topology);\n \t\tif (ret < 0) {\n@@ -235,15 +235,15 @@ int MediaDevice::populate()\n \t\tif (version == topology.topology_version)\n \t\t\tbreak;\n\n+\t\tdelete[] interfaces;\n \t\tdelete[] links;\n \t\tdelete[] ents;\n \t\tdelete[] pads;\n-\t\tdelete[] interfaces;\n\n-\t\tents = new media_v2_entity[topology.num_entities];\n-\t\tlinks = new media_v2_link[topology.num_links];\n-\t\tpads = new media_v2_pad[topology.num_pads];\n-\t\tinterfaces = new media_v2_interface[topology.num_interfaces];\n+\t\tinterfaces = new struct media_v2_interface[topology.num_interfaces];\n+\t\tents = new struct media_v2_entity[topology.num_entities];\n+\t\tlinks = new struct media_v2_link[topology.num_links];\n+\t\tpads = new struct media_v2_pad[topology.num_pads];\n\n \t\tversion = topology.topology_version;\n \t}\n@@ -254,10 +254,10 @@ int MediaDevice::populate()\n \t populateLinks(topology))\n \t\tvalid_ = true;\n\n+\tdelete[] interfaces;\n \tdelete[] links;\n \tdelete[] ents;\n \tdelete[] pads;\n-\tdelete[] interfaces;\n\n \tif (!valid_) {\n \t\tclear();\n@@ -417,17 +417,16 @@ struct media_v2_interface *MediaDevice::findInterface(const struct media_v2_topo\n */\n bool MediaDevice::populateEntities(const struct media_v2_topology &topology)\n {\n-\tmedia_v2_entity *mediaEntities = reinterpret_cast<media_v2_entity *>\n-\t\t\t\t\t (topology.ptr_entities);\n+\tstruct media_v2_entity *mediaEntities = reinterpret_cast<struct media_v2_entity *>\n+\t\t\t\t\t\t\t\t(topology.ptr_entities);\n\n \tfor (unsigned int i = 0; i < topology.num_entities; ++i) {\n \t\t/*\n \t\t * Find the interface linked to this entity to get the device\n \t\t * node major and minor numbers.\n \t\t */\n-\t\tstruct media_v2_interface *iface =\n-\t\t\tfindInterface(topology, mediaEntities[i].id);\n-\n+\t\tstruct media_v2_interface *iface = findInterface(topology,\n+\t\t\t\t\t\t\t\t mediaEntities[i].id);\n \t\tMediaEntity *entity;\n \t\tif (iface)\n \t\t\tentity = new MediaEntity(&mediaEntities[i],\n@@ -449,8 +448,8 @@ bool MediaDevice::populateEntities(const struct media_v2_topology &topology)\n\n bool MediaDevice::populatePads(const struct media_v2_topology &topology)\n {\n-\tmedia_v2_pad *mediaPads = reinterpret_cast<media_v2_pad *>\n-\t\t\t\t (topology.ptr_pads);\n+\tstruct media_v2_pad *mediaPads = reinterpret_cast<struct media_v2_pad *>\n+\t\t\t\t\t\t\t (topology.ptr_pads);\n\n \tfor (unsigned int i = 0; i < topology.num_pads; ++i) {\n \t\tunsigned int entity_id = mediaPads[i].entity_id;\n@@ -478,8 +477,8 @@ bool MediaDevice::populatePads(const struct media_v2_topology &topology)\n\n bool MediaDevice::populateLinks(const struct media_v2_topology &topology)\n {\n-\tmedia_v2_link *mediaLinks = reinterpret_cast<media_v2_link *>\n-\t\t\t\t (topology.ptr_links);\n+\tstruct media_v2_link *mediaLinks = reinterpret_cast<struct media_v2_link *>\n+\t\t\t\t\t\t\t (topology.ptr_links);\n\n \tfor (unsigned int i = 0; i < topology.num_links; ++i) {\n \t\t/*\n", "prefixes": [ "libcamera-devel", "2/2" ] }