Commit Graph

7386 Commits

Author SHA1 Message Date
GOUJON Évan
d129395fe2 g_system_thread_new: Free a memory leak on error path 2021-07-23 22:21:11 +02:00
GOUJON Évan
bd779c96e9 glib/gtestutils: Introduce and use a test_cleanup function 2021-07-23 22:20:54 +02:00
GOUJON Évan
353f0b5235 glib/gtestutils: Introduce and use a g_test_suite_free function 2021-07-23 22:16:44 +02:00
GOUJON Évan
f0c0d8b67c glib/gtestutils: Introduce and use a g_test_case_free function 2021-07-23 22:10:08 +02:00
GOUJON Évan
0786031804 g_test_run: Introduce a clean up path once test suite ran 2021-07-23 22:05:52 +02:00
Emmanuel Fleury
5e0bcbf8fe Fix signedness warning in glib/grand.c
glib/grand.c:271:17: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'long long unsigned int'
   for (i = 0; i < G_N_ELEMENTS (seed); i++)
                 ^
2021-07-21 13:49:48 +02:00
Emmanuel Fleury
28dcec03e1 Fix cast from pointer to integer of different size warnings in glib/gthread-win32.c
glib/gthread-win32.c: In function 'g_private_get_impl':
glib/gthread-win32.c:310:16: warning: cast from pointer to integer of different size
   DWORD impl = (DWORD) key->p;
                ^
glib/gthread-win32.c:315:14: warning: cast from pointer to integer of different size
       impl = (DWORD) key->p;
              ^
glib/gthread-win32.c: In function 'SetThreadName':
glib/gthread-win32.c:596:60: warning: passing argument 4 of 'RaiseException' from incompatible pointer type
    RaiseException (EXCEPTION_SET_THREAD_NAME, 0, infosize, (DWORD *) &info);
                                                            ^~~~~~~~~~~~~~~
2021-07-21 13:49:48 +02:00
Philip Withnall
b5556a2c68 gspawn: Use CLOSE_RANGE_CLOEXEC if available
It’s a new flag added to `close_range()` in kernel 5.11, which will
allow us to speed up setting `CLOEXEC` on ranges of file descriptors.

This currently happens in some situations when executing a new binary
with `GSpawn`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-07-09 12:40:47 +01:00
Khem Raj
b71117d894 correctly use 3 parameters for close_range
libc implementation has 3 parameter e.g.
https://www.freebsd.org/cgi/man.cgi?query=close_range&sektion=2&format=html

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2021-07-08 17:26:43 -07:00
Philip Withnall
7743dc889b Merge branch 'issue-2058' into 'main'
win32: Check and avoid using TLS index 0

Closes #2058

See merge request GNOME/glib!2148
2021-07-08 11:27:17 +00:00
Philip Withnall
36fe868b05 Merge branch 'thread' into 'main'
GThreadPool: Add g_thread_pool_new_full()

Closes #121

See merge request GNOME/glib!2170
2021-07-02 14:35:18 +00:00
nitinosiris
75db4883fc GThreadPool: Add g_thread_pool_new_full()
g_thread_pool_new_full() is similar to g_thread_pool_new()
but with GDestroyNotify argument.

Closes #121
2021-07-02 18:42:59 +05:30
Philip Withnall
04e629e3fe gasyncqueue: Add missing (nullable) annotation to free function
As spotted by Nitin Wartkar in
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2170#note_1195878.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-07-01 17:35:57 +01:00
Philip Withnall
74595ab64a Merge branch 'wip/pwithnall/962-drop-embedded-pcre' into 'main'
pcre: Drop internal libpcre copy

Closes #962 and #642

See merge request GNOME/glib!2144
2021-06-21 14:07:45 +00:00
Philip Withnall
54154d68bf build: Drop unused pcre_objects+pcre_deps variables in meson.build
After the previous few commits, these are now redundant.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-06-16 16:45:10 +01:00
Philip Withnall
9570e67744 pcre: Drop internal libpcre copy
It’s no longer used and is a maintenance burden.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #962
2021-06-16 16:45:10 +01:00
Philip Withnall
9fbd7f3dc1 build: Drop the internal_pcre option in favour of the subproject
This should maintain equivalent functionality, apart from that now you
have to pass `--force-fallback-for libpcre` to `meson configure` in
order to use the subproject; rather than specifying
`-Dinternal_pcre=true` to use the internal copy.

This also fixes #642, as the wrapdb copy of libpcre is version 8.37.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #962
Fixes: #642
2021-06-16 16:45:10 +01:00
Philip Withnall
b63a3189e7 tests: Add a test for GBytes memory transfer with an odd free func
This is basically a contrived test to trigger the `bytes->user_data !=
bytes->data` condition (and none of the earlier short-circuiting
conditions in that statement) in `try_steal_and_unref()`. This gives
100% line and branch coverage for `gbytes.c`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-06-16 12:14:58 +01:00
Philip Withnall
fc7b316bc7 tests: Test that g_bytes_unref(NULL) is a no-op
It’s documented as such, and this marginally increases the code coverage
on `gbytes.c`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-06-16 12:14:57 +01:00
Philip Withnall
082c2117bb tests: Use g_assert_*() rather than g_assert() in bytes.c
`g_assert()` is compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-06-16 12:14:34 +01:00
Simon McVittie
b483013d02 spawn: Clarify the most common non-exit reason for process termination
A reader might think "how would a process terminate without an exit
status?", or equivalently, "what harm would it do if I assume every
termination has an exit status?" without this reminder that termination
with a signal is also reasonably common.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-15 14:33:17 +01:00
Simon McVittie
e0b6b8037d Distinguish more clearly between wait status and exit status
On Unix platforms, wait() and friends yield an integer that encodes
how the process exited. Confusingly, this is usually not the same as
the integer passed to exit() or returned from main(): conceptually it's
an integer encoding of this tagged union:

    enum { EXITED, SIGNALLED, ... } tag;
    union {
        int exit_status;         /* if EXITED */
        struct {
            int terminating_signal;
            bool core_dumped;
        } terminating_signal;    /* if SIGNALLED */
        ...
    } detail;

Meanwhile, on Windows, wait statuses and exit statuses are
interchangeable.

I find that it's clearer what is going on if we are consistent about
referring to the result of wait() as a "wait status", and the value
passed to exit() as an "exit status".

GSubprocess already gets this right: g_subprocess_get_status() returns
the wait status, while g_subprocess_get_exit_status() genuinely returns
the exit status. However, the GSpawn family of APIs has tended to
conflate the two.

Confusingly, g_spawn_check_exit_status() has always checked a wait
status, and it would not be correct to pass an exit status to it; so
let's deprecate it in favour of g_spawn_check_wait_status(), which
does the same thing that g_spawn_check_exit_status() always did.
Code that needs backwards-compatibility with older GLib can use:

    #if !GLIB_CHECK_VERSION(2, 69, 0)
    #define g_spawn_check_wait_status(x) (g_spawn_check_exit_status (x))
    #endif

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-06-15 14:33:14 +01:00
Nitin Wartkar
e3452ea01f GBytes: add range-checked pointer getter
Updated and improved by Nitin Wartkar.

Fixes: #1098
2021-06-15 12:01:11 +00:00
Simon McVittie
e7ebee5959 Merge branch 'bookmarkfile-test-tmp' into 'main'
tests: Use a temporary file in the bookmarkfile tests

See merge request GNOME/glib!2105
2021-06-14 15:47:42 +00:00
Evangelos Ribeiro Tzaras
708100c0a2 docs: Fix annotations for optional arguments
The length parameter in g_hash_table_get_keys_as_arrays() is optional and
this should be reflected in the gtk-doc annotations.
2021-06-11 15:19:17 +02:00
Yongsu Park
3364e02041 win32: Check and avoid using TLS index 0
Zero is a valid TLS index so it needs to be checked. It’s also the
integer used to indicate that no TLS has been allocated yet, so it can’t
be used as a TLS identifier.

Incorporates changes from Philip Withnall.

Fixes: #2058
2021-06-10 15:22:55 +01:00
Philip Withnall
c0fe89c986 Merge branch 'gtypeof' into 'main'
glib_typeof: Move definition to its own header

See merge request GNOME/glib!1969
2021-06-10 12:26:27 +00:00
Philip Withnall
71edc3ffe1 Merge branch 'fix_more_warnings' into 'main'
Fix more warnings

See merge request GNOME/glib!2119
2021-06-10 09:37:34 +00:00
Philip Withnall
b052620398 gregex: Fix return from g_match_info_fetch() for unmatched subpatterns
If there were more subpatterns in the regex than matches (which can
happen if one or more of the subpatterns are optional),
`g_match_info_fetch()` was erroneously returning `NULL` rather than the
empty string. It should only return `NULL` when the `match_num`
specifies a subpattern which doesn’t exist in the regex.

This is complicated slightly by the fact that when using
`g_regex_match_all()`, more matches can be returned than there are
subpatterns, due to one or more subpatterns matching multiple times at
different offsets in the string.

This includes a fix for a unit test which was erroneously checking the
broken behaviour.

Thanks to Allison Karlitskaya for the minimal reproducer.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #229
2021-06-09 14:39:20 +01:00
Philip Withnall
1891165e73 tests: Tweak whether a PCRE test is enabled
Rather than predicating the test on whether the system PCRE is being
used, use a more specific version comparison which should work
regardless of whether the system or internal copy of libpcre is being
used.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #962
2021-06-09 12:29:02 +01:00
Emmanuel Fleury
f4d6680f13 Fix dropped 'const' qualifier warning in glib/tests/once.c
glib/tests/once.c(199): warning C4090: 'function': different 'const' qualifiers
2021-06-09 11:11:06 +02:00
Emmanuel Fleury
6d8caf6482 Fix comparison of unsigned expression < 0 is always false warning in glib/gunicollate.c
glib/gunicollate.c:444:17: warning: comparison of unsigned expression < 0 is always false
          if (xfrm_len < 0 || xfrm_len >= G_MAXINT - 2)
              ~~~~~~~~ ^ ~
2021-06-09 11:11:06 +02:00
LRN
0908e6a8e7 Fix the math in copy_chars
Now we end up returning a pointer to the end of the buffer
after we run out of space. On subsequent calls copy_count will
end up being 0.
2021-06-08 08:38:59 +00:00
Руслан Ижбулатов
fbd7a37e1a Test the wchar_t version of pid-event subst routine
Also move env setup earlier in the test, to ensure that
the child gets the envvars during initialization.

Also, don't look for exception codes in stderr, since
OutputDebugStringA() doesn't dump stuff there.
2021-06-08 08:38:59 +00:00
Руслан Ижбулатов
5c187b9385 Convert the crash handler to UTF-16, mostly 2021-06-08 08:38:59 +00:00
Руслан Ижбулатов
6d9c3e3226 W32: Remove allocations from the crash handler
Use OutputDebugStringA() instead of fprintf.

The goal for this code is to inform the person running the debugger
about the exception that caused the debugger to be attached.
This is useful for debugging with gdb, because gdb does not catch Windows
exception information (it just displays "Segmentation fault").

OutputDebugStringA() ensures that the output goes to the debugger,
and the (ab)use of strcpy() with a stack-allocated buffer ensures
that we do not allocate anything while the crash handler is running,
nor to we call CRT functions that can be reasinably expected to allocate
anything.
2021-06-08 08:38:59 +00:00
Руслан Ижбулатов
891e3a0bba W32: Initialize debugger stuff in advance
Since VEH is invoked when an exception occurs (which, for us,
is mostly when the program is already crashing), we should
try to avoid doing much processing at that point. Since these
things (debugger commandline, a list of extra exceptions to catch)
are known in advance, set them up during initialization.
2021-06-08 08:38:59 +00:00
Руслан Ижбулатов
1955ede43b W32: Don't use g_getenv() in crash handler or during initialization
The first is to avoid any non-trivial code in the crash handler.
The second is to avoid the use of quarks and hash tables (brought
in by g_getenv()) during GLib initialization.
2021-06-08 08:38:59 +00:00
Emmanuele Bassi
ff8b43a154 Merge branch '2418-more-stupid-atomics' into 'main'
gbitlock: Drop unnecessary volatile qualifiers

Closes #2418

See merge request GNOME/glib!2131
2021-06-07 17:21:50 +00:00
Nitin Wartkar
b1d7a57cdf doc: example for GArray and g_array_set_clear_func() 2021-06-07 15:52:43 +00:00
Philip Withnall
1a43d950b4 docs: Update various external links to use HEAD instead of master
Update several links to allow the remote to use its configured default
branch name, rather than specifying `master` as the default branch name.
This will help avoid breakage if any of these projects rename their
default branch in the future.

Fix a few of the links where they were hitting redirects or had moved.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2348
2021-06-07 14:03:48 +01:00
Philip Withnall
942501bec7 gbitlock: Minor improvement to documentation formatting
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-06-03 15:15:34 +01:00
Philip Withnall
11cd751203 gbitlock: Drop unnecessary volatile qualifiers
This follows on from !1719. It drops volatile qualifiers on internal
functions in `gbitlock.c`, and casts volatile public arguments to
non-volatile versions to avoid the `g_atomic_*()` macros from
propagating the volatile qualifier.

We can’t drop the `volatile` qualifier from the public API in
`gbitlock.h`, as that would unfortunately be an API break.

Update the documentation in `gbitlock` to mention that users of the API
should not use `volatile`. See http://c.isvolatileusefulwiththreads.com/

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2418
2021-06-03 15:15:21 +01:00
Philip Withnall
91759dbd63 tests: Ignore warning about use of volatile from a test for exactly that
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #2418
2021-06-03 13:44:15 +01:00
Luke Yue
3321fb561e tests: Add a test case for g_find_program_in_path()
Signed-off-by: Luke Yue <lukedyue@gmail.com>
2021-06-02 20:10:38 +08:00
Luke Yue
dba1fce993 gutils: ensure g_find_program_in_path() return an absolute path
Fix a possibility of returning a relative path, according to the
doc, the function should return an absolute path.

Signed-off-by: Luke Yue <lukedyue@gmail.com>
2021-06-02 20:10:38 +08:00
Emmanuel Fleury
1e90d9cd74 Add test case for g_prefix_error_literal() function 2021-06-01 19:00:37 +02:00
Dan Williams
9cb1bb0fb2 Add g_prefix_error_literal()
Because sometimes you don't want a lone "%s", and you don't
want the compiler yelling at you about format strings that
don't have any format in them.

Closes #663
2021-05-28 17:15:46 +02:00
Emmanuel Fleury
bf536a5ce2 Fix incompatible pointer to integer conversion warning in glib/tests/atomic.c
lib/tests/atomic.c:115:9: warning: incompatible pointer to integer conversion passing 'void *' to parameter of type 'gsize' (aka 'unsigned long')
  res = g_atomic_pointer_compare_and_exchange (&gs, NULL, NULL);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
glib/gatomic.h:225:34: note: expanded from macro 'g_atomic_pointer_compare_and_exchange'
                                 (newval), FALSE,                            \
                                 ^~~~~~~~
2021-05-27 10:16:52 +02:00
Emmanuel Fleury
2b4bf535f1 Fix discard qualifier warning in glib/tests/atomic.c
glib/tests/atomic.c:132:18: warning: passing 'typeof (*(cspp)) *' (aka 'const int *const *') to parameter of type 'const gint **' (aka 'const int **') discards qualifiers
  g_assert_true (g_atomic_pointer_get (cspp) == csp);
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
glib/gatomic.h:117:38: note: expanded from macro 'g_atomic_pointer_get'
    __atomic_load (gapg_temp_atomic, (&(gapg_temp_newval)), __ATOMIC_SEQ_CST); \
                                     ^~~~~~~~~~~~~~~~~~~~~
2021-05-27 10:16:52 +02:00
alex-tee
232b40da7b gstrvbuilder: add addv and add_many to the API 2021-05-26 12:41:18 +00:00
Xavier Claessens
090d65712d glib_typeof: Move definition to its own header
It is cleaner to define glib_typeof() in a header included after
gversionmacros.h so we can use GLIB_VERSION_MIN_REQUIRED directly
instead of doing it everywhere glib_typeof() is used.
2021-05-17 12:07:30 -04:00
Philip Withnall
f71faad46b Merge branch 'th/gdbus-doc-unsubscribe-idle' into 'master'
gdbus: document completion after idle action for g_dbus_connection_signal_unsubscribe()

See merge request GNOME/glib!2050
2021-05-17 10:49:38 +00:00
Claes Nästén
d3207660bb glib spawn-singlethread test only if F_DUPFD_CLOEXEC is defined
F_DUPFD_CLOEXEC is not available on Solaris 10, no need to fail the
build instead skip the test as on non Unix platforms already.
2021-05-14 20:24:10 +02:00
Philip Withnall
e944cf8b1c Merge branch 'bookmarkfile-crash' into 'master'
gbookmarkfile: Don't crash if we're not visited

See merge request GNOME/glib!1514
2021-05-13 22:33:40 +00:00
Philip Withnall
447f727284 tests: Use a temporary file in the bookmarkfile tests
Rather than always writing to `out.xbel` in the build directory, which
could cause issues when running tests in parallel, or expecting the
tests to not touch the build directory.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-05-13 22:53:38 +01:00
Matthias Clasen
f3e65b1af7 gbookmarkfile: Don't crash if we're not visited
Rewrite bookmark_item_dump to not crash if any of
the timestamps is NULL. Also, avoid some of the gratitious
extra string copying.

Tweaked by Philip Withnall to pass the unit tests.
2021-05-13 22:50:34 +01:00
Philip Withnall
7e9585177d tests: Drop use of g_test_bug_base()
Include the base URI in the `g_test_bug()` calls instead. This resolves
inconsistencies between the old bug base (bugzilla.gnome.org) and the
new bug base (gitlab.gnome.org). It also has the advantage that the URI
passed to `g_test_bug()` is now clickable in the code editor, rather
than being split across two locations.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/275#note_303175

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-05-13 22:16:27 +01:00
Philip Withnall
46ab6821a3 gtestutils: Allow full URIs in g_test_bug()
Even if `g_test_bug_base()` has been called.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/275#note_303175

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-05-13 21:57:40 +01:00
Philip Withnall
0f7950f199 gtestutils: Improve documentation formatting for g_test_bug_base()
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-05-13 21:57:25 +01:00
Philip Withnall
82e2517257 Merge branch 'carlosgc/remove-dot-segments' into 'master'
guri: always apply the remove dot segments algorithm

Closes #2342

See merge request GNOME/glib!2084
2021-05-13 13:13:34 +00:00
Philip Withnall
53834ee319 Merge branch 'fix_more_warnings' into 'master'
Fix more warnings (clang)

See merge request GNOME/glib!2091
2021-05-13 12:04:42 +00:00
Philip Withnall
56ddba7c34 Merge branch 'serializ' into 'master'
docs: Standardize spelling of serializ*

Closes #2399

See merge request GNOME/glib!2096
2021-05-13 11:37:11 +00:00
Emmanuel Fleury
66af256621 Fix missing initializer warning in glib/tests/spawn-path-search-helper.c
glib/tests/spawn-path-search-helper.c:82:12: warning: missing field 'short_name' initializer
    { NULL }
           ^
2021-05-13 12:57:14 +02:00
Emmanuel Fleury
f9904fe7ae Fix missing initializers warnings in glib/tests/utf8-validate.c
glib/tests/utf8-validate.c:271:11: warning: missing field 'max_len' initializer
  { NULL, }
          ^
2021-05-13 12:57:14 +02:00
Emmanuel Fleury
c65ec0bfbf Fix many missing initializers warnings in glib/tests/option-context.c
glib/tests/option-context.c:36:10: warning: missing field 'short_name' initializer
  { NULL }
         ^
glib/tests/option-context.c:43:10: warning: missing field 'short_name' initializer
  { NULL }
         ^
glib/tests/option-context.c:319:14: warning: missing field 'short_name' initializer
      { NULL } };
             ^
...
           ^
glib/tests/option-context.c:2538:12: warning: missing field 'short_name' initializer
    { NULL }
           ^
glib/tests/option-context.c:2576:14: warning: missing field 'short_name' initializer
      { NULL } };
             ^
2021-05-13 12:57:14 +02:00
Emmanuel Fleury
f2d14a8770 Fix missing field initializer warning in glib/tests/option-argv0.c
glib/tests/option-argv0.c:38:14: warning: missing field 'short_name' initializer
      { NULL } };
             ^
2021-05-13 12:57:14 +02:00
Emmanuel Fleury
2e4524cd36 Add the G_OPTION_ENTRY_NULL macro to properly initialize GOptionEntry arrays 2021-05-13 12:57:06 +02:00
Philip Withnall
c0b339372c Merge branch 'mcatanzaro/string-test' into 'master'
tests: Add missing return value check in string test

See merge request GNOME/glib!2100
2021-05-11 22:27:44 +00:00
Michael Catanzaro
82d162da83 tests: Add missing return value check in string test
Coverity noticed that we were not testing the return value here. Good
Coverity!
2021-05-11 16:24:39 -05:00
Aleksandr Mezin
55f13da1f5 gmacros.h: G_NORETURN: remove useless checks
GCC >= 2.8 and MSVC >= 1200 are already handled by `#if` branches above. So:

- `(__GNUC__ == 4 && __GNUC_MINOR__ >= 7)` is always false here

- `!(__GNUC__ == 4 && __GNUC_MINOR__ == 7)` is always true

- `(_MSC_VER >= 1900)` is always false
2021-05-11 22:27:40 +06:00
Philip Withnall
4cd1a1c03d Merge branch 'optimise_g_atomic_ref_count_dec' into 'master'
grefcount: Optimise g_atomic_ref_count_dec

See merge request GNOME/glib!2098
2021-05-11 11:00:26 +00:00
Nishal Kulkarni
8cba1f4c17 grefcount: Optimise g_atomic_ref_count_dec
Currently, `g_atomic_ref_count_dec ()` does two operations.
We try to get this down to one operation.

Replace `g_atomic_int_dec_and_test ()` with `g_atomic_int_add ()`
Passing -1 as value.

Note: changes current behaviour, checks are now done after decrement.
2021-05-11 15:08:20 +05:30
Sebastian Dröge
ea4721422f Merge branch 'optimise_gatomicrefcount' into 'master'
grefcount: Optimise g_atomic_ref_count_inc

Closes #1583

See merge request GNOME/glib!2086
2021-05-11 07:27:24 +00:00
Geyslan G. Bem
6b867cd474 docs: Standardize spelling of serializ*
Changes serialis* to serializ*.

Fixes: #2399

Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
2021-05-10 15:28:12 -03:00
nitinosiris
15e3b9e219 glib: documentation of GSourceFuncs
Only finalize has a comment to indicate that it can be NULL
However, prepare and check can both be NULL too.

Fixes: 1864
2021-05-10 20:03:12 +05:30
Philip Withnall
2549187b18 Merge branch 'windows-known-folders' into 'master'
Use SHGetKnownFolderPath() on Windows

Closes #2397

See merge request GNOME/glib!2089
2021-05-10 14:13:01 +00:00
Thomas Haller
bdd6b753ca main: document notify function gets called during g_source_destroy()
This seems non-obvious to me. Document it.

It also seems important to know, because it means that the data pointer
might already be destroyed, before the source is unreferenced for good.
For example, if the data pointer keeps a reference to the GSource,
and it might seem sensible to call:

    g_source_destroy(data->source);
    g_source_unref(data->source); /* <<< data is already destroyed? */

This leads to a crash, if the source was attached to a context.
2021-05-10 13:16:05 +02:00
Nishal Kulkarni
827b4ec855 grefcount: Optimise g_atomic_ref_count_inc
Currently, `g_atomic_ref_count_inc ()` does three operations.
We try to get this down to one operation.

Fixed by replacing `g_atomic_int_inc ()` with `g_atomic_int_add ()`
which increments by 1 and returns old value

Note: changes current behaviour, checks are now done after increment.

Closes: #1583
2021-05-10 15:45:00 +05:30
Руслан Ижбулатов
d270d5b615 Use SHGetKnownFolderPath() on Windows
SHGetSpecialFolderLocation() can cause 200ms delays when getting some
folder locations.

Also, use SHGetKnownFolderPath() normally, without loading it at runtime,
since GLib is Windows 7-or-later now.

Fixes #2397
2021-05-07 12:33:51 +00:00
Emmanuel Fleury
9656e606d2 Fix cast to smaller integer type warning in glib/gscanner.c
glib/gscanner.c:1681:13: warning: cast to smaller integer type 'GTokenType' from 'gpointer' (aka 'void *')
        *token_p = (GTokenType) value_p->v_symbol;
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-05-06 23:07:04 +02:00
Emmanuel Fleury
83d46f6a0a Fix missing field initializer in glib/deprecated/gthread.h
glib/deprecated/gthread-deprecated.c:473:42: warning: missing field 'unused' initializer
  static const GStaticMutex init_mutex = G_STATIC_MUTEX_INIT;
                                         ^
glib/deprecated/gthread.h:128:36: note: expanded from macro 'G_STATIC_MUTEX_INIT'
                                   ^
glib/deprecated/gthread-deprecated.c:659:45: warning: missing field 'unused' initializer
  static const GStaticRecMutex init_mutex = G_STATIC_REC_MUTEX_INIT;
                                            ^
glib/deprecated/gthread.h:170:35: note: expanded from macro 'G_STATIC_REC_MUTEX_INIT'
                                  ^
glib/deprecated/gthread.h:128:36: note: expanded from macro 'G_STATIC_MUTEX_INIT'
                                   ^
glib/deprecated/gthread-deprecated.c:959:42: warning: missing field 'unused' initializer
  static const GStaticRWLock init_lock = G_STATIC_RW_LOCK_INIT;
                                         ^
glib/deprecated/gthread.h:206:33: note: expanded from macro 'G_STATIC_RW_LOCK_INIT'
                                ^
glib/deprecated/gthread.h:128:36: note: expanded from macro 'G_STATIC_MUTEX_INIT'
                                   ^
2021-05-06 22:54:53 +02:00
Carlos Garcia Campos
7e428aa4e5 guri: always apply the remove dot segments algorithm
And not only when g_uri_parse_relative() is called with a base uri. This
follows the spec and it's compatible with SoupURI.

Fixes #2342
2021-05-05 15:13:16 +02:00
Thomas Haller
10027a7cb6 guuid: fix shift operation to parse hex string in uuid_parse_string()
The actually parsed `@bytes` are not used because the only caller
does not provide an output parameter to request them. So this bug had
no effect in practice.
2021-05-03 15:09:31 +02:00
Robin Verdenal-Tallieux
514c2d8197 gmacros: Add __ to noinline to prevent conflict with macro in pixman
Fixes: #2388
2021-05-03 09:37:00 +00:00
Nishal Kulkarni
ad1fd7f998 test-printf: use G_GNUC_CHECK_VERSION
Replace `__GLIBC__` with `G_GNUC_CHECK_VERSION`
2021-04-29 17:39:54 +05:30
Nishal Kulkarni
6cc9899f3d gbitlock: use G_GNUC_CHECK_VERSION
Replace `__GLIBC__` with `G_GNUC_CHECK_VERSION`
2021-04-29 17:38:59 +05:30
Peter Bloomfield
ab62e655b3 gstring: Cleanup documentation of g_string_replace
Clean up the documentation of `g_string_replace()`'s `limit` parameter.
2021-04-27 18:55:17 -04:00
Marco Trevisan (Treviño)
11f31d8220 tests/pattern: Add compilation and copy test for utf-8 string
While we already tested this for matching we did not when copying, so
adding an expclit test for the utf8 case.
2021-04-27 16:25:09 +02:00
Marco Trevisan (Treviño)
37323239a0 gpattern: Adjust includes to match style rules 2021-04-27 16:25:09 +02:00
Marco Trevisan (Treviño)
fbb198f968 gpattern: Move match and match_string functions into GPatternSpec
This allows introspection to properly handle them as GPatternSpec
methods, as per this deprecate g_pattern_match() and
g_pattern_match_string() functions.
2021-04-27 16:25:09 +02:00
Marco Trevisan (Treviño)
474ece6d61 gpattern: Implement copy function
Add copy ability for pattern spec, so that it can be used as a boxed
type.
2021-04-27 16:25:09 +02:00
Ignacio Casal Quinteiro
03e614e6d5 gmacros: missing check if __STDC_VERSION__ is defined
This fixes warnings when compiling on old distros like centos 7
2021-04-27 13:11:42 +02:00
Sebastian Dröge
0b863a4ea9 Merge branch 'filename_max' into 'master'
Improve handling of FILENAME_MAX

See merge request GNOME/glib!2055
2021-04-23 08:40:21 +00:00
Ignacio Casal Quinteiro
2c97526c00 gmacros: check that __cplusplus or _MSC_VER is defined
Otherwise it will fail to compile in old distros like Centos 7
Fixes #2387
2021-04-23 10:10:48 +02:00
Philip Withnall
3131a6149e gdir: Add trailing nul delimiter to FILENAME_MAX
`FILENAME_MAX` is not guaranteed to include a trailing nul delimiter, so
explicitly add one.

See
https://www.gnu.org/software/libc/manual/html_node/Limits-for-Files.html:
`PATH_MAX` is explicitly defined to include a nul delimiter;
`FILENAME_MAX` is not.

See also https://twitter.com/pid_eins/status/1357008940886818822.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-04-19 19:24:08 +01:00
Philip Withnall
496135c569 dirent: Add trailing nul delimiter to FILENAME_MAX
`FILENAME_MAX` is not guaranteed to include a trailing nul delimiter, so
explicitly add one.

See
https://www.gnu.org/software/libc/manual/html_node/Limits-for-Files.html:
`PATH_MAX` is explicitly defined to include a nul delimiter;
`FILENAME_MAX` is not.

See also https://twitter.com/pid_eins/status/1357008940886818822.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-04-19 19:23:10 +01:00
Philip Withnall
3c027268a4 dirent: Simplify a memset() call
Let the compiler figure out the size, rather than hard-coding it the
same as the struct definition.

This makes no functional changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-04-19 19:22:33 +01:00
Princeton Ferro
30ed2ea263 improve console check in gspawn-win32
We use the return value of AllocConsole (GetCurrentProcessId ()) to
determine whether the spawning process is attached to a console.
2021-04-19 10:25:06 +00:00
Nelson Ben
225fec1329 g_string_replace(): Fix documentation of 'limit' parameter 2021-04-18 18:31:32 +00:00