Commit Graph

22016 Commits

Author SHA1 Message Date
Marc-André Lureau
6f419e7e2f gio: use g_uri_split_network() in g_network_address_parse_uri()
_g_uri_parse_authority() can be replaced with g_uri_split_network() &
PARSE_STRICT. Keep the original error code, for compatibility reasons.

Notice that GUri uses gint for the port, and value -1 if the port value
is missing. However, GNetworkAddress::port is a guint.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-28 16:31:11 +04:00
Marc-André Lureau
a173a6f617 gio: use g_uri_is_valid()
_g_uri_parse_authority() without argument is actually checking that the
URI is valid, by checking it parses successfully

We keep the existing error domain / code for compatibility reasons,
instead of raising the underlying G_URI_ERROR.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-28 16:15:50 +04:00
Marc-André Lureau
034a4dcdc0 gio: replace _g_uri_from_authority() with g_uri_join()
_g_uri_from_authority() is doing the same work as g_uri_join(): taking
URI components and merging them in a legit URI string, with encoding.

It turns out g_uri_from_authority was unnecessarily complex, since no
caller used the userinfo field.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-28 16:12:37 +04:00
Marc-André Lureau
82ad7853ba uri: change g_uri_is_valid() to check absolute URI
g_uri_is_valid() should check the given URI is valid following RFC-3986,
and reject relative references.

Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/2169

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-28 15:44:43 +04:00
Marc-André Lureau
44d4640c47 uri: rename absolute & relative uri_string to uri_ref
Let's reserve the term URI for absolute URIs, following rfc3986
terminology.

See:
https://gitlab.gnome.org/GNOME/glib/-/issues/2169

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-28 15:07:08 +04:00
Marc-André Lureau
d625a29b28 uri: add a comment about temporary GUri construction
As pointed out in the discussion of:
https://gitlab.gnome.org/GNOME/glib/-/issues/2169

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-28 14:54:55 +04:00
Marc-André Lureau
19c0db3185 uri: improve some documentation about absolute URIs
As pointed out in the discussion
https://gitlab.gnome.org/GNOME/glib/-/issues/2169.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-28 14:54:55 +04:00
Marc-André Lureau
3521763532 uri: add some note about the API scope
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-28 14:54:42 +04:00
Sebastian Dröge
9577616622 Merge branch '272-thread-pool-docs' into 'master'
gthreadpool: Mention g_get_num_processors() in the thread pool docs

Closes #272

See merge request GNOME/glib!1588
2020-07-27 19:04:11 +00:00
Philip Withnall
1203e80f5f Merge branch '250-testcase-docs' into 'master'
gtestutils: Clarify the docs for g_test_create_case()

Closes #250

See merge request GNOME/glib!1587
2020-07-27 17:01:16 +00:00
Philip Withnall
b3c0c4804b gthreadpool: Mention g_get_num_processors() in the thread pool docs
Just to make it a little more obvious that a thread pool can be
initialised with one thread per logical CPU.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #272
2020-07-27 17:28:43 +01:00
Philip Withnall
07278e73d4 gtestutils: Clarify the docs for g_test_create_case()
Improve formatting, and clarify that the same *type* of test fixture can
be reused, not the same specific instance of a test fixture.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #250
2020-07-27 17:26:56 +01:00
Sebastian Dröge
5ba5f5b686 Merge branch '137-gfileinfo-display-name-docs' into 'master'
gfileinfo: Clarify docs to say that name and display-name are set

Closes #137

See merge request GNOME/glib!1585
2020-07-27 13:12:44 +00:00
Philip Withnall
5b429344b5 Merge branch '1869-ios-cocoa' into 'master'
gosxutils: Include Foundation rather than Cocoa

Closes #1869

See merge request GNOME/glib!1589
2020-07-27 12:41:27 +00:00
Philip Withnall
9c6c546236 gosxutils: Include Foundation rather than Cocoa
Apparently, the function calls added in 11729cdc use Foundation, not
Cocoa. Cocoa is a massive superset of Foundation, and is not available
on iOS.

Patch contributed by Jay Freeman, but without providing an e-mail
address. So the git commit cannot be attributed to him.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1869
2020-07-27 13:21:20 +01:00
Sebastian Dröge
4bd74ac582 Merge branch 'wip/pwithnall/bsd-nofollow' into 'master'
gfileutils: Fix O_NOFOLLOW handling on BSD systems

See merge request GNOME/glib!1591
2020-07-27 12:01:19 +00:00
Sebastian Dröge
62a54a90b2 Merge branch '4-strescape-utf8' into 'master'
Add some g_strescape() tests

Closes #4

See merge request GNOME/glib!1584
2020-07-27 11:49:44 +00:00
Sebastian Dröge
6a87f7ed6f Merge branch 'bandwidth' into 'master'
Reduce CI bandwidth requirements

See merge request GNOME/glib!1570
2020-07-27 11:31:38 +00:00
Sebastian Dröge
79aeba33c7 Merge branch 'ci-schedules' into 'master'
Use CI schedules and DAGs

See merge request GNOME/glib!1590
2020-07-27 11:30:33 +00:00
Philip Withnall
b4aa9d7858 gfileutils: Fix O_NOFOLLOW handling on BSD systems
Various different BSD systems use a different errno from `E_LOOP` (as
defined by POSIX and used on Linux) to indicate that a file is a symlink
when you try to `open()` it with `O_NOFOLLOW`.

Fix the code which detects this. This is a follow-up to #1302.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-27 12:24:20 +01:00
Philip Withnall
410ee530b5 ci: Add DAG attributes
Add some basic DAG attributes so that some jobs in the pipeline can
run out of stage order to speed things up a little.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-27 12:10:54 +01:00
Philip Withnall
feab973662 ci: Move some CI jobs from branches to schedules
These jobs (`scan-build` and `valgrind`) take ages to run and rarely
indicate failures, so move them to a weekly schedule, rather than
running them on each branch/MR.

The current schedule is once weekly:
https://gitlab.gnome.org/GNOME/glib/-/pipeline_schedules.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-27 12:10:41 +01:00
Sebastian Dröge
87bc87ae69 Merge branch '1022-g-object-new-zeros-docs' into 'master'
gobject: Document that g_object_new() zeros out private data

Closes #1022

See merge request GNOME/glib!1586
2020-07-27 08:09:07 +00:00
Philip Withnall
b79747eee1 Merge branch 'remove-broken-xp-code' into 'master'
gio: Remove broken support for XP

See merge request GNOME/glib!1583
2020-07-27 02:07:43 +00:00
Philip Withnall
41937c3631 gobject: Document that g_object_new() zeros out private data
It’s already mentioned at
https://developer.gnome.org/gobject/stable/chapter-gobject.html#gobject-instantiation,
but is important enough that mentioning it in the documentation for
`g_object_new()` seems helpful.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1022
2020-07-27 01:57:57 +01:00
Philip Withnall
0544fdff5f gfileinfo: Clarify docs to say that name and display-name are set
They are always available, for all files.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #137
2020-07-27 00:45:31 +01:00
Philip Withnall
1ef6e84012 tests: Add some tests for expanding invalid escapes with g_strcompress()
This brings the branch coverage of `g_strcompress()` up to 100%. Yay.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-26 23:22:06 +01:00
Philip Withnall
59eb3c5bdb tests: Add missing cast to URI tests
This fixes a compiler warning.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-26 23:05:31 +01:00
Philip Withnall
437526675a tests: Test that UTF-8 is escaped correctly by g_strescape()
`g_strescape()` is documented as escaping UTF-8 characters, so test that
it does.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #4
2020-07-26 23:04:37 +01:00
Philip Withnall
a84f241dd7 Merge branch '1302-file-set-contents-fsync' into 'master'
gfileutils: Add g_file_set_contents_full() and GFileSetContentsFlags

Closes #1203 and #1302

See merge request GNOME/glib!369
2020-07-26 21:35:35 +00:00
Philip Withnall
5bf3849099 tests: Add tests for g_file_set_contents_full()
These exercise all the code paths I can manage without adding a load of
machinery to inject faults into `write()`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1302
2020-07-26 21:38:17 +01:00
Philip Withnall
f35f9e918a tests: Use G_TEST_OPTION_ISOLATE_DIRS for fileutils tests
They all still pass.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-26 21:38:17 +01:00
Philip Withnall
cd02eac2d4 gstdio: Add macOS support to g_fsync()
Apparently, `fsync()` doesn’t actually sync to the spinning disk on
macOS. You need an `fcntl()` for that.

See: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/fsync.2.html

Spotted by Christoph Reiter in a comment on !369.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-26 21:38:17 +01:00
Philip Withnall
926dfe5925 gstdio: Handle EINTR in g_fsync()
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-26 21:38:17 +01:00
Philip Withnall
84dd89242a gfileutils: Use g_fsync() for platform-independence
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-26 21:38:17 +01:00
Philip Withnall
ea2db92034 glocalfileoutputstream: Use g_fsync() for platform-independence
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-26 21:38:17 +01:00
Philip Withnall
3b6460b94c glib: Use g_file_set_contents_full() throughout GLib and GIO
Where applicable. Where the current use of `g_file_set_contents()` seems
the most appropriate, leave that in place.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1302
2020-07-26 21:37:46 +01:00
Philip Withnall
24ed91ce33 gfileutils: Add a mode argument to g_file_set_contents_full()
This is used when creating the temporary file, or new file from scratch.

I wondered about also allowing the file owner and group to be set, but
that’s not as generally applicable — if your process is operating across
multiple user IDs then it likely has some fairly OS-specific
requirements and will need tighter control of its syscalls anyway.

(Eventually, support for setting the file owner and group atomically
could be added by writing out a file using `O_TMPFILE` so it’s not
addressable, and then linking it into the file system in place of the
old file using something like `renameat2(AT_EMPTY_PATH)` or `linkat()`.
That’s currently not possible without patching the kernel with
https://marc.info/?l=linux-fsdevel&m=152472898003523&w=2, as far as I
know at the moment.)

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1203
2020-07-26 21:37:46 +01:00
Philip Withnall
f3cea1c464 gfileutils: Implement GFileSetContentsFlags
This moves `write_to_temp_file()` into `g_file_set_contents_full()` and
coalesces its handling of `do_fsync` with the `rename_file()` call. It
adds support for `G_FILE_SET_CONTENTS_DURABLE` and
`G_FILE_SET_CONTENTS_NONE` — previously only
`G_FILE_SET_CONTENTS_CONSISTENT | G_FILE_SET_CONTENTS_ONLY_EXISTING` was
supported.

In the case that `G_FILE_SET_CONTENTS_CONSISTENT |
G_FILE_SET_CONTENTS_DURABLE` is set, an additional `fsync()` is now done
on the directory after renaming the temporary file.

In the case that `G_FILE_SET_CONTENTS_ONLY_EXISTING` isn’t set, the
`fsync()` after writing the temporary file will always be done (unless
the file system guarantees it never needs to be done).

In the case that only `G_FILE_SET_CONTENTS_DURABLE` is set, the
destination file will be written to directly (using this mode is not
really advised).

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1302
2020-07-26 21:37:46 +01:00
Philip Withnall
387c159862 gfileutils: Tidy up types of length arguments in helper functions
We can guarantee that they’re non-negative.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1302
2020-07-26 21:37:46 +01:00
Philip Withnall
e4e618c604 gfileutils: Factor out fsync calculation
This introduces no functional changes, just makes the code a bit more
modular and reusable.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1302
2020-07-26 21:37:46 +01:00
Philip Withnall
00c17de72e gfileutils: Split out write_to_file() helper function
This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1302
2020-07-26 21:37:46 +01:00
Philip Withnall
554107c23c gfileutils: Add g_file_set_contents_full() and GFileSetContentsFlags
This is a new version of the g_file_set_contents() API which will allow
its safety to be controlled by some flags, allowing the user to choose
their preferred tradeoff between safety (`fsync()` calls) and speed.

Currently, the flags do nothing and the new API behaves like the old
API. This will change in the following commits.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1302
2020-07-26 21:37:46 +01:00
Nirbheek Chauhan
4e485d76ac gio: Remove broken support for XP
We now require Windows 7 or newer, and the networking code hasn't
worked in a long time since we directly use symbols from iphlapi.dll
now.
2020-07-26 21:30:05 +05:30
Marc-André Lureau
5b49df3b9f Merge branch 'uri-non-utf8' into 'master'
Fix non-utf8 URI pct-decoding / unescape regression

Closes #2165

See merge request GNOME/glib!1569
2020-07-26 14:24:53 +00:00
Philip Withnall
c60d6599c9 Merge branch 'mach_monotonic_time_use_timebase_struct' into 'master'
gmain: fix fetching timebase on non-Intel Darwin

Closes #858

See merge request GNOME/glib!1566
2020-07-26 13:22:48 +00:00
Marc-André Lureau
22fe3b0224 uri: fix regression in g_uri_unescape_segment/string
The previous implementation of g_uri_unescape_segment() allowed non-utf8
decoded characters. uri_decoder() allows it too with FLAGS_ENCODED (I
think it's abusing a bit the user-facing flags for some internal
decoding behaviour)

However, it didn't allow \0 in the decoded string. Let's have an extra
check for that, outside of uri_decoder().

Fixes: d83d68d64c
Reported-by: Matthias Clasen <mclasen@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-26 17:19:43 +04:00
Marc-André Lureau
ea395e3fdd uri: add a GError to the new g_uri_unescape_bytes()
Suggested-by: Matthias Clasen <mclasen@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-26 17:19:37 +04:00
Philip Withnall
d5513ef72c Merge branch 'giomodule-cache' into 'master'
Fix giomodule.cache being wrongly considered stale

Closes #2127

See merge request GNOME/glib!1560
2020-07-25 23:10:25 +00:00
Philip Withnall
41ffa411e8 Merge branch '2132-quark-ctor-supp' into 'master'
glib.supp: Generalise some g_quark_init() suppressions

Closes #2132

See merge request GNOME/glib!1543
2020-07-25 20:16:03 +00:00