---------- Forwarded message --------- From: Thibaut Cuvelier <tcuvel...@lyx.org> Date: Thu, 26 Oct 2023, 03:35 Subject: Fwd: New Defects reported by Coverity Scan for LyX To: LyX Developers <lyx-devel@lists.lyx.org>
Dear list, I am attaching a patch that fixes two Coverity warnings. Could anyone commit this to the Git repo (given I currently have no access to it)? As it was generated with git format-patch, it should be easy to do while keeping the commit message that explains the rationale behind the fix. Thanks in advance! Thibaut ---------- Forwarded message --------- From: <scan-ad...@coverity.com> Date: Thu, 19 Oct 2023 at 22:54 Subject: New Defects reported by Coverity Scan for LyX To: <dourou...@gmail.com> Hi, Please find the latest report on new defect(s) introduced to LyX found with Coverity Scan. 2 new defect(s) introduced to LyX found with Coverity Scan. New defect(s) Reported-by: Coverity Scan Showing 2 of 2 defect(s) ** CID 403673: Incorrect expression (IDENTICAL_BRANCHES) /home/lasgoutt/src/lyx/coverity/lyx/src/tex2lyx/text.cpp: 4351 in lyx::parse_text(lyx::Parser &, std::basic_ostream<char, std::char_traits<char>>&, unsigned int, bool, lyx::Context &, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> &, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> &)() ________________________________________________________________________________________________________ *** CID 403673: Incorrect expression (IDENTICAL_BRANCHES) /home/lasgoutt/src/lyx/coverity/lyx/src/tex2lyx/text.cpp: 4351 in lyx::parse_text(lyx::Parser &, std::basic_ostream<char, std::char_traits<char>>&, unsigned int, bool, lyx::Context &, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> &, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> &)() 4345 parse_text_snippet(p, os, FLAG_ITEM, outer, context); 4346 bool xcolorulem = LaTeXPackages::isAvailable("ulem") && 4347 LaTeXPackages::isAvailable("xcolor"); 4348 // No need to test for luatex, since luatex comes in 4349 // two flavours (dvi and pdf), like latex, and those 4350 // are detected by pdflatex. >>> CID 403673: Incorrect expression (IDENTICAL_BRANCHES) >>> The same code is executed regardless of whether "lyx::pdflatex || lyx::xetex" is true, because the 'then' and 'else' branches are identical. Should one of the branches be modified, or the entire 'if' statement replaced? 4351 if (pdflatex || xetex) { 4352 if (xcolorulem) { 4353 preamble.registerAutomaticallyLoadedPackage("ulem"); 4354 preamble.registerAutomaticallyLoadedPackage("xcolor"); 4355 } 4356 } else { ** CID 403672: Error handling issues (CHECKED_RETURN) /home/lasgoutt/src/lyx/coverity/lyx/src/insets/InsetInfo.cpp: 1587 in lyx::<unnamed>::xhtmlShortcutInfo(lyx::XMLStream &, const lyx::InsetInfoParams &)() ________________________________________________________________________________________________________ *** CID 403672: Error handling issues (CHECKED_RETURN) /home/lasgoutt/src/lyx/coverity/lyx/src/insets/InsetInfo.cpp: 1587 in lyx::<unnamed>::xhtmlShortcutInfo(lyx::XMLStream &, const lyx::InsetInfoParams &)() 1581 string const lcode = params.lang->code(); 1582 docstring trans; 1583 for (size_t i = 0; i < sequence.length(); ++i) { 1584 char_type const c = sequence[i]; 1585 const auto keyMapping = keyToString.find(c); 1586 if (keyMapping != keyToString.end()) { >>> CID 403672: Error handling issues (CHECKED_RETURN) >>> Calling "translateString" without checking return value (as is done elsewhere 15 out of 18 times). 1587 translateString(from_ascii(keyMapping->second), trans, lcode); 1588 xs << trans; 1589 } else { 1590 xs << c; 1591 } 1592 ________________________________________________________________________________________________________ To view the defects in Coverity Scan visit, https://u15810271.ct.sendgrid.net/ls/click?upn=HRESupC-2F2Czv4BOaCWWCy7my0P0qcxCbhZ31OYv50yoTScfh6B8koVa-2BsXrqsH2r7zUmO9t1iEi-2FFYNyEDxxSQ-3D-3DsI5y_EaoV9iDrwluI0GGUrbM7yWAc9ILy2qIm0bzgdOF2o6OvKSta0m1PyhfKtFZpqs5rxkZ0WyT4tDIrKOVdRzCQUcgJBhEZL-2FoBWogZGuZsQC-2Bq0AbrFZDRbh6FzKvH7PuKIgIPnV5R1jUXR4Pa7I5qkEG-2FqT5uQIViXTNlHVpGxd3kG3fmlowNDXT2qSzXiuqPTFSxrInHD6j7Cz-2FWufFoDw-3D-3D To manage Coverity Scan email notifications for "dourou...@gmail.com", click https://u15810271.ct.sendgrid.net/ls/click?upn=HRESupC-2F2Czv4BOaCWWCy7my0P0qcxCbhZ31OYv50yped04pjJnmXOsUBtKYNIXxxF-2FO44sWaogU6jGZMVL91U2CAiKpstwf-2F8GS1cLm5bQFa2vNdaMB9I0sFa-2FifkyGPDQ9lPJpxrLzv5JkQQq3cko-2Bs4SC3hxsw-2BPRRBy49SI-3D7CxO_EaoV9iDrwluI0GGUrbM7yWAc9ILy2qIm0bzgdOF2o6OvKSta0m1PyhfKtFZpqs5rOv1mjtxIcNA1-2BLpFky2OOXQ6ExpkSk52MJq4xUJIfv7mlJOCFNj0N3zW2gF-2FyB4sS4owJvxQWsBtMLx1FOu06Mn9mxTRKUrRjoIP3llSsiz-2FzmYV8YrnO8QCCDcbvrPjEdlzbTKFt5-2Fbqvb9L58JtQ-3D-3D
From 469351fd8ca2a47bcf46367ba8fce57d76bb5686 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier <tcuvelier@lyx.org> Date: Thu, 26 Oct 2023 03:32:35 +0200 Subject: [PATCH] XHTML: fix Coverity warnings about return values of translateString. These values are ignored, as there is no specific action to perform if the translation fails: print the untranslated string in that case. Hence the cast to void, which should silence Coverity on these cases. --- src/insets/InsetInfo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/insets/InsetInfo.cpp b/src/insets/InsetInfo.cpp index 4b9277490d..2daab87330 100644 --- a/src/insets/InsetInfo.cpp +++ b/src/insets/InsetInfo.cpp @@ -1506,7 +1506,7 @@ void docbookShortcutInfo(XMLStream & xs, const InsetInfoParams & params) { for (char_type const c : sequence) { const auto keyMapping = keyToString.find(c); if (keyMapping != keyToString.end()) { - translateString(from_ascii(keyMapping->second), trans, lcode); + (void) translateString(from_ascii(keyMapping->second), trans, lcode); // db:keysym: symbolic name (like Page Up), unlike what is printed on the key (like // ⇞, ↑, ▲, PgUp, Page Up, etc.) @@ -1584,7 +1584,7 @@ void xhtmlShortcutInfo(XMLStream & xs, const InsetInfoParams & params) { char_type const c = sequence[i]; const auto keyMapping = keyToString.find(c); if (keyMapping != keyToString.end()) { - translateString(from_ascii(keyMapping->second), trans, lcode); + (void) translateString(from_ascii(keyMapping->second), trans, lcode); xs << trans; } else { xs << c; -- 2.41.0.windows.1
-- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel