From patchwork Tue Jan 24 19:37:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khem Raj X-Patchwork-Id: 18192 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id CB0C0BEFBE for ; Tue, 24 Jan 2023 19:37:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 25EB4625E4; Tue, 24 Jan 2023 20:37:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674589060; bh=6wOaJB2Bm7f7VAoR0zup9Hpsic4xEg1BGQRbJTjn2XQ=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=ZsWRXtzEjey6kCPEltmP99KKtUdY/WvYwxpX90IGrcjnJ8L2n3twgsoOGMCr1A/kh tLioDf/JJh7phW5KPng3mKwITUsJVzyN+T2XWe1n7tyfd+q8xWoKPiTJoVUD/r9J7h zQXZbLp1Pufyq7TKo+omfVB2MXIo3G+VHRJ42QDpkjWEioLVrakB4ULlEcEnzQW+LC pJdjV/kEfqxgEgkksdQAwGw2z5NE6baYcJfE5yEFnaZ0f5fQgxuVjAxEXeUqQHRQLW AofWR2kteKZf3lrlRzq4oGZSMtSfP1ZCQRHxEUMVypB1DzrlEOlofsMdnLnBLp2XyV h/rspmuQ76QsQ== Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EFE10603D8 for ; Tue, 24 Jan 2023 20:37:38 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="G+vIghnp"; dkim-atps=neutral Received: by mail-pj1-x1034.google.com with SMTP id h5-20020a17090a9c0500b0022bb85eb35dso10653248pjp.3 for ; Tue, 24 Jan 2023 11:37:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=XYObCYTp7zgHbjmCw+6WCGL8Of5FyJc3TV0T19ps01U=; b=G+vIghnp7n4wgE+lwLPPOt8mLX1dNJUOicm2HJmWW5aalzLxGiHNRrZor3UXlLHxot OLii/RAaXx9NH68lTSkyFuaqfyqj/qcsDmRL+vXPBpQKeUFcJDTXwvyK1uqFDsor/5L/ W0P1/1ceD5Dm444qIjOa5s4ZUjJHJiScWm9pmN6Nj1eza5/KN5ryo7Md1lKu+31fKYJc CCBhThf/C+c6ZyfPv+wqZECIt4jJtGfpNZ6Re/WO7DiaHJbmo6lqs4MZt4Ck1LXy0twO CaS53N5CSfzUxx0OZDrPkIBJblX0Y2Yp8+MymYuL3ObxpRcURs+pDYwgvjwtgBVTX4PV wILA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XYObCYTp7zgHbjmCw+6WCGL8Of5FyJc3TV0T19ps01U=; b=RJt22xeItVP1ySyg0oAcFpA7FPHJKnmfc2T2WY1UzhewYYbxx2BKR0nVD9/WGFG9Ki FRuPpjsOXcBv1vJn+0mb/4nM10jTVpnjDtfFfuD2PyW82GmtFoCId4EFILNP/j/JJ4aR bk6ayuxxC9MTpDNe80Fu1X9JEfv1DGLp/UaPHf+0bajzZgJm95uR3v3PlyWQIgl3bxtc hXwnNjGSD1RMbBUvYmPuMPUTsUEtSqcse9gp3PgF17nc76BQY4UQUPJBmmq8T+YKXPfj yaRkzseV64DdPOtlBE7S0qr0aq7kVkouxpfMd7QQaRnblCdtfeHAna37thjtiqxNUU6t iH8A== X-Gm-Message-State: AFqh2kpkJ8X9IxbY9LGSv4jJwHjJULT+6sUjx24HQV3YtA5/2YMS1Z52 LzzL0zly6ixr7NVNUXNxjc1Uskv9aMQNJw== X-Google-Smtp-Source: AMrXdXsg5IY5/XumTLea1MuAzZQqdO+GobtTw4AK1vyN4cn9IyoOGntTCR5lrH8SOeedFPTxDTTsfQ== X-Received: by 2002:a17:902:6b4b:b0:194:a1f6:65b6 with SMTP id g11-20020a1709026b4b00b00194a1f665b6mr32162347plt.41.1674589056669; Tue, 24 Jan 2023 11:37:36 -0800 (PST) Received: from apollo.hsd1.ca.comcast.net ([2601:646:9181:1cf0::aee3]) by smtp.gmail.com with ESMTPSA id a23-20020a1709027d9700b00187033cac81sm2033203plm.145.2023.01.24.11.37.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jan 2023 11:37:36 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 24 Jan 2023 11:37:33 -0800 Message-Id: <20230124193733.3153431-1-raj.khem@gmail.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] file_sink.cpp: Avoid dangling-reference X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Khem Raj via libcamera-devel From: Khem Raj Reply-To: Khem Raj Cc: Khem Raj Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Fixes following errors with gcc-13 ../git/src/cam/file_sink.cpp:92:45: error: possibly dangling reference to a temporary [-Werror=dangling-reference] 92 | const FrameMetadata::Plane &meta = buffer->metadata().planes()[i]; | ^~~~ ../git/src/cam/file_sink.cpp:92:81: note: the temporary was destroyed at the end of the full expression '(& buffer->libcamera::FrameBuffer::metadata())->libcamera::FrameMetadata::planes().libcamera::Span::operator[](i)' 92 | const FrameMetadata::Plane &meta = buffer->metadata().planes()[i]; | ^ cc1plus: all warnings being treated as errors Upstream-Status: Submitted [https://lists.libcamera.org/pipermail/libcamera-devel/2023-January/036575.html] Signed-off-by: Khem Raj --- v2: Rebase on tip of trunk src/apps/cam/file_sink.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/apps/cam/file_sink.cpp b/src/apps/cam/file_sink.cpp index b32aad24..9f4c5648 100644 --- a/src/apps/cam/file_sink.cpp +++ b/src/apps/cam/file_sink.cpp @@ -114,13 +114,13 @@ void FileSink::writeBuffer(const Stream *stream, FrameBuffer *buffer, } for (unsigned int i = 0; i < buffer->planes().size(); ++i) { - const FrameMetadata::Plane &meta = buffer->metadata().planes()[i]; + unsigned int bytesused = buffer->metadata().planes()[i].bytesused; Span data = image->data(i); - unsigned int length = std::min(meta.bytesused, data.size()); + unsigned int length = std::min(bytesused, data.size()); - if (meta.bytesused > data.size()) - std::cerr << "payload size " << meta.bytesused + if (bytesused > data.size()) + std::cerr << "payload size " << bytesused << " larger than plane size " << data.size() << std::endl;