Skip to content

Commit

Permalink
Silence false truncation warning
Browse files Browse the repository at this point in the history
We know we won't overflow here, because we've manually truncated the
input string already. But gcc can still complain, so we need to shut it
up by ignoring the return value.
  • Loading branch information
CendioOssman committed Feb 3, 2025
1 parent 88bcf57 commit 8b2d404
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions vncviewer/DesktopWindow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,11 @@ void DesktopWindow::setName(const char *name)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"

snprintf(windowNameStr, sizeof(windowNameStr),
labelFormat, truncatedName);
if (snprintf(windowNameStr, sizeof(windowNameStr), "%s - TigerVNC",
truncatedName) >= (int)sizeof(windowNameStr)) {
// This is just to shut up the compiler, as we've already made sure
// we won't truncate anything
}

#pragma GCC diagnostic pop

Expand Down

0 comments on commit 8b2d404

Please sign in to comment.