[Geany-Devel] Plugins Quality Check

Colomban Wendling lists.ban at xxxxx
Thu Feb 20 15:02:36 UTC 2014


Le 20/02/2014 09:07, Lex Trotman a écrit :
> [...]
> geanygendoc - 2 warnings, extra switch case may be consequential,
> unused function
> [...]
> 
> Unused functions and variables are probably inconsequential, unless
> they are the result of a typo in the code meant to use them, they need
> a quick check and correct.

In geanygendoc, it was simply dead code because of a quick
fix/workaround.  Removed, since anyway that code, while providing
interesting (unused) feature, wasn't working properly.  And well, we
have a VCS anyway to get back removed stuff if needed.

> Extra switch case may indicate a typo, needs checking.

But actually it doesn't.  It's due to the fact
g_scanner_get_next_token() returns an enumeration type, while actually
it should probably be an integer.  This function returns the next token
type, and this can be any character, plus a few extra, and is
implemented as an enumeration with a gap for naked bytes:

enum {
  /* few named bytes for convenience */
  EOF = 0;
  BRACE_OPEN = '{';
  BRACE_CLOSE = '}';
  /* ... */
  EXTRA_STUFF = 256;
  /* ... */
}

This relies on the enumeration type to be implemented as an integer and
implicitly accept intermediate values.

I "fixed" this by casting the return type to integer, but now in place of

> ggd-file-type-loader.c: In function 'ggd_file_type_read_match':
> ggd-file-type-loader.c:412:11: warning: case value '46' not in enumerated type 'GTokenType' [-Wswitch]
>            case '.': /* skip it */ break;

I get

> ggd-file-type-loader.c: In function 'ggd_file_type_read_match':
> ggd-file-type-loader.c:411:17: warning: cast from function call of type 'GTokenType' to non-matching type 'unsigned int' [-Wbad-function-cast]
>          switch ((guint) g_scanner_get_next_token (scanner)) {

way better, right?  So what can I tell you, get the GLib fixed? :)


Cheers,
Colomban


More information about the Devel mailing list