Avoid recursion - #696
Conversation
| metadata.push_back({uri, string(ref["MimeType"]), std::move(tst)}); | ||
| }; | ||
| add("META-INF/ASiCArchiveManifest.xml", "text/xml"); | ||
| for(auto ref = doc/"DataObjectReference"; ref; ref++) |
Check notice
Code scanning / CodeQL
Declaration hides variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 12 months ago
To fix this problem, the name of the variable declared in the inner for-loop on line 87 should be changed so that it does not shadow the outer variable from line 80. The best approach is to rename the inner loop variable to something more descriptive, such as dataRef. This change only requires updating the loop variable to dataRef and updating all uses within the loop, which are currently ref. Since this for-loop is small, only a handful of places require the change:
- Line 87:
for(auto ref = ...; ref; ref++)→for(auto dataRef = ...; dataRef; dataRef++) - Lines 89, 91, 92: All instances of
ref["Rootfile"],ref["URI"],ref["MimeType"]should be replaced withdataRef[... ]
No imports or other method/variable definitions are needed: only the use of the loop variable. All changes are to src/SignatureTST.cpp in the region of lines 87–94.
| @@ -84,12 +84,12 @@ | ||
| metadata.emplace_back(std::move(uri), string(ref["MimeType"]), std::move(tst)); | ||
| file.clear(); | ||
|
|
||
| for(auto ref = doc/"DataObjectReference"; ref; ref++) | ||
| for(auto dataRef = doc/"DataObjectReference"; dataRef; dataRef++) | ||
| { | ||
| if(ref["Rootfile"] == "true") | ||
| if(dataRef["Rootfile"] == "true") | ||
| { | ||
| file = util::File::fromUriPath(ref["URI"]); | ||
| mime = ref["MimeType"]; | ||
| file = util::File::fromUriPath(dataRef["URI"]); | ||
| mime = dataRef["MimeType"]; | ||
| } | ||
| } | ||
| } |
IB-8611 Signed-off-by: Raul Metsma <raul@metsma.ee>
IB-8611
Signed-off-by: Raul Metsma raul@metsma.ee