[{"id":4851,"web_url":"https://patchwork.libcamera.org/comment/4851/","msgid":"<20200519134457.GH470768@oden.dyn.berto.se>","date":"2020-05-19T13:44:57","subject":"Re: [libcamera-devel] [PATCH 3/3] libcamera: v4l2_videodevice: Use\n\tFileDescriptor \"fd move\" constructor","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your work.\n\nOn 2020-05-18 19:48:04 +0300, Laurent Pinchart wrote:\n> Use the newly added \"fd move\" constructor of the FileDescriptor class to\n> avoid dup() + close().\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/libcamera/v4l2_videodevice.cpp | 9 +--------\n>  1 file changed, 1 insertion(+), 8 deletions(-)\n> \n> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> index fbe55bc6f54f..3614b2ed1cbc 100644\n> --- a/src/libcamera/v4l2_videodevice.cpp\n> +++ b/src/libcamera/v4l2_videodevice.cpp\n> @@ -1276,14 +1276,7 @@ FileDescriptor V4L2VideoDevice::exportDmabufFd(unsigned int index,\n>  \t\treturn FileDescriptor();\n>  \t}\n>  \n> -\tFileDescriptor fd(expbuf.fd);\n> -\t/*\n> -\t * FileDescriptor takes a duplicate of fd, so we must close the\n> -\t * original here, otherwise it will be left dangling.\n> -\t */\n> -\t::close(expbuf.fd);\n> -\n> -\treturn fd;\n> +\treturn FileDescriptor(std::move(expbuf.fd));\n>  }\n>  \n>  /**\n> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lf1-x143.google.com (mail-lf1-x143.google.com\n\t[IPv6:2a00:1450:4864:20::143])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 284D6603D9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 May 2020 15:44:59 +0200 (CEST)","by mail-lf1-x143.google.com with SMTP id c12so7824959lfc.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 May 2020 06:44:59 -0700 (PDT)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\tn8sm8653116lfb.20.2020.05.19.06.44.57\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 19 May 2020 06:44:57 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com header.b=\"H13EHqyM\"; \n\tdkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=3o2AqOTM851dDEs8gBwbe9NUjYM22w50WMoEVKjWiJA=;\n\tb=H13EHqyMBmqAc521qEuCdZUBCZHCBPv7UiRp5IM1cbhvetekU1BSTTHARnhyDkYgmj\n\tOtVPKprJGW2QYeSjlstLdQWqCwfq5TNcEuHBOKx9E8JvvKOJ0Ab00rhpeptkXXnXBY9q\n\tB5GQRFrSTkPDuswsAqThp67ZUZoqItEq9q/9lGldMHTRuDoXhUnQStFEEpn5XFSDFfUZ\n\t4LW1yxv8FuOa2ph/GP/dbrVIJeVmEg+pAXUidXEuuXSfkN3ECzEaupa0+TFB6uLf/6j8\n\tAUrLctZvZCpKCDRXFovxKmmBQGKDBaxVfauMB8+BQr8z+XhD1nckv7J5HoaOyZn1byvM\n\tlw2A==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=3o2AqOTM851dDEs8gBwbe9NUjYM22w50WMoEVKjWiJA=;\n\tb=KD+TMDU5AcZI2WVPKvBrJ+oJAIRkPSbYbKVzLt7aMrYEyH4SxcXaaP7RIZo8HIkcmO\n\tNNLKd4Oz5hcl7cW1wzUVQXHyYrC4RkMEO3tcc+W5xsecCD1TLNUczqiNKNQfIUiqUHQ1\n\tPmwEMhIFjqFdZ3aMNjIz5mh+qOoX20l5ucUGLmhXV5n1c0VGIRT02fvCSBdANoQTkw4z\n\twCoZZBv86a9xPt0hewaKC8iYdRTBgfdjoYtyAbCLbIJtNGc9z0UbjYrlVUhYQ/N0mXRU\n\tDeF08d5/21k7rA3IJhy3CLZuwoRR0TlwIX55hm04vi5ZOpYf5oj64g4tDUUubXxcXazx\n\tWMGQ==","X-Gm-Message-State":"AOAM532o1LbkumCSlQUQCxVdh3Ou4GAW0imQDGK70OBA4JeIOafs4PhG\n\tIMAG2NeFPkisUDRiFQQpABmJVw==","X-Google-Smtp-Source":"ABdhPJwReYsIgXeDli2zy8VDntmXDla5BJ+HIO0QsnHF1DeDReZF+lEYuANJMhVeex/Dxhbs1yRBOg==","X-Received":"by 2002:a19:3817:: with SMTP id f23mr14946604lfa.6.1589895898510;\n\tTue, 19 May 2020 06:44:58 -0700 (PDT)","Date":"Tue, 19 May 2020 15:44:57 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200519134457.GH470768@oden.dyn.berto.se>","References":"<20200518164804.10088-1-laurent.pinchart@ideasonboard.com>\n\t<20200518164804.10088-3-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200518164804.10088-3-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 3/3] libcamera: v4l2_videodevice: Use\n\tFileDescriptor \"fd move\" constructor","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":"Tue, 19 May 2020 13:44:59 -0000"}},{"id":4866,"web_url":"https://patchwork.libcamera.org/comment/4866/","msgid":"<CAEmqJPqWzb12-XE=1XGBPH9o6Ao+q4kjw=aSjzsXnJNg5NH+gw@mail.gmail.com>","date":"2020-05-19T14:41:29","subject":"Re: [libcamera-devel] [PATCH 3/3] libcamera: v4l2_videodevice: Use\n\tFileDescriptor \"fd move\" constructor","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi Laurent,\n\nOn Mon, 18 May 2020 at 17:48, Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Use the newly added \"fd move\" constructor of the FileDescriptor class to\n> avoid dup() + close().\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n\n> ---\n>  src/libcamera/v4l2_videodevice.cpp | 9 +--------\n>  1 file changed, 1 insertion(+), 8 deletions(-)\n>\n> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> index fbe55bc6f54f..3614b2ed1cbc 100644\n> --- a/src/libcamera/v4l2_videodevice.cpp\n> +++ b/src/libcamera/v4l2_videodevice.cpp\n> @@ -1276,14 +1276,7 @@ FileDescriptor V4L2VideoDevice::exportDmabufFd(unsigned int index,\n>                 return FileDescriptor();\n>         }\n>\n> -       FileDescriptor fd(expbuf.fd);\n> -       /*\n> -        * FileDescriptor takes a duplicate of fd, so we must close the\n> -        * original here, otherwise it will be left dangling.\n> -        */\n> -       ::close(expbuf.fd);\n> -\n> -       return fd;\n> +       return FileDescriptor(std::move(expbuf.fd));\n>  }\n>\n>  /**\n> --\n> Regards,\n>\n> Laurent Pinchart\n>","headers":{"Return-Path":"<naush@raspberrypi.com>","Received":["from mail-lj1-x241.google.com (mail-lj1-x241.google.com\n\t[IPv6:2a00:1450:4864:20::241])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8EDE9603D9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 May 2020 16:41:45 +0200 (CEST)","by mail-lj1-x241.google.com with SMTP id g1so13985463ljk.7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 May 2020 07:41:45 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"XUTEkhUe\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=LKbPwb4D0VmZqYYTWKu0hfLAsuufTaOgbVsON+pvP9o=;\n\tb=XUTEkhUe4x1842PIH1mfKUcy51Gbm8CTndQJMKL2t9h4ZachOrTntWGRVA4C+RRQLB\n\tdB73WqM7oyVKJjvP7G4bWXqTZB3nvSKTooQfpbPiMJnxISy2OHwK8dUWHHkBPpNsvl5F\n\t02gKY9c4sM2Ggxpoo1LWy4xJHWXOX9LNTqd0J26LEuGBiBXe1W6RZiMe+u9yeJvAdhhb\n\thwKVRkF8xQdIq3IT0fhu1HbK3CrI4U/WHwshLaOH4sW+GwDepMP6Ivjlsa/lw5dEQwvE\n\tCUoHHDcCevxtAwqXXFe1h9Te+ZV7id0vT81rDNhq4y10M/ChQ+ydijMJs7ul9pRNwM3E\n\tXtQA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=LKbPwb4D0VmZqYYTWKu0hfLAsuufTaOgbVsON+pvP9o=;\n\tb=Jh2GfMQMKUC9OL2GGPhCy4R+FYgkcq275L0hBYS/1FqSE7/tuFOGrMeVuFIJAISkWr\n\tP6yGgtttnC9SldLLiBRSKRcwt6JYE0mnNmEJC8v75keSNGRihBU0sANGfauOjnFh6/FJ\n\txPS2E/bWVKrEyFHIMxIhiJfPymknJ7qaszdQ1Zd2ElAzzMBFLFaunn4niqzKARMlVdVJ\n\txQuZUA021BtvlJvS8prFcYcT7E9SLEFlkNH2K86sGwqSZoSmH2rVLMtqcxUOmQAd3g0k\n\t4aVOcaVsRkLQ14lB5/4nz+ttwSFjju5uE1CSmiX5YpFptn6f1Ci4HoMYI6uh0ns7UHQA\n\tVhVQ==","X-Gm-Message-State":"AOAM531Dpdt/tKJXQ0/eh3vHhvLJQKBRGFO4FSI3A7GnwEnutzaLMO0/\n\tQoAlsh7BqoTGirN6uUGgHgy7yw/TQ4cdCWtC5F4wEJNdiybD/w==","X-Google-Smtp-Source":"ABdhPJyk6nRci99CNZ3W2BG045q+yLU+AlVmXFJRbp/klXQ5n0YJMF4aFG0ZnIHYc8aorOnCGPvccjb78N70FwqbYBk=","X-Received":"by 2002:a05:651c:11cf:: with SMTP id\n\tz15mr13276547ljo.90.1589899304905; \n\tTue, 19 May 2020 07:41:44 -0700 (PDT)","MIME-Version":"1.0","References":"<20200518164804.10088-1-laurent.pinchart@ideasonboard.com>\n\t<20200518164804.10088-3-laurent.pinchart@ideasonboard.com>","In-Reply-To":"<20200518164804.10088-3-laurent.pinchart@ideasonboard.com>","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Tue, 19 May 2020 15:41:29 +0100","Message-ID":"<CAEmqJPqWzb12-XE=1XGBPH9o6Ao+q4kjw=aSjzsXnJNg5NH+gw@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH 3/3] libcamera: v4l2_videodevice: Use\n\tFileDescriptor \"fd move\" constructor","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":"Tue, 19 May 2020 14:41:45 -0000"}}]