mate-desktop / mate-terminal

The MATE Terminal Emulator
http://www.mate-desktop.org
GNU General Public License v3.0
133 stars 73 forks source link

terminal-encoding: Remove -Wformat warning #343

Closed rbuj closed 4 years ago

rbuj commented 4 years ago

Test

$ ./autogen.sh --prefix=/usr --enable-compile-warnings=maximum --enable-debug && make &> make.log
$ grep -A 2 Wformat make.log 

Removed warnings

terminal-encoding.c:251:27: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘gsize’ {aka ‘long unsigned int’} [-Wformat=]
  251 |                           " output \"%s\" bytes read %u written %u\n",
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
terminal-encoding.c:251:27: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 4 has type ‘gsize’ {aka ‘long unsigned int’} [-Wformat=]
  251 |                           " output \"%s\" bytes read %u written %u\n",
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
raveit65 commented 4 years ago

Aha, the parameter --debug is needed to see the warning. For that reason you won't find the warning at current travis build from master.

monsta commented 4 years ago

Well, technically, since it's like a size_t, we need different modifiers for 32-bit and 64-bit systems. The manual tells there are G_GSIZE_MODIFIER and/or G_GSIZE_FORMAT: https://developer.gnome.org/glib/stable/glib-Basic-Types.html#gsize

(check these macros in /usr/lib/.../glib-2.0/include/glibconfig.h for the actual values)

rbuj commented 4 years ago

@monsta done.

test: open Add or Remove Terminal Encodings dialog

$ MATE_TERMINAL_DEBUG="encodings" mate-ternimal
<cut>
Rejecting encoding IBM864 as invalid:
 input  " !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
 output "(null)" bytes read 5 written 5
 Error: Invalid byte sequence in conversion input
Encoding ISO-8859-13 is valid
<cut>

Screenshot at 2020-04-28 22-07-37