From d5cad318d9ac198d8aa1544234cb4d3c9c1488da Mon Sep 17 00:00:00 2001 From: rener2020 <76736114+rener2020@users.noreply.github.com> Date: Tue, 28 Oct 2025 20:35:53 +0800 Subject: [PATCH] Update Cdr.cpp: fix -Wconversion warning in options_[1] assignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix(Cdr): silence -Wconversion warning when updating options_[1] Explicitly cast arithmetic expression to uint8_t to prevent narrowing conversion warning in GCC/Clang: warning: conversion from ‘int’ to ‘std::array::value_type’ may change value [-Wconversion] The new expression keeps the same semantics while ensuring type safety: options_[1] = static_cast( static_cast(options_[1] & 0xC) + static_cast(alignment & 0x3) ); No behavioral change intended. Signed-off-by: rener2020 <76736114+rener2020@users.noreply.github.com> --- src/cpp/Cdr.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cpp/Cdr.cpp b/src/cpp/Cdr.cpp index c1a3a5e1..7e76373a 100644 --- a/src/cpp/Cdr.cpp +++ b/src/cpp/Cdr.cpp @@ -387,7 +387,10 @@ void Cdr::set_dds_cdr_options( { auto length {offset_ - cdr_buffer_.begin()}; auto alignment = ((length + 3u) & ~3u) - length; - options_[1] = static_cast(options_[1] & 0xC) + static_cast(alignment & 0x3); + options_[1] = static_cast( + static_cast(options_[1] & 0xC) + + static_cast(alignment & 0x3) + ); } if (encapsulation_serialized_ && CdrVersion::CORBA_CDR < cdr_version_)