After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 752288 - value in values: Params of the search function should be const
value in values: Params of the search function should be const
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Code Generator
unspecified
Other All
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2015-07-12 13:08 UTC by Adrien Plazas
Modified: 2018-05-22 15:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Use const pointers for the needle parameters in array_contains functions (1.10 KB, patch)
2015-10-29 21:24 UTC, Timm Bäder
none Details | Review

Description Adrien Plazas 2015-07-12 13:08:37 UTC
To compile this vala code:

    if (value in values)

where value is a string and values a string[], valac generated a function whose prototype is:
    static gboolean _vala_string_array_contains (gchar** stack, int stack_length, gchar* needle);

but the values it passes to the needle params is contant, and hence I got this error:

variable/Options.c: In function 'retro_option_set_current':
variable/Options.c:272:59: warning: passing argument 3 of '_vala_string_array_contains' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  if (_vala_string_array_contains (_tmp1_, _tmp1__length1, _tmp0_)) {
                                                           ^
variable/Options.c:253:17: note: expected 'gchar * {aka char *}' but argument is of type 'const gchar * {aka const char *}'
 static gboolean _vala_string_array_contains (gchar** stack, int stack_length, gchar* needle) {
                 ^

I would suggest to make the stack and needle parameters constant as they are never changed by the function.
Comment 1 Timm Bäder 2015-10-29 21:24:10 UTC
Created attachment 314428 [details] [review]
Use const pointers for the needle parameters in array_contains functions

Seems like using a const pointer for the needle is always fine, at least considering the generated type, which is also const. The stack however is not const when generated so that might need further changes.
Comment 2 GNOME Infrastructure Team 2018-05-22 15:25:04 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/504.