Commit Graph

25229 Commits

Author SHA1 Message Date
Sebastian Dröge
4ea412c276 Merge branch 'unicode-normalise-leak' into 'main'
tests: Fix a minor leak in the unicode-normalize test

See merge request GNOME/glib!2606
2022-04-29 08:02:56 +00:00
Sebastian Dröge
42da5c454c Merge branch 'move-lcovrc' into 'main'
build: Move lcovrc file to root so it’s picked up by Meson

See merge request GNOME/glib!2630
2022-04-29 08:01:15 +00:00
Sebastian Dröge
cf863530ef Merge branch 'fix-unicode-normalize-installed-test' into 'main'
tests: Ensure NormalizationTest.txt is installed for installed-tests

See merge request GNOME/glib!2602
2022-04-29 08:00:50 +00:00
Sebastian Dröge
53016eff58 Merge branch 'revert-stat-abi-break' into 'main'
Revert "glib/gstdio: simplify GStatBuf macro condition for win64"

Closes #2633

See merge request GNOME/glib!2618
2022-04-29 08:00:31 +00:00
Sebastian Dröge
4f48d4e1bb Merge branch 'scan-build-fixes' into 'main'
Fix various scan-build warnings

See merge request GNOME/glib!2628
2022-04-28 11:07:34 +00:00
Philip Withnall
8e295e23a5 build: Move lcovrc file to root so it’s picked up by Meson
Move the lcovrc file to the root of the project, so that it’s picked up
by Meson when running `ninja coverage` locally.

See https://github.com/mesonbuild/meson/issues/4628

This won’t affect the code coverage run on the CI, since that explicitly
used the lcovrc file already.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-04-28 11:57:45 +01:00
Sebastian Dröge
a0aff5404c Merge branch 'scan-build-leak-fix' into 'main'
gopenuriportal: Fix a use-after-free on an error path

See merge request GNOME/glib!2627
2022-04-28 10:44:57 +00:00
Philip Withnall
a17a27bcf1 glocalfileinfo: Remove a redundant store
This fixes a scan-build warning:
```
../../../../source/glib/gio/glocalfileinfo.c:1661:28: warning: Although the value stored to 'mydirname' is used in the enclosing expression, the value is never actually read from 'mydirname' [deadcode.DeadStores]
                           mydirname = g_strdup (dirname),
                           ^           ~~~~~~~~~~~~~~~~~~
```

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

Helps: #1767
2022-04-28 11:22:53 +01:00
Philip Withnall
b509e59726 tests: Remove some redundant writes
`ret` was never read. This fixes scan-build warnings:
```
../../../../source/glib/glib/tests/thread.c:148:8: warning: Although the value stored to 'ret' is used in the enclosing expression, the value is never actually read from 'ret' [deadcode.DeadStores]
  if ((ret = prlimit (getpid (), RLIMIT_NPROC, &nl, &ol)) != 0)
       ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../source/glib/glib/tests/thread.c:174:8: warning: Although the value stored to 'ret' is used in the enclosing expression, the value is never actually read from 'ret' [deadcode.DeadStores]
  if ((ret = prlimit (getpid (), RLIMIT_NPROC, &ol, NULL)) != 0)
       ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

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

Helps: #1767
2022-04-28 11:22:53 +01:00
Philip Withnall
de5b30df84 tests: Add a missing assertion
This fixes a warning about a dead store to `newpath` from scan-build.

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

Helps: #1767
2022-04-28 11:22:53 +01:00
Philip Withnall
1d6c46a0ac gdatetime: Rework array indexing to satisfy scan-build
This introduces no functional changes, but reworks the array indexing so
that scan-build has a better idea about the array bounds. This squashes
the scan-build warning:
```
../../../../source/glib/glib/gdatetime.c:2292:20: warning: The left operand of '>=' is a garbage value [core.UndefinedBinaryOperatorResult]
      if (days [i] >= day_of_year)
          ~~~~~~~~ ^
```

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

Helps: #1767
2022-04-28 11:22:53 +01:00
Philip Withnall
969eb835dc gopenuriportal: Fix a use-after-free on an error path
`path` was used in building the error message after it had been freed.
Spotted by scan-build.

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

Helps: #1767
2022-04-28 11:22:33 +01:00
Philip Withnall
7f83151ac0 gsocket: Clear address before filling it
This will probably make no functional difference, but will squash two
warnings from scan-build:
```
../../../../source/glib/gio/gsocket.c:503:14: warning: Assigned value is garbage or undefined [core.uninitialized.Assign]
      family = address.storage.ss_family;
             ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../source/glib/gio/gsocket.c:527:29: warning: Assigned value is garbage or undefined [core.uninitialized.Assign]
       socket->priv->family = address.storage.ss_family;
                            ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
```

It seems like a reasonable thing to warn about. Initialising the full
union to zero should avoid any possibility of undefined behaviour like
that.

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

Helps: #1767
2022-04-28 10:50:08 +01:00
Philip Withnall
c02890645b tests: Drop redundant store
This fixes a scan-build warning:
```
../../../../source/glib/gio/tests/gdbus-tests.c:146:3: warning: Value stored to 'watch_id' is never read [deadcode.DeadStores]
  watch_id = 0;
  ^
```

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

Helps: #1767
2022-04-28 10:43:13 +01:00
Philip Withnall
86b8891add gmain: Initialise a variable
This fixes a scan-build warning:
```
../../../../source/glib/glib/gmain.c:4193:18: warning: 2nd function call argument is an uninitialized value [core.CallAndMessage]
  while ((nfds = g_main_context_query (context, max_priority, &timeout, fds,
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

This is a valid situation which can occur if the preceding
`g_main_context_prepare()` call returns `FALSE` and doesn’t set
`max_priority`.

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

Helps: #1767
2022-04-28 10:40:38 +01:00
Philip Withnall
7a1a9259a1 gmessages: Clear address before passing it to getpeername()
This will probably make no functional difference, but will squash a
warning from scan-build:
```
../../../../source/glib/glib/gmessages.c:2243:42: warning: The left operand of '==' is a garbage value [core.UndefinedBinaryOperatorResult]
  if (err == 0 && addr.storage.ss_family == AF_UNIX)
                  ~~~~~~~~~~~~~~~~~~~~~~ ^
```

It seems like a reasonable thing to warn about. Initialising the full
union to zero should avoid any possibility of undefined behaviour like
that.

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

Helps: #1767
2022-04-28 10:36:37 +01:00
Emmanuel Fleury
fe2619079f Expand ghook unit tests for a better coverage and better control 2022-04-28 10:35:36 +02:00
Sebastian Dröge
0c1b7b263e Merge branch 'multicast-memcpy-size' into 'main'
gsocket: Add assertions about socket address sizes for memcpy()

See merge request GNOME/glib!2625
2022-04-27 14:32:16 +00:00
Sebastian Dröge
4a1ffd1c79 Merge branch 'gio-tool-set-leak' into 'main'
gio-tool: Fix a minor memory leak when using gio-set with bytestrings

See merge request GNOME/glib!2626
2022-04-27 14:32:13 +00:00
Philip Withnall
49cc9b96f4 gio-tool: Fix a minor memory leak when using gio-set with bytestrings
Tested using:
```sh
touch ~/foo
gio set ~/foo -t bytestring user::test "\x00\x00"
```
(it doesn’t matter that this fails; the bytestring is still decoded)

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

Coverity CID: #1474407
2022-04-27 15:01:08 +01:00
Philip Withnall
ff944776fe gsocket: Add assertions about socket address sizes for memcpy()
These `memcpy()` calls only happen if `g_inet_address_get_family(group)
== G_SOCKET_FAMILY_IPV4`, so the assertions should never fail.

It’s helpful for understanding the code, and for static analysis, to add
the assertions though.

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

Coverity CID: #1486858
2022-04-27 14:47:35 +01:00
Philip Withnall
1dfea6bc93 Merge branch 'timeloop_test' into 'main'
Remove tests/timeloop.c and tests/timeloopbasic.c

See merge request GNOME/glib!2609
2022-04-27 11:47:30 +00:00
Emmanuel Fleury
fd8424a974 Removing unused tests/timeloop.c and tests/timeloop-basic.c
Remove unused tests/timelooop.c and tests/timeloop-basic.c because
these programs are manual performance tests which are no more relevant
for glib. They were used for the writing of GMainLoop but since then
they haven't not much been used in 22 years, it is safe to remove them.

Helps issue #1434
2022-04-26 20:20:03 +02:00
Philip Withnall
eec65c761b gthread: Fix futex timespec type on 32-bit kernels with 64-bit userspace
The `struct timespec` type documented as being passed to the `futex()`
syscall actually needs to be the *kernel’s* timespec type. This will be
a different width from the userspace timespec type if running a 64-bit
userspace on a 32-bit kernel.

That mismatch will cause `g_cond_wait_until()` to return `FALSE`
immediately.

No other uses of `futex()` in GLib use the timeout argument, so they’re
all OK.

Following a detailed suggestion by Rich Felker, pass a different
timespec type into `futex()` if `__NR_futex_time64` is defined. That’s
the 64-bit time version of `futex()` which was added in kernel 5.1, and
which was only added for 32-bit kernels.

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

Fixes: #2634
2022-04-26 13:15:07 +01:00
Philip Withnall
606bdcdb18 Merge branch 'main' into 'main'
Fix the annotation of g_utf8_strncpy()

See merge request GNOME/glib!2621
2022-04-26 10:23:27 +00:00
Hodong
797bcf3224 Fix the annotation of g_utf8_strncpy() 2022-04-26 18:54:57 +09:00
Sebastian Dröge
fa55f37a88 Merge branch 'log-writer-checks' into 'main'
gmessages: Error if g_log_set_writer_func() is called multiple times

See merge request GNOME/glib!2617
2022-04-26 07:41:56 +00:00
Philip Withnall
862e250eaa Merge branch 'fixes_in_tests' into 'main'
Fixes in tests

See merge request GNOME/glib!2608
2022-04-25 17:30:54 +00:00
Philip Withnall
b56f10c890 Revert "glib/gstdio: simplify GStatBuf macro condition for win64"
This reverts commit ae1cccaa0a.

It broke ABI on 64-bit builds with MSVC, as discussed here:
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2449#note_1430571.

Fixes: #2633
2022-04-25 17:58:04 +01:00
Philip Withnall
8a498fa989 gversion: Clarify that GLIB_CHECK_VERSION is a >= check
The documentation body makes it sound like it might be a `==` check;
only the ‘returns’ line previously clarified this.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-04-25 15:20:16 +01:00
Philip Withnall
6dc7b100f5 Merge branch 'gbookmarkfile_tests' into 'main'
Expand tests on gbookmark file API

See merge request GNOME/glib!2610
2022-04-25 13:37:43 +00:00
Philip Withnall
dfb3517d37 gmessages: Error if g_log_set_writer_func() is called multiple times
Inspired by https://gitlab.gnome.org/GNOME/glib/-/issues/2638.

This requires moving the tests to subprocesses, so that
`g_log_set_writer_func()` is only called once per process.

It also adds a test for the new error.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-04-25 12:38:59 +01:00
Philip Withnall
a44a0c07bd Merge branch 'gtype-boxed-type-macro' into 'main'
docs: Expand G_DEFINE_BOXED_TYPE docs with more detailed example

See merge request GNOME/glib!2612
2022-04-25 10:39:27 +00:00
Logan Rathbone
3a4f0746f5 docs: Expand G_DEFINE_BOXED_TYPE docs with more detailed example 2022-04-25 10:39:27 +00:00
Philip Withnall
cc99d6ee97 Merge branch 'gio-windows' into 'main'
Meson: Fix gio-windows-2.0 override name

See merge request GNOME/glib!2615
2022-04-25 10:30:11 +00:00
Philip Withnall
231a4bb9cb Merge branch 'update-inout-annotations' into 'main'
Add inout annotations for g_iconv

See merge request GNOME/glib!2614
2022-04-25 10:28:39 +00:00
Philip Withnall
7ab50b9e29 Merge branch 'gtestutils-add-stdlib' into 'main'
gtestutils: Include stdlib.h for exit function

See merge request GNOME/glib!2613
2022-04-25 10:27:15 +00:00
Xavier Claessens
199ff2a841 Meson: Fix gio-windows-2.0 override name
The override name must match the pkgconfig name.
2022-04-24 21:29:26 -04:00
TestingPlant
39378b2581 Add inout annotations for g_iconv 2022-04-24 19:15:53 +00:00
Bruce Cowan
444fc6ccda Update British English translation
(cherry picked from commit 82feda1ccf)
2022-04-24 10:31:01 +00:00
Biswapriyo Nath
3c841f18c1 gtestutils: Include stdlib.h for exit function
This fixes warning: implicit declaration of function 'exit'
2022-04-23 14:02:10 +05:30
Milo Ivir
497aba96f1 Update Croatian translation 2022-04-20 17:46:52 +00:00
Emmanuel Fleury
6eddfefbfc Expand tests on gbookmark file API 2022-04-19 16:38:41 +02:00
Ask Hjorth Larsen
d147c36bc6 Updated Danish translation 2022-04-18 19:25:00 +02:00
Emmanuel Fleury
b5c162635c Fix spelling mistake in filename when unlinking it after the test. 2022-04-17 08:08:30 +02:00
Emmanuel Fleury
9ed0dc5583 Clean the file "iochannel-test-outfile" after the test test_small_writes() 2022-04-17 08:08:30 +02:00
Emmanuel Fleury
8901898da2 Cleaning file 'filename' after the test in glib/tests/fileutils.c 2022-04-17 08:08:23 +02:00
Enrico Nicoletto
15d6558ea2 Update Brazilian Portuguese translation 2022-04-15 17:07:22 +00:00
Philip Withnall
41fcb33034 tests: Fix a minor leak in the unicode-normalize test
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Coverity CID: #1487904
2022-04-14 13:26:25 +01:00
Philip Withnall
d987146fe1 Merge branch 'w32-tests' into 'main'
Fix test suite on Windows

See merge request GNOME/glib!2449
2022-04-14 12:16:19 +00:00