ipa: rpi: imx500: Fix stringop-truncation warning

This warning is issued by the compiler because the strncpy copies across
the whole string array, leaving no place for the nul terminator. Fix it
by copying sizeof(str) - 1 elements.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
This commit is contained in:
Naushir Patuck
2025-04-25 08:43:27 +01:00
committed by Konsta
parent ad64f9e8cc
commit 7b1d459071

View File

@@ -246,7 +246,7 @@ void CamHelperImx500::parseInferenceData(libcamera::Span<const uint8_t> buffer,
exported.height = inputTensorInfo.height;
exported.numChannels = inputTensorInfo.channels;
strncpy(exported.networkName, inputTensorInfo.networkName.c_str(),
sizeof(exported.networkName));
sizeof(exported.networkName) - 1);
exported.networkName[sizeof(exported.networkName) - 1] = '\0';
metadata.set("cnn.input_tensor_info", exported);
metadata.set("cnn.input_tensor", std::move(inputTensorInfo.data));
@@ -279,7 +279,7 @@ void CamHelperImx500::parseInferenceData(libcamera::Span<const uint8_t> buffer,
<< "IMX500 output tensor info export failed, numTensors > MaxNumTensors";
}
strncpy(exported.networkName, outputTensorInfo.networkName.c_str(),
sizeof(exported.networkName));
sizeof(exported.networkName) - 1);
exported.networkName[sizeof(exported.networkName) - 1] = '\0';
metadata.set("cnn.output_tensor_info", exported);
metadata.set("cnn.output_tensor", std::move(outputTensorInfo.data));