lxqt / qtermwidget

The terminal widget for QTerminal
https://lxqt.github.io
GNU General Public License v2.0
507 stars 255 forks source link

Silenced old compilation warnings #562

Closed tsujan closed 3 weeks ago

tsujan commented 4 weeks ago

Consulted Konsole's code fo char command[40];. Previously, this warning was shown:

…/qtermwidget/lib/Vt102Emulation.cpp: In member function ‘virtual void Konsole::Vt102Emulation::sendMouseEvent(int, int, int, int)’:
…/qtermwidget/lib/Vt102Emulation.cpp:949:56: warning: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size between 7 and 26 [-Wformat-truncation=]
  949 |         snprintf(command, sizeof(command), "\033[%d;%d;%dM", cb + 0x20, cx, cy);
      |                                                        ^~
…/qtermwidget/lib/Vt102Emulation.cpp:949:44: note: directive argument in the range [1, 2147483647]
  949 |         snprintf(command, sizeof(command), "\033[%d;%d;%dM", cb + 0x20, cx, cy);
      |                                            ^~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:970,
                 from /usr/include/c++/14.2.1/cstdio:42,
                 from …/qtermwidget/lib/Vt102Emulation.h:27,
                 from …/qtermwidget/lib/Vt102Emulation.cpp:24:
In function ‘int snprintf(char*, size_t, const char*, ...)’,
    inlined from ‘virtual void Konsole::Vt102Emulation::sendMouseEvent(int, int, int, int)’ at …/qtermwidget/lib/Vt102Emulation.cpp:949:17:
/usr/include/bits/stdio2.h:68:35: note: ‘__builtin___snprintf_chk’ output between 9 and 37 bytes into a destination of size 32
   68 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   69 |                                    __glibc_objsize (__s), __fmt,
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   70 |                                    __va_arg_pack ());
tsujan commented 4 weeks ago

@yan12125 Could you take a quick look at it? It's small.

yan12125 commented 3 weeks ago

Looks good, thanks!