[libcamera-devel] [PATCH v2] cam: file_sink: Fixes following errors with gcc-13
Eric Curtin
ecurtin at redhat.com
Tue Feb 14 13:14:49 CET 2023
../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<const libcamera::FrameMetadata::Plane>::operator[](i)'
92 | const FrameMetadata::Plane &meta = buffer->metadata().planes()[i];
| ^
cc1plus: all warnings being treated as errors
Co-developed-by: Khem Raj <raj.khem at gmail.com>
Signed-off-by: Eric Curtin <ecurtin at redhat.com>
---
Changes in v2:
- Added const
- Made patch mergeable by accounting for new directory structure
---
src/apps/cam/file_sink.cpp | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/apps/cam/file_sink.cpp b/src/apps/cam/file_sink.cpp
index b32aad24..d41569c9 100644
--- a/src/apps/cam/file_sink.cpp
+++ b/src/apps/cam/file_sink.cpp
@@ -114,13 +114,12 @@ 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];
-
+ const unsigned int bytesused = buffer->metadata().planes()[i].bytesused;
Span<uint8_t> data = image->data(i);
- unsigned int length = std::min<unsigned int>(meta.bytesused, data.size());
+ const unsigned int length = std::min<unsigned int>(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;
--
2.39.1
More information about the libcamera-devel
mailing list