Commit Graph

7644 Commits

Author SHA1 Message Date
Loic Le Page
bfa46bd98a Fix gconstructor.h header to include gslist functions
Macros defined in gconstructor.h header are using g_slist_find()
function but the gslist.h corresponding header was not included.
2022-01-26 10:08:20 +01:00
Pablo Correa Gómez
6406217f50
gsequence: Fix variable maybe uninitialized warning
../glib/gsequence.c: In function 'g_sequence_move_range':
../glib/gsequence.c:640:24: warning:
 'dest_seq' may be used uninitialized in this function [-Wmaybe-uninitialized]
  640 |   if (dest && dest_seq == src_seq &&
      |               ~~~~~~~~~^~~~~~~~~~
2022-01-25 20:18:41 +01:00
Pablo Correa Gómez
c2ff12ced5
glib/tests: Fix variable maybe uninitialized warning 2022-01-25 20:18:41 +01:00
Ignacio Casal Quinteiro
08017c0d6c giowin32: use gint64 and _lseeki64
off_t on windows is 32bit which means that it will not be able
to handle big offsets
2022-01-20 12:22:18 +01:00
Philip Withnall
ce45b88b90 Merge branch 'unicode_caseconv_tests' into 'main'
Merge test/unicode-caseconv.c into glib/tests/unicode.c

See merge request GNOME/glib!2432
2022-01-19 15:54:19 +00:00
Emmanuel Fleury
b9f07a458a Merge test/unicode-caseconc.c into glib/tests/unicode.c
Related to issue #1434
2022-01-19 16:21:01 +01:00
Philip Withnall
90b40ee3d2 Merge branch '2580-spawn-close-range-errors' into 'main'
gspawn: Report errors with closing file descriptors between fork/exec

Closes #2580

See merge request GNOME/glib!2435
2022-01-19 12:43:57 +00:00
Philip Withnall
ce04a12404 gspawn: Report errors with closing file descriptors between fork/exec
If a seccomp policy is set up incorrectly so that it returns `EPERM` for
`close_range()` rather than `ENOSYS` due to it not being recognised, no
error would previously be reported from GLib, but some file descriptors
wouldn’t be closed, and that would cause a hung zombie process. The
zombie process would be waiting for one half of a socket to be closed.

Fix that by correctly propagating errors from `close_range()` back to the
parent process so they can be reported correctly.

Distributions which aren’t yet carrying the Docker fix to correctly
return `ENOSYS` from unrecognised syscalls may want to temporarily carry
an additional patch to fall back to `safe_fdwalk()` if `close_range()`
fails with `EPERM`. This change will not be accepted upstream as `EPERM`
is not the right error for `close_range()` to be returning.

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

Fixes: #2580
2022-01-19 12:01:08 +00:00
Philip Withnall
8ec5dca0fe Merge branch '2564-zerowidth-jungseong' into 'main'
guniprop: Set jungseong and jongseong points to zero-width for Old Korean

Closes #2564

See merge request GNOME/glib!2418
2022-01-19 11:20:35 +00:00
Philip Withnall
3be0fc867e Merge branch 'wip/hash-table-from' into 'main'
ghash: Add g_hash_table_new_similar

See merge request GNOME/glib!2405
2022-01-19 11:19:07 +00:00
Matthias Clasen
6749b343fe Improve g_ascii_formatd docs and preconditions 2022-01-19 00:14:55 +00:00
Jonas Ådahl
283d9e0c15 ghash: Add g_hash_table_new_similar()
This function creates a new hash table, but inherits the functions used
for the hash, comparison, and key/value memory management functions from
another hash table.

The primary use case is to implement a behaviour where you maintain a
hash table by regenerating it, letting the values not migrated be freed.
See the following pseudo code:

```
GHashTable *ht;

init(GList *resources) {
  ht = g_hash_table_new (g_str_hash, g_str_equal, g_free, g_free);
  for (r in resources)
    g_hash_table_insert (ht, strdup (resource_get_key (r)), create_value (r));
}

update(GList *resources) {
  GHashTable *new_ht = g_hash_table_new_similar (ht);

  for (r in resources) {
    if (g_hash_table_steal_extended (ht, resource_get_key (r), &key, &value))
      g_hash_table_insert (new_ht, key, value);
    else
      g_hash_table_insert (new_ht, strdup (resource_get_key (r)), create_value (r));
  }
  g_hash_table_unref (ht);
  ht = new_ht;
}
```
2022-01-18 22:19:55 +01:00
Pablo Correa Gómez
b8c4a3e13b
glib/tests: Fix NULL reference on >= C++11
Fixes #2582
2022-01-18 16:51:15 +01:00
Philip Withnall
b828f1001b Merge branch 'illumos-timezone' into 'main'
Fix GDateTime timezone resolution for Illumos

Closes #2550

See merge request GNOME/glib!2409
2022-01-17 19:28:07 +00:00
Tim Mooney
8cc71d35d0 Fix GDateTime timezone resolution for Illumos
Closes #2550
2022-01-14 22:39:56 -06:00
Nirbheek Chauhan
41d80f5029 Merge branch 'wip/pwithnall/2565-array-preprocessor' into 'main'
tests: Fix compilation failure on msys2-mingw64

Closes #2565

See merge request GNOME/glib!2419
2022-01-14 14:47:53 +00:00
Sebastian Keller
d9e001e2cd gfileutils: Remove outdated BTRFS fsync optimization from set_contents
This code was skipping fsync on BTRFS because of an old guarantee about
the overwrite-by-rename behavior that no longer holds true. This has
been confirmed by the BTRFS developers to no longer be guaranteed since
Kernel 3.17 (August 2014), but it was guaranteed when this optimization
was first introduced in 2010.

This could result in empty files after crashes in applications using
g_file_set_contents(). Most prominently this might have been the cause
of dconf settings getting lost on BTRFS after crashes due to the
frequency with which such writes can happen in dconf.

See: https://gitlab.gnome.org/GNOME/dconf/-/issues/73
2022-01-11 19:07:01 +01:00
Simon McVittie
c651ea0453 testutils: Defer global cleanup until we really exit
Some test suites try to call g_test_build_filename() after g_test_run()
has returned. In the installed-tests use-case where G_TEST_BUILDDIR and
G_TEST_SRCDIR are unset, that call uses test_argv0_dirname, which
is freed in test_cleanup(). Defer test_cleanup() using atexit() so it
isn't freed until after we return from main().

Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/2563
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-01-06 15:41:13 +00:00
Philip Withnall
233611fe42 tests: Fix compilation failure on msys2-mingw64
This is a follow-up from commit 995823b9d9, which added the condition
```
```
to the array test. On most platforms, both of those symbols are numeric
literals, but on 64-bit Windows `G_MAXSIZE` includes some widening
casts, which means it can’t be used in a preprocessor condition.

We don’t expose an appropriate symbol in `glibconfig.h` which could be
used instead, but the standard `*_WIDTH` symbols from `limits.h` will be
identical and can be used instead.

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

Fixes: #2565
2022-01-06 13:22:23 +00:00
Philip Withnall
84202a2ef0 guniprop: Set jungseong and jongseong points to zero-width for Old Korean
This mirrors what `wcwidth()` from glibc does as of June 2020 (commit
6e540caa2).

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

Fixes: #2564
2022-01-06 13:11:24 +00:00
Philip Withnall
e6b85bc05c gtestutils: Fix minor typos in the g_test_get_filename() docs
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-01-06 12:52:00 +00:00
Kelvin Zhang
2a4422b0f2 Use meson dependency to link against apple framework
Using ld_flags would work, but that does not propagate ldflags to users
of glib. Meson's dependency() call will propagate apple framework
dependencies to downstream users.
2022-01-05 11:32:32 -08:00
Sophie Herold
68eab1d999 utils: Add XDG_STATE_HOME support 2021-12-24 20:11:39 +00:00
Sebastian Dröge
8ca2a7d7c8 Merge branch 'wip/pwithnall/fix-environment-tests' into 'main'
tests: Fix environment test on FreeBSD

See merge request GNOME/glib!2407
2021-12-24 10:08:50 +00:00
Philip Withnall
2f53c8ed64 Merge branch 'barch/windows_no_popups' into 'main'
Prevent gtest tests from popping up dialog boxes

See merge request GNOME/glib!2400
2021-12-23 13:14:00 +00:00
Philip Withnall
1a1f05234e Merge branch 'improve_gasyncqueue_tests' into 'main'
Improve test coverage of glib/tests/asyncqueue.c

See merge request GNOME/glib!2403
2021-12-23 13:11:45 +00:00
Philip Withnall
4bb9e20fff tests: Fix environment test on FreeBSD
Fix for commit 20c8ea1bc651bc4b79d39b80d42b468f6e7a2dc8; while Linux
seems happy to return the value for the invalid key we set above, BSD
returns NULL (which is probably a more valid thing to do).

Accept both.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-12-23 13:04:49 +00:00
Charles Barto
5c82bf65d6 include crtdbg first, so includes are alphabatical 2021-12-17 16:49:42 -08:00
Charles Barto
77df44371e Only call _set_abort_behavior with the ucrt. 2021-12-17 16:05:14 -08:00
Emmanuel Fleury
aa99af54aa Improve test coverage of glib/tests/asyncqueue.c 2021-12-17 21:21:49 +01:00
Emmanuel Fleury
c6ced6abe0 Improving glib/tests/environment.c 2021-12-17 20:18:40 +01:00
Charles Barto
908ed3498b Prevent gtest tests from popping up dialog boxes
Many UCRT (and msvcrt/msvcxx) functions open dialog boxes
by default for .... some reason. This is a problem because a test runner
waiting on a process to exit won't see it exit unless someone actually
clicks away the box, which won't happen on a CI machine.

Additionally g_abort unconditionally raises a debugging exception,
which, if uncaught, will cause windows error reporting to pop a dialog

Resolve the first problem by calling platform specific (but documented)
functions to change the CRT's behavior in g_test_init

Resolve the second by only throwing a debug exception if we're under
debugging, and just calling abort() otherwise.

This reduces the number of popups triggerd by `meson test` from
over 10 to about three on my machine, mostly in the spawn test code.
2021-12-16 20:20:56 -08:00
Emmanuel Fleury
20c8ea1bc6 Move tests/env-test.c into glib/tests/environment.c 2021-12-16 16:32:26 +01:00
Emmanuel Fleury
9f760a7cc1 Moving tests/dirname-test.c to glib/tests/fileutils.c
Helps issue #1434
2021-12-16 10:41:13 +00:00
Philip Withnall
dce8d110d6 Merge branch 'move_tests/child-test_to_glib/tests/spawn-multithreaded' into 'main'
Merging tests/child-test.c into glib/tests/spawn-multithreaded.c

See merge request GNOME/glib!2390
2021-12-16 10:38:53 +00:00
Charles Barto
d60b4010c4 Silence MSVC C4312 in list tests
This warning warns on widening casts from integer to pointer type,
because those casts can be problematic for porting to new pointer
sizes. The code in question didn't do any bad things here so an
intermediate cast to size_t was added to silence the warning
2021-12-15 17:21:20 -08:00
Charles Barto
cdd53b9218 fix /list/position test
This test was exploiting unspecified behavior w.r.t. the address of string
literals, It expected them to be pooled (the same literal has the same
address, at least within a TU), but MSVC does not pool by default,
leading to a failure.
2021-12-15 17:19:50 -08:00
Emmanuel Fleury
45bd6e1d3d Improving the tests moved in spawn-multithreaded 2021-12-16 00:55:42 +01:00
Emmanuel Fleury
241b9f41b4 Merging tests/child-test.c into glib/tests/spawn-multithreaded.c
Helps issue #1434
2021-12-15 23:12:59 +01:00
Michael Catanzaro
b251a7cd18 gspawn: add new error message for open() failures
Reporting these as dup2() failures is bogus.
2021-12-14 13:45:39 -06:00
Michael Catanzaro
34de33a9bd gspawn: Check from errors from safe_dup2() and dupfd_cloexec()
Although unlikely, these functions can fail, e.g. if we run out of file
descriptors. Check for errors to improve robustness. This is especially
important now that I changed our use of dupfd_cloexec() to avoid
returning fds smaller than the largest fd in target_fds. An application
that attempts to remap to the highest-allowed fd value deserves at least
some sort of attempt at error reporting, not silent failure.
2021-12-14 13:45:39 -06:00
Michael Catanzaro
7d5bdff6d9 gspawn: Implement fd remapping for posix_spawn codepath
This means that GSubprocess will (sometimes) be able to use the
optimized posix_spawn codepath instead of having to fall back to
fork/exec.
2021-12-14 13:45:39 -06:00
Michael Catanzaro
f9780c6bee gspawn: fix fd remapping conflation issue
We currently dup all source fds to avoid possible conflation with the
target fds, but fail to consider that the result of a dup might itself
conflict with one of the target fds. Solve this the easy way by duping
all source_fds to values that are greater than the largest fd in
target_fds.

Fixes #2503
2021-12-14 13:45:39 -06:00
Michael Catanzaro
e2700c7638 gspawn: fix hangs when duping child_err_report_fd
In case child_err_report_fd conflicts with one of the target_fds, the
code here is careful to dup child_err_report_fd in order to avoid
conflating the two. It was a good idea, but evidently was not tested,
because the newly-created fd is not created with CLOEXEC set. This means
it stays open in the child process, causing the parent to hang forever
waiting to read from the other end of the pipe. Oops!

The fix is simple: just set CLOEXEC. This removes our only usage of the
safe_dup() function, so it can be dropped.

Fixes #2506
2021-12-14 13:36:26 -06:00
Michael Catanzaro
33f15d9dd0 gspawn: Improve error message when dup fails
This error message is no longer accurate now that we allow arbitrary fd
remapping.
2021-12-14 13:36:25 -06:00
Michael Catanzaro
ac8d1aa247 gspawn: use close_and_invalidate more 2021-12-14 13:36:24 -06:00
Emmanuel Fleury
cde56cfc70 Move tests/completion-test.c to glib/tests/completion.c
Helps issue #1434
2021-12-13 17:42:23 +01:00
Érico Nogueira
4b2f342a22 gstrfuncs: don't require nonstandard functions for USE_XLOCALE.
Make it so USE_XLOCALE is set whenever newlocale() and uselocale() are
available. This way, we can still use the _g_snprintf() path for some
functions, and also use the *_l functions when they are available.

newlocale(3) are uselocale(3) part of POSIX 2008, while the *_l
functions being used are nonstandard glibc extensions. Gating all the
locale functionality behind them meant we were using fallbacks on non
glibc platforms unnecessarily.

Further changes to this code could add fallback for the non _l suffixed
number parsing functions, but that might be unnecessary complexity.

Fixes #2553
2021-12-09 18:20:07 -03:00
Phaedrus Leeds
93f5758cf4 gfileutils: Fix transfer annotation and whitespace issues 2021-12-02 12:37:26 -08:00
Philip Withnall
fc25f8d7ef gfileutils: Correctly reset start value when canonicalising paths
If a path starts with more than two slashes, the `start` value was
previously incorrect:
 1. As per the `g_path_skip_root()` call, `start` was set to point to
    after the final initial slash. For a path with three initial
    slashes, this is the character after the third slash.
 2. The canonicalisation loop to find the first dir separator sets
    `output` to point to the character after the first slash (and it
    overwrites the first slash to be `G_DIR_SEPARATOR`).
 3. At this point, with a string `///usr`, `output` points to the second
    `/`; and `start` points to the `u`. This is incorrect, as `start`
    should point to the starting character for output, as per the
    original call to `g_path_skip_root()`.
 4. For paths which subsequently include a `..`, this results in the
    `output > start` check in the `..` loop below not skipping all the
    characters of a preceding path component, which is then caught by
    the `G_IS_DIR_SEPARATOR (output[-1])` assertion.

Fix this by resetting `start` to `output` after finding the final slash
to keep in the output, but before starting the main parsing loop.

Relatedly, split `start` into two variables: `after_root` and
`output_start`, since the variable actually has two roles in the two
parts of the function.

Includes a test.

This commit is heavily based on suggestions by Sebastian Wilhemi and
Sebastian Dröge.

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

oss-fuzz#41563
2021-12-02 17:50:17 +00:00
Philip Withnall
3421a703ca gfileutils: Add a comment in g_canonicalize_filename()
Clarify the code a little. This introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-12-02 11:32:25 +00:00
Philip Withnall
cbd48824bd tests: Test the function forms of g_bit_*() APIs too
The tests were previously only checking the macro forms. The function
forms should behave identically, but since it’s easy enough to get
coverage of them, we might as well.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-12-02 10:02:57 +00:00
Philip Withnall
d5e6793b83 tests: Factor out common calculations in test_basic_bits() test
This decreases the overall test time from 0.17s to 0.12s for me, and
will help further in the following commit where I’m going to repeat some
of these calculations again for further comparisons.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-12-02 09:59:46 +00:00
Philip Withnall
17ffe7b303 Merge branch 'move_bit-test' into 'main'
Merging tests/bit-test.c into glib/tests/utils.c

See merge request GNOME/glib!2379
2021-12-02 09:45:37 +00:00
Emmanuel Fleury
dd47df80e1 Merging tests/bit-test.c into glib/tests/utils.c 2021-12-01 14:10:44 +01:00
Philip Withnall
b5b3327636 Merge branch 'move_test_sources' into 'main'
GSource: move test to glib/tests/

See merge request GNOME/glib!2376
2021-12-01 11:39:46 +00:00
Bastien Nocera
0cc75eb728 gtestutils: Mention the unit used for the test timer 2021-12-01 11:19:30 +01:00
Nishal Kulkarni
70a8811ccc GSource: move test to glib/tests/
Previously tests existed in two places,
`$top_srcdir/tests/sources.c` contained additional tests,
they have now been moved to `$top_srcdir/glib/tests/mainloop.c`
and `$top_srcdir/tests/sources.c` was deleted.

Related to: #1434
2021-12-01 14:04:46 +05:30
Philip Withnall
9bd3ae856e Merge branch '2541-canonicalize-performance' into 'main'
gfileutils: Improve performance of g_canonicalize_filename()

Closes #2541

See merge request GNOME/glib!2374
2021-11-30 09:59:13 +00:00
Emmanuel Fleury
074d0a79d9 Removing tests/asyncqueue-test.c from tests/
Tests on async queues are already performed in a more extensive way in
glib/tests/asyncqueue.c. This test file can be safely removed without
any loss.
2021-11-29 16:46:13 +01:00
Nishal Kulkarni
279a610018 gqsort: Move test to glib/tests/
Previously tests existed in two places,
`$top_srcdir/tests/qsort-test.c` contained a similar test
to the one in `$top_srcdir/glib/tests/sort.c` called `test_sort_basic()`

The test for checking with zero elements was additional added to
`$top_srcdir/glib/tests/sort.c` and `$top_srcdir/tests/qsort-test.c`
was deleted.

Related to: #1434
2021-11-27 02:16:22 +05:30
Sebastian Wilhelmi
9a30a495ec gfileutils: Improve performance of g_canonicalize_filename()
Improve the performance of canonicalising filenames with many `..` or
`.` components, by modifying the path inline rather than calling
`memmove()`.

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

Fixes: #2541
2021-11-26 14:07:10 +00:00
Philip Withnall
72377e3b6e Merge branch 'new_alloca0_newa0' into 'main'
galloca: Add new API g_alloca0 and g_newa0

Closes #475

See merge request GNOME/glib!2367
2021-11-26 12:38:46 +00:00
Nishal Kulkarni
b321bf70d7 goption: Use new g_newa0() function
Replace old `g_newa()` and `memset()` with `g_newa0()`
2021-11-26 12:24:23 +00:00
Nishal Kulkarni
8bf62d6309 ghmac: Use new g_alloca0() function
Replace `g_alloca()` and `memset()` with `g_alloca0()`
2021-11-26 12:24:23 +00:00
Marc-André Lureau
b4631c44ad galloca: Add new API g_alloca0 and g_newa0
Added `g_alloca0()` which wraps `g_alloca()` and initializes
allocated memory to zeroes.

Added `g_newa0()` which wraps `g_alloca0()` in a typesafe manner.

Refreshed and tweaked by Nishal Kulkarni.
2021-11-26 12:24:23 +00:00
Philip Withnall
3fecaa3924 tests: Unset CHARSET when testing locales to avoid it breaking tests
The charset set in `CHARSET` overrides the charset after the `.` in any
`LC_*` category (set via the environment or `setlocale()`). This will
break many tests, but in particular it definitely breaks the
`/GDateTime/format_mixed/` tests which are specifically checking
different charsets being set for different `LC_*` categories.

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

Fixes: #2514
2021-11-26 12:08:02 +00:00
Philip Withnall
7dc7b84a52 gcharset: Document the CHARSET environment variable a bit
Users should probably never be setting this — instead, just add the
charset after a `.` in `LANGUAGE`/`LC_ALL`/`LC_*`/`LANG`.

I can’t find any reference (in `git log`, code comments, or man pages)
to this environment variable being standardised or documented or even
used anywhere outside GLib. Perhaps it should eventually be removed.

If anybody finds references as to why GLib checks `CHARSET`, this
comment can be updated in future.

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

Helps: #2514
2021-11-26 12:07:00 +00:00
Sebastian Dröge
72ca69e1db Add some overflow protection to g_string_chunk_insert_len()
If the new string's length plus the existing storage's length is
overflowing a gsize, we would previously memcpy() the string over the
bounds of the previous allocation.

Similarly if the string's size was bigger than G_MAXSIZE / 2 we would've
previously allocated 0 bytes.

Now instead create a new allocation that fits the string.
2021-11-25 14:38:17 +02:00
Sebastian Dröge
b5447e8e35 Add overflow protection to g_string_maybe_expand() 2021-11-25 14:38:17 +02:00
Sebastian Dröge
d01dc6d23a Add stricter overflow protection from GArray to g_ptr_array_maybe_expand() too
It might otherwise happen that the return value from g_nearest_pow()
does not fit into a guint, i.e. it might be G_MAXUINT + 1 if that fits
into a gsize.
2021-11-25 14:11:29 +02:00
Sebastian Dröge
5fcd2495f9 De-duplicate g_nearest_pow() implementation
And put it as static inline function into a private shared header instead.
2021-11-25 14:05:42 +02:00
Philip Withnall
f496d28093 Merge branch 'make_setprgname_thread_safe' into 'main'
gutils: Make g_set_prgname() thread-safe

Closes #847

See merge request GNOME/glib!2358
2021-11-24 11:10:29 +00:00
Nishal Kulkarni
ef4b43ff13 gutils: Make g_set_prgname() thread-safe
Currently `g_prgname` can be freed by `g_set_prgname()` while another
thread is holding a pointer to it.

We use GQuark when setting g_prgname so that string is never released once set.
Also added unit test, which checks if setting prgname in multi-threaded
program is safe.

Closes: #847
2021-11-24 16:22:28 +05:30
Philip Withnall
de2f692846 Merge branch 'main' into 'main'
gutf8: add string length check when ending character offset is -1

See merge request GNOME/glib!2328
2021-11-22 12:22:54 +00:00
Philip Withnall
d455ece99f Merge branch 'improve-win32-version' into 'main'
gutils.c: Improve g_get_os_info() for Windows 10/Server 2008 R2+

Closes #2443

See merge request GNOME/glib!2351
2021-11-22 11:16:04 +00:00
Chun-wei Fan
7540bed89e gutils.c: Improve g_get_os_info() for Windows Server 2008+
Instead of Windows 7/8/8.1 Server, use the proper names Server 2008
R2/2012/2012 R2 so that things are clearer to people.  Since nowadays
GLib requires Windows 7 (_WIN32_WINNT 0x0601, meaning the server
counterpart is Server 2008 R2), we include Server 2008 in the list for
completeness' sake, but exclude the Server 2003/2003R2 from the list.
2021-11-22 12:54:52 +08:00
Chun-wei Fan
5f56477cc7 gutils.c: Improve Windows Server 2016/10 20H2+ detection
This improves how we obtain the Windows release versions in
get_windows_version(), in turn g_get_os_info() for Windows Server 2016
and later, and Windows 10 20H2 (2009) and later and Windows 11, by doing
the following:

*  Check the build number.  For Windows 11, the build number is 22000+;
   for Windows Server 2022, the build number is 20348, and for Windows
   Server 2019, the build number is 17763.  We know what OS build
   numbers to check for by the Windows OS type that we obtained by using
   g_win32_check_windows_version().  Show the actual server release
   string (i.e. Windows Server 20xx yyyy) as appropriate, as a result.
*  Check the DisplayVersion entry in the registry under
   SOFTWARE\Microsoft\Windows NT\CurrentVersion if we obtained "2009"
   from the ReleaseId entry, since DisplayVersion replaces ReleaseId
   after Windows 10/Server 2019 20H2 (2009).  This makes things more
   clear for Windows releases after 20H2, where previously 20H2
   and 21H1 were all identified as Windows 10 [Server] 2009.

This should fix issue #2443.
2021-11-22 12:16:14 +08:00
Sebastian Dröge
07151049aa Annotate g_getenv() and g_environ_getenv() return value as nullable 2021-11-20 11:11:01 +02:00
Chun-wei Fan
045b4b80df gwin32.c: Split out call to RtlGetVersion()
Unfortunately, we may well be likely to need to call RtlGetVersion() via
GetModuleHandle() + GetProcAddress(), so split out the call to RtlGetVersion()
into a private function of its own, so that we can reuse the same code in other
parts of GLib, so that we can:

*  Determine better in a more fine-tuned way to determine whether we are on
   Windows 10/11 and/or Server 2016/2019/2022, since we need to rely on the
   build number.

*  Just call RtlGetVersion() once, when needed, as that is all that is needed.
   We could re-use the same function once to compare what we got when we
   called RtlGetVersion() and do what is necessary there.
2021-11-19 16:01:54 +08:00
Chen Guanqiao
9adbdd45d7 gutf8: add string length check when ending character offset is -1
Some function such as atk_text_get_text, use -1 to indicate the end of the
string. And an crash occurs when the -1 is passed to g_utf8_substring.

Call Trace:
  0  __memmove_avx_unaligned_erms
  1  memcpy
  2  g_utf8_substring
  3  impl_GetText
  4  handle_other
  5  handle_message
  6  _dbus_object_tree_dispatch_and_unlock
  7  dbus_connection_dispatch
  8  dbus_connection_dispatch
  9  ()
  10 g_main_dispatch
  11 g_main_context_dispatch
  12 g_main_context_iterate
  13 g_main_context_iteration
  14 g_application_run
  15 main

Signed-off-by: Chen Guanqiao <chen.chenchacha@foxmail.com>
2021-11-19 00:52:07 +08:00
Philip Withnall
97e3d366bc gosxutils: Add missing prototype
Fixes a `-Wmissing-prototypes` warning on macOS.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-18 14:32:09 +00:00
Philip Withnall
e5719fd667 gosxutils: Add newline at end of file
Fixes a `-Wnewline-eof` warning when building on macOS.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-18 13:52:24 +00:00
Philip Withnall
6554af0320 gutils: Disable some dead code on macOS
This code isn’t used when building on macOS, so ifdef it out to avoid a
compiler warning.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-18 10:57:37 +00:00
Philip Withnall
81a31fd062 Merge branch '2523-checked-arithmetic' into 'main'
gtypes: Rework checked arithmetic handling

Closes #2523

See merge request GNOME/glib!2343
2021-11-18 10:54:54 +00:00
Philip Withnall
eba54436f7 Merge branch 'main' into 'main'
guri: Improve performance of remove_dot_segments() algorithm

Closes #2526

See merge request GNOME/glib!2327
2021-11-17 15:20:28 +00:00
Sebastian Wilhelmi
21b45d6ac2 guri: Improve performance of remove_dot_segments() algorithm 2021-11-17 15:20:28 +00:00
Philip Withnall
b09ccc4635 Merge branch 'fix_all_warnings' into 'main'
Fix final warnings in Windows code

See merge request GNOME/glib!2323
2021-11-17 15:15:46 +00:00
Emmanuel Fleury
8c35109a21 Fix signedness warnings in glib/gutf8.c
glib/gutf8.c: In function 'g_utf8_get_char_extended':
glib/gutf8.c:626:39: error: comparison of integer expressions of different signedness: 'guint' {aka 'unsigned int'} and 'gssize' {aka 'int'}
  626 |   if (G_UNLIKELY (max_len >= 0 && len > max_len))
      |                                       ^
glib/gmacros.h:1091:27: note: in definition of macro 'G_UNLIKELY'
 1091 | #define G_UNLIKELY(expr) (expr)
      |                           ^~~~
glib/gutf8.c:628:21: error: comparison of integer expressions of different signedness: 'guint' {aka 'unsigned int'} and 'gssize' {aka 'int'}
  628 |       for (i = 1; i < max_len; i++)
      |                     ^
2021-11-17 14:40:38 +01:00
Philip Withnall
bc04b57eed gtypes: Rework checked arithmetic handling
Rather than using the fixed-type compiler builtins
(`__builtin_uadd_overflow()`, etc.), use the generic versions
(`__builtin_add_overflow()`). This avoids issues with matching the
definition of GLib types (such as `guint` and particularly `gsize`) to
basic C types (`int`, `long`, `long long`), as the mapping can vary
between platforms.

See https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html

Adjust the fallback inline functions similarly.

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

Fixes: #2523
2021-11-17 11:57:09 +00:00
Philip Withnall
65368ca448 Merge branch 'main' into 'main'
Better detection of the cleanup attribute.

See merge request GNOME/glib!2223
2021-11-16 15:35:05 +00:00
Alvarito050506
03753cda79 Better detection of the cleanup attribute.
Use g_macro__has_attribute to detect it instead of
hardcoding __GNUC__ || __clang__. This adds support
for a few compiler and is consistent with the rest
of the gmacros.h file.
2021-11-16 15:13:07 +00:00
Philip Withnall
fc4070a047 gmessages: Support namespaced journals
Spotted and diagnosed by Ilya Basin.

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

Fixes: #2530
2021-11-16 14:43:12 +00:00
Sebastian Dröge
e9acc6a7f9 Merge branch '2529-special-dirs-annotation' into 'main'
gutils: Add missing (nullable) annotation to g_get_user_special_dir()

Closes #2529

See merge request GNOME/glib!2334
2021-11-16 12:30:08 +00:00
Philip Withnall
88ed83c61e gutils: Add missing (nullable) annotation to g_get_user_special_dir()
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2529
2021-11-16 12:05:53 +00:00
gonyere
5eeac53793 Changed gendered terms to be gender-neutral 2021-11-12 21:32:21 -05:00
Philip Withnall
746ce4e042 Merge branch 'fix_garray_warning' into 'main'
Fix always true comparison warning in glib/garray.c

See merge request GNOME/glib!2311
2021-11-04 14:18:03 +00:00
Emmanuel Fleury
12113f398a Fix always true comparison warning in glib/garray.c
glib.git/glib/garray.c: In function ‘g_array_new’:
glib.git/glib/garray.c:184:34: error: comparison is always true due to limited range of data type [-Werror=type-limits]
  184 |   g_return_val_if_fail (elt_size <= G_MAXSIZE / 2 - 1, NULL);
      |                                  ^~
glib.git/glib/gmacros.h:1090:25: note: in definition of macro ‘G_LIKELY’
 1090 | #define G_LIKELY(expr) (expr)
      |                         ^~~~
glib.git/glib/garray.c:184:3: note: in expansion of macro ‘g_return_val_if_fail’
  184 |   g_return_val_if_fail (elt_size <= G_MAXSIZE / 2 - 1, NULL);
      |   ^~~~~~~~~~~~~~~~~~~~
glib.git/glib/garray.c: In function ‘g_array_sized_new’:
glib.git/glib/garray.c:265:34: error: comparison is always true due to limited range of data type [-Werror=type-limits]
  265 |   g_return_val_if_fail (elt_size <= G_MAXSIZE, NULL);
      |                                  ^~
glib.git/glib/gmacros.h:1090:25: note: in definition of macro ‘G_LIKELY’
 1090 | #define G_LIKELY(expr) (expr)
      |                         ^~~~
glib.git/glib/garray.c:265:3: note: in expansion of macro ‘g_return_val_if_fail’
  265 |   g_return_val_if_fail (elt_size <= G_MAXSIZE, NULL);
      |   ^~~~~~~~~~~~~~~~~~~~
2021-11-04 14:50:24 +01:00
Philip Withnall
7be79cb840 Merge branch '2310-xdgmime-leaks' into 'main'
gcontenttype: Ignore intentional one-time leaks from xdgmime

Closes #2310

See merge request GNOME/glib!2268
2021-11-03 15:42:20 +00:00
Philip Withnall
fe0346a172 gdate: Clarify the documentation for g_date_new_dmy() and new_julian()
The documentation about validity did not match the code. Since the code
hasn’t changed in a long time (since 1998 or 2011), change the
documentation to match it.

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

Fixes: #2520
2021-11-03 10:47:38 +00:00
Sebastian Dröge
82be9c4f11 Merge branch 'keyfile-parsing-performance' into 'main'
Keyfile parsing performance improvements

See merge request GNOME/glib!1991
2021-11-02 11:08:15 +00:00
Philip Withnall
513f48bab7 gkeyfile: Rework preconditions to avoid unreachable branches
It’s a programmer error for `NULL` to reach `is_group_name()` or
`is_key_name()`, so rework the preconditions so that all programmer
error checks are wrapped in a `g_return_if_fail()`. The coverage
scanning is set up to ignore anything inside that.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
e8a6d0b54e tests: Test various different invalid encoding names for key files
These exercise different branches in
`g_key_file_parse_key_value_pair()`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
d2e5c61104 tests: Use g_assert_*() rather than g_assert() in keyfile.c
`g_assert()` is compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
655e2bac33 gkeyfile: Remove some redundant checks
`g_key_file_parse_key_value_pair()` checks that both of these are
non-NULL on entry, and they can’t be modified between then and here.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
f471afb646 gkeyfile: Clarify behaviour of locales and checked_locales
This should introduce no functional changes, but will remove an
unreachable branch in `g_key_file_locale_is_interesting()`:
`checked_locales` indicates whether `locales` has been initialised (and
it can be initialised to `NULL`), so there’s no point in checking
`locales` itself if `checked_locales` is checked.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
f93f24e41c gkeyfile: Avoid allocating a copy of the locale for a key
Instead compare it inline. This should avoid a lot of allocations in key
files with lots of translations (such as desktop files).

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
5a38dc79f0 gkeyfile: Move allocation of value until after locale checks have passed
This avoids allocating a copy of the value in the case that it’s for a
locale which is uninteresting.

This should speed up parsing of key files with large numbers of
translations, when only the translations for certain locales are wanted.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
6c70d30f07 gkeyfile: Tidy up ownership transfer in parse_key_value_pair()
This introduces no functional changes, but does make the ownership
transfer a little clearer.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
cdcc06bbc5 gkeyfile: Move allocation of value until after error checking
This doesn’t affect performance in the normal case of a valid key file,
but does improve performance when handling largely-invalid key files.

oss-fuzz#31796

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
b07408fe5d gkeyfile: Fix off-by-one error in calculating value length
This was harmless, as it was always +1 too long, so included the
trailing nul terminator. However, upcoming changes will start to use it
in a context where there is no nul terminator.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
535653eec1 gstrfuncs: Document that g_ascii_strncasecmp() stops at first nul byte
The documentation wasn’t clear about whether it did that, or ignored nul
bytes and continued to `n` bytes regardless.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
c29601818f gkeyfile: Eliminate strcmp()s when looking up a group node
Rather than looking for the group node by comparing each name in the
linked list of `GKeyFileGroup` instances, look up the `GKeyFileGroup` in
the hash table, then look up its `GList` node by pointer.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
cba8d59737 gkeyfile: Eliminate unnecessary allocations when setting booleans
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
f71db39284 gkeyfile: Avoid an unnecessary strcmp()
As the groups are disambiguated by name via the `groups` hash table,
there is guaranteed to be at most one `GKeyFileGroup` instance per group
name, which means they can be compared for equality by `GKeyFileGroup`
pointer, rather than needing a `strcmp()`.

This speeds up key file parsing in all cases.

oss-fuzz#31796

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:36 +00:00
Philip Withnall
960030712d gkeyfile: Add a length argument to is_key_name()
This allows it to be called on a substring of a larger string, without
having to allocate a nul-terminated copy of the substring with
`g_strndup()` before knowing that the key name is actually valid.

This speeds up parsing of highly invalid key files, but doesn’t affect
performance in the normal case of a valid key file.

oss-fuzz#31796

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-02 09:38:33 +00:00
Philip Withnall
48af1cbddc Merge branch 'source-attach-trigger-wakeup' into 'main'
Add g_main_context_new_with_flags() and ownerless polling option

See merge request GNOME/glib!1960
2021-11-01 18:39:56 +00:00
Philip Withnall
46fe9639b9 gkeyfile: Make various parsing variables const
All these `gchar *`s are used as moving pointers into strings, being
incremented as the strings are parsed. They are never modified, so can
be `const`. This doesn’t speed anything up, but does allow removing some
casts and slightly improving type safety.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-11-01 18:16:27 +00:00
Emmanuele Bassi
0c5c55bb11 Merge branch 'datetime-typo-fix' into 'main'
tests: Fix a typo in a test message in gdatetime.c

See merge request GNOME/glib!2310
2021-10-25 12:11:17 +00:00
Philip Withnall
ac26e9d780 tests: Fix a typo in a test message in gdatetime.c
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-10-25 12:56:16 +01:00
Egor Bychin
5484bf1cef gutils: Add a comment specifying reason of omitting g_mkdir 2021-10-22 12:04:13 +01:00
Philip Withnall
ee867a3c63 gthread-win32: Remove an unnecessary volatile qualifier
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-10-21 12:01:33 +01:00
Philip Withnall
9784f31527 Merge branch 'fix_more_windows_warnings' into 'main'
Fix more windows warnings

See merge request GNOME/glib!2303
2021-10-20 15:30:50 +00:00
Emmanuel Fleury
2f2e021a56 Fix signedness warnings in glib/gwin32.c
glib/gwin32.c: In function 'g_win32_check_windows_version':
glib/gwin32.c:556:32: warning: comparison of integer expressions of different signedness: 'DWORD' {aka 'long unsigned int'} and 'gint' {aka 'const int'}
   if (osverinfo.dwMajorVersion > major)
                                ^
glib/gwin32.c:558:37: warning: comparison of integer expressions of different signedness: 'DWORD' {aka 'long unsigned int'} and 'gint' {aka 'const int'}
   else if (osverinfo.dwMajorVersion == major)
                                     ^~
glib/gwin32.c:560:36: warning: comparison of integer expressions of different signedness: 'DWORD' {aka 'long unsigned int'} and 'gint' {aka 'const int'}
       if (osverinfo.dwMinorVersion > minor)
                                    ^
glib/gwin32.c:562:41: warning: comparison of integer expressions of different signedness: 'DWORD' {aka 'long unsigned int'} and 'gint' {aka 'const int'}
       else if (osverinfo.dwMinorVersion == minor)
                                         ^~
2021-10-19 18:44:38 +02:00
Emmanuel Fleury
6971f4f264 Fix signedness warnings in glib/gtimezone.c
glib/gtimezone.c: In function 'rules_from_windows_time_zone':
glib/gtimezone.c:926:56: warning: comparison of integer expressions of different signedness: 'int' and 'DWORD' {aka 'long unsigned int'}
       for (year = first, i = 0; *rules != NULL && year <= last; year++)
                                                        ^~
glib/gtimezone.c:946:20: warning: comparison of integer expressions of different signedness: 'int' and 'DWORD' {aka 'long unsigned int'}
           if (year > first && memcmp (&regtzi_prev, &regtzi, sizeof regtzi) == 0)
                    ^
glib/gtimezone.c: In function 'set_tz_name':
glib/gtimezone.c:1481:25: error: comparison of integer expressions of different signedness: 'int' and 'guint' {aka 'unsigned int'}
 1481 |   len = *pos - name_pos > size - 1 ? size - 1 : *pos - name_pos;
      |                         ^
glib/gtimezone.c:1481:49: error: operand of '?:' changes signedness from 'int' to 'guint' {aka 'unsigned int'} due to unsignedness of other operand
 1481 |   len = *pos - name_pos > size - 1 ? size - 1 : *pos - name_pos;
      |                                                 ^~~~~~~~~~~~~~~
glib/gtimezone.c: In function 'rules_from_identifier':
glib/gtimezone.c:1553:25: warning: comparison of integer expressions of different signedness: 'int' and 'guint' {aka 'unsigned int'}
           for (i = 0; i < rules_num - 1; i++)
                         ^
2021-10-19 18:44:20 +02:00
Mark Weaver
995823b9d9 #1331: buffer overflow fix 2021-10-19 15:38:13 +00:00
Emmanuel Fleury
c9b4b0e765 Fix signedness warning in glib/gthread-win32.c
glib/gthread-win32.c: In function 'g_system_thread_new':
glib/gthread-win32.c:507:37: warning: comparison of integer expressions of different signedness: 'DWORD' {aka 'long unsigned int'} and 'int'
   if (ResumeThread (thread->handle) == -1)
                                     ^~
2021-10-19 00:30:50 +02:00
Philip Withnall
e212c5a28d Merge branch 'fix_more_windows_warnings' into 'main'
Fix windows warnings

See merge request GNOME/glib!2294
2021-10-18 14:48:18 +00:00
Emmanuel Fleury
928be8b8bc Fix signedness warnings in glib/gstdio.c
glib/gstdio.c: In function '_g_win32_stat_utf8':
glib/gstdio.c:763:45: warning: comparison of integer expressions of different signedness: 'gsize' {aka 'long long unsigned int'} and 'long long int'
       (g_path_is_absolute (filename) && len <= g_path_skip_root (filename) - filename))
                                             ^~
glib/gstdio.c: In function 'g_win32_readlink_utf8':
glib/gstdio.c:896:15: warning: comparison of integer expressions of different signedness: 'glong' {aka 'long int'} and 'gsize' {aka 'long long unsigned int'}
   if (tmp_len > buf_size)
               ^
2021-10-18 14:23:31 +02:00
Emmanuel Fleury
b89967a14d Fix signedness warnings in glib/gpoll.c
glib/gpoll.c: In function 'poll_rest':
../glib/gpoll.c:165:22: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'unsigned int'
       if (timeout_ms == INFINITE)
                      ^~
glib/gpoll.c:219:18: warning: comparison of unsigned expression >= 0 is always true
   else if (ready >= WAIT_OBJECT_0 && ready < WAIT_OBJECT_0 + nhandles)
                  ^~
glib/gpoll.c: In function 'poll_single_thread':
glib/gpoll.c:281:44: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'unsigned int'
       if (retval == 0 && (data->timeout_ms == INFINITE || data->timeout_ms > 0))
                                            ^~
glib/gpoll.c: In function 'g_poll':
glib/gpoll.c:477:52: warning: comparison of integer expressions of different signedness: 'DWORD' {aka 'long unsigned int'} and 'int'
         retval = retval == -1 ? -1 : thread_retval == -1 ? -1 : retval + thread_retval;
                                                    ^~
glib/gpoll.c:477:60: warning: operand of ?: changes signedness from 'int' to 'long unsigned int' due to unsignedness of other operand
         retval = retval == -1 ? -1 : thread_retval == -1 ? -1 : retval + thread_retval;
                                                            ^~
glib/gpoll.c:477:33: warning: operand of ?: changes signedness from 'int' to 'long unsigned int' due to unsignedness of other operand
         retval = retval == -1 ? -1 : thread_retval == -1 ? -1 : retval + thread_retval;
                                 ^~
2021-10-18 14:23:26 +02:00
Philip Withnall
6e2de8fcb5 Merge branch 'msvc-asan-build' into 'main'
glib-private: Fix MSVC build with AddressSanitizer

See merge request GNOME/glib!2293
2021-10-18 12:09:44 +00:00
Philip Withnall
68295cb2fb Merge branch 'utf16-to-utf8-docs' into 'main'
gutf8: Document that out args from g_utf16_to_utf8() are non-negative

See merge request GNOME/glib!2295
2021-10-18 11:58:54 +00:00
Philip Withnall
c8e78f395b Merge branch 'fatal-meson-warnings' into 'main'
meson: fix warnings for extract_all_objects function

See merge request GNOME/glib!2286
2021-10-18 11:57:50 +00:00
Philip Withnall
2423419a29 Merge branch 'static-analysis' into 'main'
fix issues found by svace static code analyzer

See merge request GNOME/glib!2285
2021-10-18 11:03:33 +00:00
Eli Schwartz
abb8e1c3a0 meson: fix warnings for extract_all_objects function
The "recursive:" kwarg is available in the targeted minimum version of
meson, and is basically required if you want to not emit warnings and
maybe error with --fatal-meson-warnings.

There are two basic solutions to this problem:

- The current default behavior is false, so explicitly opt in to that
  value. None of these internal libraries use recursive objects anyway.

- Use link_with to link to the static library directly, rather than the
  extracted objects.

Option 2 is what used to be done before commit
62af03bda8, but it only works with meson
>=0.52 and previously had buggy behavior.

Since the minimum version of meson is now 0.52, it is safe to revert
that commit and go back to using link_with, and therefore option 2 is
chosen.
2021-10-18 11:50:49 +01:00
Philip Withnall
6163c2c3fe Merge branch 'update-ci' into 'main'
ci: Update CI images to latest stable Debian and Fedora, bump Meson dependency to 0.52

See merge request GNOME/glib!2287
2021-10-18 10:48:31 +00:00
Egor Bychin
7f6ce4d8d2 gvariant: Fix pointers being dereferenced despite NULL checks 2021-10-15 14:15:43 +03:00
Egor Bychin
05dffc1a7f gvariant: Fix memory leak on a TYPE_CHECK failure 2021-10-15 14:15:43 +03:00
Egor Bychin
0abf51e0de gslice: Fix page size being limited to int instead of gsize 2021-10-15 14:15:43 +03:00
Egor Bychin
5a61f8b922 gmessages: Add check for a localtime function return value 2021-10-15 14:15:43 +03:00
Egor Bychin
a3f81a2ef5 gkeyfile: Remove unreachable code 2021-10-15 14:15:43 +03:00
Egor Bychin
e9adcd8f7f gbacktrace: Fix fcntl command arguments not being checked 2021-10-15 14:15:43 +03:00
Emmanuel Fleury
d16d780bf4 Fix signedness warning in glib/win_iconv.c
glib/win_iconv.c: In function 'iso2022jp_mbtowc':
glib/win_iconv.c:1818:18: warning: comparison of integer expressions of different signedness: 'DWORD' {aka 'long unsigned int'} and 'int'
     if (cv->mode != ISO2022_MODE(cs, shift))
                  ^~
glib/win_iconv.c: In function 'iso2022jp_wctomb':
glib/win_iconv.c:1889:18: warning: comparison of integer expressions of different signedness: 'DWORD' {aka 'long unsigned int'} and 'int'
     if (cv->mode == ISO2022_MODE(cs, shift))
                  ^~
2021-10-14 18:48:02 +02:00
Emmanuel Fleury
78af147721 Fix signedness warning in glib/gfileutils.c
glib/gfileutils.c: In function 'g_file_test':
glib/gfileutils.c:375:18: warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int'
   if (attributes == INVALID_FILE_ATTRIBUTES)
                  ^~
glib/gfileutils.c: In function 'g_get_current_dir':
glib/gfileutils.c:2882:40: warning: comparison of integer expressions of different signedness: 'DWORD' {aka 'long unsigned int'} and 'int'
   if (GetCurrentDirectoryW (len, wdir) == len - 1)
                                        ^~
2021-10-14 18:42:07 +02:00
Emmanuel Fleury
5471c13f65 Fix signedness warning in glib/gdate.c
glib/gdate.c: In function 'win32_strftime_helper':
glib/gdate.c:2582:12: warning: comparison of integer expressions of different signedness: 'gsize' {aka 'long long unsigned int'} and 'glong' {aka 'long int'}
   if (slen <= convlen)
            ^~
2021-10-14 18:40:32 +02:00
Philip Withnall
90b2ad80ee gutf8: Document that out args from g_utf16_to_utf8() are non-negative
Despite their type, the values returned will always be ≥ 0. It’s
unfortunate they weren’t declared with an unsigned type, but we can’t
change that now without breaking API.

Spotted in !2294.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-10-14 12:45:30 +01:00
Emmanuel Fleury
4ec06aa0c1 Fix missing initializer warning in glib/giowin32.c
glib/giowin32.c:1027:1: warning: missing initializer for field 'closure_callback' of 'GSourceFuncs' {aka 'struct _GSourceFuncs'}
 };
 ^
2021-10-13 18:38:59 +02:00
Emmanuel Fleury
a8a4bbf652 Fix signedness warning in glib/gspawn-win32.c
glib/gspawn-win32.c: In function 'read_helper_report':
glib/gspawn-win32.c:329:16: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'long long unsigned int'
   while (bytes < sizeof(gintptr)*2)
                ^
glib/gspawn-win32.c:366:13: warning: comparison of integer expressions of different signedness: 'gint' {aka 'int'} and 'long long unsigned int'
   if (bytes < sizeof(gintptr)*2)
             ^
2021-10-13 18:38:59 +02:00
Seungha Yang
a2f2745035 glib-private: Fix MSVC build with AddressSanitizer
MSVC supports AddressSanitizer as well via "/fsanitize=address" option,
but __lsan_ignore_object() equivalent feature is not supported.
Note that there's __declspec(no_sanitize_address) specifier which
provides a similar feature but that's not runtime behavior
so it's not directly applicable to g_ignore_leak() family.

See also https://docs.microsoft.com/en-us/cpp/sanitizers/asan-building?view=msvc-160
2021-10-13 18:18:08 +09:00
Emmanuel Fleury
cd04e0b7a4 Fix signedness warning in glib/gslice.c
glib/gslice.c: In function 'slice_config_init':
glib/gslice.c:394:16: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int'
   else if (len >= G_N_ELEMENTS (wvalue))
                ^~
2021-10-12 18:05:48 +02:00