Commit Graph

18343 Commits

Author SHA1 Message Date
Ting-Wei Lan
09c019a4f0 kqueue: Make it possible to pass file monitor tests
Previously, kqueue file monitor only add event sources for directories
regardless of the type of the file being monitored. Doing so may be
possible on inotify, but it is not sufficient on kqueue. Watching a
directory on kqueue doesn't report changes made to files under it, and
we must watch files themselves to get notified. This problem is fixed
by adding a second watch for non-directory file monitors, and the result
is that we are now able to receive 'CHANGED' and 'ATTRIBUTE_CHANGED'
events for non-directory files.

Since having two watches on one file monitor requires many code changes
to work properly, this commit also changes the following things:

 - NOTE_ALL macro is now replaced by note_all inline function. Since the
   kqueue backend is shared by all BSD operating systems, there are a
   few difference between these systems. It is easier to do '#ifdef'
   check in a function than in a macro.

 - Both g_kqueue_file_monitor_callback and g_kqueue_file_monitor_cancel
   now holds a lock before accessing kqueue_sub structs. This fixes a
   crash when these two functions are called from different threads,
   causing g_kqueue_file_monitor_callback to access freed memory.

 - 'mask' variable in g_kqueue_file_monitor_callback is now removed.
   The usage of 'mask' was wrong because of the 'mask > 0' check.
   'CHANGED' event has value 0 so the 'mask > 0' check made it
   impossible to emit 'CHANGED' events.

 - kqueue-missing scans can now be triggered from the kqueue event
   callback instead of always waiting for 4 seconds.

 - Don't remove a file from kqueue on unlink unless its hard link count
   has dropped to zero.

 - Don't use 'else if' in the check of 'fflags'. It is possible for a
   kevent to have multiple flags set.

 - Don't use g_file_monitor_emit_event directly. Always use
   g_file_monitor_source_handle_event to report events.
   Events submitted to g_file_monitor_emit_event are delivered
   immediately, but events sent to g_file_monitor_source_handle_event
   are scheduled by GLocalFileMonitor. If we mix the two, the order of
   events will be wrong and tests will fail.

 - Report 'CHANGES_DONE_HINT' immediately after 'CREATED' if the file
   created is not a regular file. This is copied from ih_event_callback.
2018-06-17 11:26:32 +08:00
Philip Withnall
b4259dec70 Merge branch 'wip/oholy/gunixmountfor-docs' into 'master'
docs: Document g_unix_mount_for

See merge request GNOME/glib!66
2018-06-06 11:03:32 +00:00
Philip Withnall
205059b9c0 Merge branch 'wip/oholy/trashing-locations' into 'master'
glocalfile: Allow trashing only for locations supported by trash:///

See merge request GNOME/glib!49
2018-06-06 10:58:22 +00:00
Ondrej Holy
8df517b457 docs: Document g_unix_mount_for
g_unix_mount_for() has been added into GLib before some time,
however, it is missing in the docs.
2018-06-06 12:24:12 +02:00
Ondrej Holy
f7e80f8d0c glocalfile: Add test case for g_file_trash
g_local_file_trash has been changed to return G_IO_ERROR_NOT_SUPPORTED
for locations on system-internal mounts. Let's verify that.

https://gitlab.gnome.org/GNOME/glib/issues/251
2018-06-06 12:18:30 +02:00
Marek Cernocky
5107d209d8 Updated Czech translation 2018-06-06 11:06:49 +02:00
Philip Withnall
f06ba1722c Merge branch 'solaris-defines' into 'master'
Meson: Add missing defines on Solaris

See merge request GNOME/glib!64
2018-06-06 01:55:43 +00:00
Xavier Claessens
02bac34921 Merge branch 'drop-unused-defines' into 'master'
Remove unused HAVE_LONG_LONG_FORMAT and HAVE_LONG_LONG_FORMAT

See merge request GNOME/glib!63
2018-06-05 23:32:20 +00:00
Xavier Claessens
6ed57f8e26 Meson: Add missing defines on Solaris
We have no way to test Solaris builds atm, and it is not even clear how
to detect Solaris systems with meson. It will probably need to be
revisited when we get a proper CI in place.
2018-06-05 19:30:16 -04:00
Xavier Claessens
65bd090d57 Remove unused HAVE_LONG_LONG_FORMAT and HAVE_INT64_AND_I64 2018-06-05 19:04:48 -04:00
Philip Withnall
8683e029be Merge branch 'ci-cleanup' into 'master'
ci: small cleanups

See merge request GNOME/glib!62
2018-06-05 22:30:16 +00:00
Xavier Claessens
79c1cd21f2 ci: Be consistent on artifact naming 2018-06-05 14:01:53 -04:00
Xavier Claessens
a4ccb4972c ci: No need to "cd _build" and set prefix/libdir 2018-06-05 13:58:48 -04:00
Xavier Claessens
34e0c5a799 ci: Add missing "except: tags" 2018-06-05 13:39:26 -04:00
Christoph Reiter
0a36314b28 Merge branch 'meson-unused-zlib-libname' into 'master'
Meson: Remove unused zlib_libname variable

See merge request GNOME/glib!61
2018-06-05 15:37:57 +00:00
Xavier Claessens
9229f96fd6 Meson: Remove unused zlib_libname variable 2018-06-05 10:51:03 -04:00
Xavier Claessens
68d99c766b Merge branch 'patch-2' into 'master'
Fix potential Null pointer dereference

See merge request GNOME/glib!60
2018-06-05 14:38:44 +00:00
Gaurav
4ade09416b Fix potential Null pointer dereference.
if "match" is NULL, it is dereferenced in match_free() (L:457)
2018-06-05 14:01:47 +00:00
Ondrej Holy
6dfd0a00e7 glocalfile: Update G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH logic
Change G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH logic to be consistent
with recent g_local_file_trash changes, i.e. set this to FALSE for
locations on system-internal mounts.

https://gitlab.gnome.org/GNOME/glib/issues/251
2018-06-05 14:53:15 +02:00
Ondrej Holy
15a47afb0e glocalfile: Allow trashing only for locations supported by trash:///
New bugs appears periodically in nautilus/gvfs/glib components that not
all trashed files are shown in trash:///. It used to be problem mostly
for "bind mounts" and btrfs subvolumes only. Currently, it is also
problem for nfs, cifs and other filesystems, which have been recently
added by commmit 0d69462f on the list of system internal filesystems.

This happens because the trash backend doesn't monitor files on system
internal mounts. Such behavior is not against the trash-spec, however,
we should be consistent within GNOME.

This behavior has the nice side-effect that it solves issues with hangs
on network filesystems: https://gitlab.gnome.org/GNOME/glib/issues/605,
because those are currently on the system internal filesystem list.

https://gitlab.gnome.org/GNOME/glib/issues/251
2018-06-05 14:53:15 +02:00
Philip Withnall
1e9060547d Merge branch '1307-tarball-dist' into 'master'
Remove some files not included in tarballs

Closes #1307

See merge request GNOME/glib!58
2018-06-05 09:10:21 +00:00
Xavier Claessens
27ec1469ab Remove developer script not needed in git repository 2018-06-04 22:27:22 -04:00
Xavier Claessens
b04cf01934 Remove old tests not being built since 2012
Those tests are failing and are not built since commit d6a075b
2018-06-04 22:18:02 -04:00
Xavier Claessens
4a369a0b6c Remove tests/gio-ls.c that never has been built 2018-06-04 21:53:00 -04:00
Philip Withnall
95ebaa26aa Merge branch '1401-g_clear_handle_id-clear_func-not-nullable' into 'master'
g_clear_handle_id: don't accept NULL clear_func

Closes #1401

See merge request GNOME/glib!55
2018-06-04 13:41:10 +00:00
Will Thompson
0f7c196c21
g_clear_handle_id: don't accept NULL clear_func
Fixes #1401.
2018-06-04 13:11:49 +01:00
Philip Withnall
e0f82b9494 Merge branch '1374-array-tests' into 'master'
Resolve "Fix g_array_insert_vals() with an index off the end of the array"

Closes #1374

See merge request GNOME/glib!12
2018-06-04 10:34:28 +00:00
Philip Withnall
80243e65b6 tests: Expand GArray test coverage to cover all construction forms
Previously, there was very little coverage of GArray behaviour with
either of the zero_terminated or clear_ arguments to g_array_new() set
to TRUE.

Parameterise the tests and exhaustively expand the coverage to cover all
possible GArray configurations.

This was made possible by the online code coverage report for GLib which
we now have:
https://gnome.pages.gitlab.gnome.org/glib/coverage/glib/garray.c.gcov.html.

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

https://bugzilla.gnome.org/show_bug.cgi?id=795975
2018-06-04 11:11:26 +01:00
Philip Withnall
89f45e96b2 garray: Allow over-allocation in g_array_insert_vals()
Previously, g_array_insert_vals() would crash if called with an index
off the end of the array. This is inconsistent with the behaviour of
other methods (like g_array_set_size()), which will expand the array as
necessary.

Modify g_array_insert_vals() to expand the array as necessary. New array
elements will be cleared to zero if the GArray was constructed with
(clear_ == TRUE).

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

https://bugzilla.gnome.org/show_bug.cgi?id=795975
2018-06-04 11:11:26 +01:00
Philip Withnall
3eeec77800 garray: Fix (nullable) annotation on GArray.[prepend|insert]_vals()
They do both accept NULL value arrays, but only if the number of
elements in the value array is zero. Fix the annotations and mention
this in the documentation.

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

https://bugzilla.gnome.org/show_bug.cgi?id=795975
2018-06-04 11:11:26 +01:00
Xavier Claessens
05fe110635 Merge branch 'remove-disable-mem-pools' into 'master'
build: Remove the --disable-mem-pools build option and the DISABLE_MEM_POOLS macro

See merge request GNOME/glib!52
2018-06-03 03:22:18 +00:00
Christoph Reiter
3aa23078ac build: Remove the --disable-mem-pools build option and the DISABLE_MEM_POOLS macro
It's mostly not used anymore and doesn't do what it says it does.

The docs state that it affects GList, GSList, GNode, GMemChunks, GSignal,
GType n_preallocs and GBSearchArray while:

* GList, GSList and GNode use GSlice and are not affected
* GMemChunks is gone
* GType npreallocs is ignored

It also states that it can be used to force the usage of g_malloc/g_free,
which is handled by G_SLICE=always-malloc now.

The only places where it's used is in signal handling through GBSearchArray
and in GValueArray (deprecated). Since it's unlikely that anyone wants to
reduce allocation sizes just for those cases remove the build option.
2018-06-02 09:45:55 +02:00
Christoph Reiter
553df9dcaf Merge branch 'fix-gdbus-unix-addresses-test' into 'master'
Fix failing gdbus-unix-addresses test when G_MESSAGES_DEBUG is set

See merge request GNOME/glib!50
2018-06-01 15:31:25 +00:00
Nirbheek Chauhan
b1ce8344b7 Merge branch 'patch-1' into 'master'
Fix a warning reported by static analyser tool

See merge request GNOME/glib!44
2018-06-01 14:30:14 +00:00
Xavier Claessens
f929d14826 Fix failing gdbus-unix-addresses test when G_MESSAGES_DEBUG is set
This test assumes the subprocess does not print anything else on stdout
other than the dbus address, otherwise g_test_trap_assert_stdout()
fails to match. But if the env running tests has G_MESSAGES_DEBUG=all
then it will also print "PATH=%s".
2018-06-01 10:23:12 -04:00
Xavier Claessens
a3c061a814 Merge branch 'remove-gc-friendly-default' into 'master'
Remove unused ENABLE_GC_FRIENDLY_DEFAULT and its build option

See merge request GNOME/glib!43
2018-05-31 17:36:25 +00:00
Xavier Claessens
09b8c6d24b Merge branch 'remove-secure-libc' into 'master'
Remove unused HAVE_LIBC_ENABLE_SECURE  and add a glibc implementation for g_check_setuid

See merge request GNOME/glib!45
2018-05-31 16:20:12 +00:00
Emmanuele Bassi
54db9d3fc3 Merge branch 'remove-posix-memalign-compl-check' into 'master'
Remove posix_memalign() checks for an old glibc bug

See merge request GNOME/glib!47
2018-05-31 13:03:41 +00:00
Emmanuele Bassi
dd4f44fd04 Merge branch 'remove-no-fd-set' into 'master'
Remove NO_FD_SET and assume fd_set exists

See merge request GNOME/glib!46
2018-05-31 12:42:38 +00:00
Christoph Reiter
fe59a18f89 Remove posix_memalign() checks for an old glibc bug
POSIX_MEMALIGN_WITH_COMPLIANT_ALLOCS was added in
https://bugzilla.gnome.org/show_bug.cgi?id=328254
to work around a glibc bug where it wrongly checked the size argument
to be a power of two instead of the alignment.

This was fixed in glibc in
https://sourceware.org/git/?p=glibc.git;a=commit;h=b2bffca2e3b59dd882039e3b0ab835d127bdaf7a
about 16 years ago.
2018-05-31 14:29:33 +02:00
Christoph Reiter
b6c81d139c Remove NO_FD_SET and assume fd_set exists
gspawn.c is using fd_set without checks for 17 years now and the NO_FD_SET check was added
19 years ago.
2018-05-31 13:31:55 +02:00
Christoph Reiter
a7fefb0e4e g_check_setuid: implement using getauxval(AT_SECURE) with glibc
See commit 4c2928a544 for why checking AT_SECURE is preferable compared
to UID checks as currently done in the fallback case.

getauxval() was added with glibc 2.16

While glibc <2.19 didn't provide a way to differentiate a 0 return value from an error,
passing AT_SECURE should always succeed according to
https://sourceware.org/ml/libc-alpha/2014-07/msg00407.html
I've added an errno check anyway, to be on the safe side.
2018-05-31 12:02:36 +02:00
Christoph Reiter
41165b2a7e Remove unused HAVE_LIBC_ENABLE_SECURE
It was added in 4c2928a544 to potentially enable accessing
AT_SECURE through __libc_enable_secure, but was never enabled.

Newer glibc provides getauxval(AT_SECURE) which should be used instead.
Add a TODO note for that.
2018-05-31 10:58:27 +02:00
Gaurav
593eeff55e Fix a warning reported by static analyser tool:
Assignment of a signed value which has type 'time_t' to a variable of a bigger integer type 'guint64'
2018-05-31 08:25:31 +00:00
Christoph Reiter
118332dd5c Remove unused ENABLE_GC_FRIENDLY_DEFAULT and its build option
ENABLE_GC_FRIENDLY_DEFAULT was supposed to set the default for the gc friendliness
while still allowing to force enable it at runtime with G_DEBUG=gc-friendly.

With commit 943a18b564 (6 years ago) things were changed to always set it
according to the content of G_DEBUG in glib_init(), making the default unused.

Since nobody complained since then just remove the macro and the build option.
2018-05-31 07:19:12 +02:00
Philip Withnall
e03f83212d Merge branch '796385-indentation' into 'master'
Fix misleading indentation (bug #796385)

See merge request GNOME/glib!42
2018-05-30 09:33:56 +00:00
Philip Withnall
61b2f5c8e1 build: Always enable -Wmisleading-indentation
Try and ensure that people don’t push code with misleading indentation
in future. This should give fairly few false positives.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-05-30 10:12:01 +01:00
Iain Lane
51d566ba6e test_paths: Reindent to avoid tripping -Wmisleading-indentation
This fixes:

glib/tests/testglib.c: In function ‘test_paths’:
glib/tests/testglib.c:955:3: error: this ‘if’ clause does not guard... [-Werror=misleading-indentation]
   if (g_test_verbose ())
   ^~
glib/tests/testglib.c:958:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
     {
     ^

https://bugzilla.gnome.org/show_bug.cgi?id=796385
2018-05-30 10:07:35 +01:00
Philip Withnall
2dce3ce125 Merge branch 'win-date-fixes' into 'master'
gdate: Use a more recent year when fetching the month names. Fixes #1386

Closes #1386

See merge request GNOME/glib!40
2018-05-29 16:35:12 +00:00
Philip Withnall
42a9e80ab1 Merge branch 'remove-winxp-comapt-code' into 'master'
Remove winxp compat code

See merge request GNOME/glib!41
2018-05-29 16:07:48 +00:00