From b40ca53f130144117539e1729d6e57cfb1ead830 Mon Sep 17 00:00:00 2001 From: Phenom Date: Sat, 9 May 2020 14:32:48 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20warning:=20=E2=80=98n=E2=80=99=20may=20be?= =?UTF-8?q?=20used=20uninitialized=20in=20this=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ../../../trunk/libretroshare/src/rsitems/rsmsgitems.cc: In member function ‘virtual void RsMsgTags::serial_process(RsGenericSerializer::SerializeJob, RsGenericSerializer::SerializeContext&)’: ../../../trunk/libretroshare/src/rsitems/rsmsgitems.cc:93:22: warning: ‘n’ may be used uninitialized in this function [-Wmaybe-uninitialized] 93 | uint32_t n ; | ^ --- libretroshare/src/rsitems/rsmsgitems.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libretroshare/src/rsitems/rsmsgitems.cc b/libretroshare/src/rsitems/rsmsgitems.cc index fa4991b8c..8060248f4 100644 --- a/libretroshare/src/rsitems/rsmsgitems.cc +++ b/libretroshare/src/rsitems/rsmsgitems.cc @@ -83,19 +83,19 @@ void RsMsgTagType::serial_process(RsGenericSerializer::SerializeJob j,RsGenericS void RsMsgTags::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) { - RsTypeSerializer::serial_process(j,ctx,msgId,"msgId") ; + RsTypeSerializer::serial_process(j,ctx,msgId,"msgId") ; #warning this is not the correct way to serialise here. We should directly call serial_process >() but for backward compatibility, we cannot - if(j == RsGenericSerializer::DESERIALIZE) - while(ctx.mOffset < ctx.mSize) - { - uint32_t n ; + if(j == RsGenericSerializer::DESERIALIZE) + while(ctx.mOffset < ctx.mSize) + { + uint32_t n = 0;// No real need to initialize but otherwise the compiler complains. RsTypeSerializer::serial_process(j,ctx,n,"tagIds element") ; tagIds.push_back(n) ; - } - else - for(std::list::iterator it(tagIds.begin());it!=tagIds.end();++it) + } + else + for(std::list::iterator it(tagIds.begin());it!=tagIds.end();++it) RsTypeSerializer::serial_process(j,ctx,*it,"tagIds element") ; }