diff --git a/docs/reference/glib/meson.build b/docs/reference/glib/meson.build index 1a36809..f0f915e 100644 --- a/docs/reference/glib/meson.build +++ b/docs/reference/glib/meson.build @@ -20,7 +20,6 @@ if get_option('gtk_doc') 'gprintfint.h', 'gmirroringtable.h', 'gscripttable.h', - 'gstrfuncsprivate.h', 'glib-mirroring-tab', 'gnulib', 'pcre', diff --git a/gio/Makefile.am b/gio/Makefile.am index f8670d2..16c6387 100644 --- a/gio/Makefile.am +++ b/gio/Makefile.am @@ -859,7 +859,7 @@ gio_probes.h: gio_probes.d < $@.tmp > $@ && rm -f $@.tmp gio_probes.lo: gio_probes.d - $(AM_V_GEN) $(LIBTOOL) --mode=compile $(AM_V_lt) --tag=CC env CFLAGS="$(CFLAGS)" $(DTRACE) -G -s $< -o $@ + $(AM_V_GEN) $(LIBTOOL) --mode=compile $(AM_V_lt) --tag=CC $(DTRACE) -G -s $< -o $@ BUILT_SOURCES += gio_probes.h gio_probes.lo CLEANFILES += gio_probes.h gio_probes.h.tmp diff --git a/gio/gcredentials.c b/gio/gcredentials.c index 75d3332..2e05077 100644 --- a/gio/gcredentials.c +++ b/gio/gcredentials.c @@ -262,35 +262,6 @@ g_credentials_to_string (GCredentials *credentials) /* ---------------------------------------------------------------------------------------------------- */ -#if G_CREDENTIALS_USE_LINUX_UCRED -/* - * Check whether @native contains invalid data. If getsockopt SO_PEERCRED - * is used on a TCP socket, it succeeds but yields a credentials structure - * with pid 0, uid -1 and gid -1. Similarly, if SO_PASSCRED is used on a - * receiving Unix socket when the sending socket did not also enable - * SO_PASSCRED, it can succeed but yield a credentials structure with - * pid 0, uid /proc/sys/kernel/overflowuid and gid - * /proc/sys/kernel/overflowgid. - */ -static gboolean -linux_ucred_check_valid (struct ucred *native, - GError **error) -{ - if (native->pid == 0 - || native->uid == -1 - || native->gid == -1) - { - g_set_error_literal (error, - G_IO_ERROR, - G_IO_ERROR_INVALID_DATA, - _("GCredentials contains invalid data")); - return FALSE; - } - - return TRUE; -} -#endif - /** * g_credentials_is_same_user: * @credentials: A #GCredentials. @@ -320,8 +291,7 @@ g_credentials_is_same_user (GCredentials *credentials, ret = FALSE; #if G_CREDENTIALS_USE_LINUX_UCRED - if (linux_ucred_check_valid (&credentials->native, NULL) - && credentials->native.uid == other_credentials->native.uid) + if (credentials->native.uid == other_credentials->native.uid) ret = TRUE; #elif G_CREDENTIALS_USE_FREEBSD_CMSGCRED if (credentials->native.cmcred_euid == other_credentials->native.cmcred_euid) @@ -480,10 +450,7 @@ g_credentials_get_unix_user (GCredentials *credentials, g_return_val_if_fail (error == NULL || *error == NULL, -1); #if G_CREDENTIALS_USE_LINUX_UCRED - if (linux_ucred_check_valid (&credentials->native, error)) - ret = credentials->native.uid; - else - ret = -1; + ret = credentials->native.uid; #elif G_CREDENTIALS_USE_FREEBSD_CMSGCRED ret = credentials->native.cmcred_euid; #elif G_CREDENTIALS_USE_NETBSD_UNPCBID @@ -529,10 +496,7 @@ g_credentials_get_unix_pid (GCredentials *credentials, g_return_val_if_fail (error == NULL || *error == NULL, -1); #if G_CREDENTIALS_USE_LINUX_UCRED - if (linux_ucred_check_valid (&credentials->native, error)) - ret = credentials->native.pid; - else - ret = -1; + ret = credentials->native.pid; #elif G_CREDENTIALS_USE_FREEBSD_CMSGCRED ret = credentials->native.cmcred_pid; #elif G_CREDENTIALS_USE_NETBSD_UNPCBID diff --git a/gio/gcredentialsprivate.h b/gio/gcredentialsprivate.h index e9ec09b..4d1c420 100644 --- a/gio/gcredentialsprivate.h +++ b/gio/gcredentialsprivate.h @@ -22,77 +22,6 @@ #include "gio/gcredentials.h" #include "gio/gnetworking.h" -/* - * G_CREDENTIALS_SUPPORTED: - * - * Defined to 1 if GCredentials works. - */ -#undef G_CREDENTIALS_SUPPORTED - -/* - * G_CREDENTIALS_USE_LINUX_UCRED, etc.: - * - * Defined to 1 if GCredentials uses Linux `struct ucred`, etc. - */ -#undef G_CREDENTIALS_USE_LINUX_UCRED -#undef G_CREDENTIALS_USE_FREEBSD_CMSGCRED -#undef G_CREDENTIALS_USE_NETBSD_UNPCBID -#undef G_CREDENTIALS_USE_OPENBSD_SOCKPEERCRED -#undef G_CREDENTIALS_USE_SOLARIS_UCRED - -/* - * G_CREDENTIALS_NATIVE_TYPE: - * - * Defined to one of G_CREDENTIALS_TYPE_LINUX_UCRED, etc. - */ -#undef G_CREDENTIALS_NATIVE_TYPE - -/* - * G_CREDENTIALS_NATIVE_SIZE: - * - * Defined to the size of the %G_CREDENTIALS_NATIVE_TYPE - */ -#undef G_CREDENTIALS_NATIVE_SIZE - -/* - * G_CREDENTIALS_UNIX_CREDENTIALS_MESSAGE_SUPPORTED: - * - * Defined to 1 if we have a message-passing API in which credentials - * are attached to a particular message, such as `SCM_CREDENTIALS` on Linux - * or `SCM_CREDS` on FreeBSD. - */ -#undef G_CREDENTIALS_UNIX_CREDENTIALS_MESSAGE_SUPPORTED - -/* - * G_CREDENTIALS_SOCKET_GET_CREDENTIALS_SUPPORTED: - * - * Defined to 1 if we have a `getsockopt()`-style API in which one end of - * a socket connection can directly query the credentials of the process - * that initiated the other end, such as `getsockopt SO_PEERCRED` on Linux - * or `getpeereid()` on multiple operating systems. - */ -#undef G_CREDENTIALS_SOCKET_GET_CREDENTIALS_SUPPORTED - -/* - * G_CREDENTIALS_SPOOFING_SUPPORTED: - * - * Defined to 1 if privileged processes can spoof their credentials when - * using the message-passing API. - */ -#undef G_CREDENTIALS_SPOOFING_SUPPORTED - -/* - * G_CREDENTIALS_PREFER_MESSAGE_PASSING: - * - * Defined to 1 if the data structure transferred by the message-passing - * API is strictly more informative than the one transferred by the - * `getsockopt()`-style API, and hence should be preferred, even for - * protocols like D-Bus that are defined in terms of the credentials of - * the (process that opened the) socket, as opposed to the credentials - * of an individual message. - */ -#undef G_CREDENTIALS_PREFER_MESSAGE_PASSING - #ifdef __linux__ #define G_CREDENTIALS_SUPPORTED 1 #define G_CREDENTIALS_USE_LINUX_UCRED 1 @@ -112,12 +41,6 @@ #define G_CREDENTIALS_NATIVE_SIZE (sizeof (struct cmsgcred)) #define G_CREDENTIALS_UNIX_CREDENTIALS_MESSAGE_SUPPORTED 1 #define G_CREDENTIALS_SPOOFING_SUPPORTED 1 -/* GLib doesn't implement it yet, but FreeBSD's getsockopt()-style API - * is getpeereid(), which is not as informative as struct cmsgcred - - * it does not tell us the PID. As a result, libdbus prefers to use - * SCM_CREDS, and if we implement getpeereid() in future, we should - * do the same. */ -#define G_CREDENTIALS_PREFER_MESSAGE_PASSING 1 #elif defined(__NetBSD__) #define G_CREDENTIALS_SUPPORTED 1 diff --git a/gio/gdatainputstream.c b/gio/gdatainputstream.c index f9891bb..9f207b1 100644 --- a/gio/gdatainputstream.c +++ b/gio/gdatainputstream.c @@ -27,7 +27,6 @@ #include "gioenumtypes.h" #include "gioerror.h" #include "glibintl.h" -#include "gstrfuncsprivate.h" #include @@ -857,7 +856,7 @@ static gssize scan_for_chars (GDataInputStream *stream, gsize *checked_out, const char *stop_chars, - gsize stop_chars_len) + gssize stop_chars_len) { GBufferedInputStream *bstream; const char *buffer; @@ -953,7 +952,7 @@ typedef struct gsize checked; gchar *stop_chars; - gsize stop_chars_len; + gssize stop_chars_len; gsize length; } GDataInputStreamReadData; @@ -1079,17 +1078,12 @@ g_data_input_stream_read_async (GDataInputStream *stream, { GDataInputStreamReadData *data; GTask *task; - gsize stop_chars_len_unsigned; data = g_slice_new0 (GDataInputStreamReadData); - - if (stop_chars_len < 0) - stop_chars_len_unsigned = strlen (stop_chars); - else - stop_chars_len_unsigned = (gsize) stop_chars_len; - - data->stop_chars = g_memdup2 (stop_chars, stop_chars_len_unsigned); - data->stop_chars_len = stop_chars_len_unsigned; + if (stop_chars_len == -1) + stop_chars_len = strlen (stop_chars); + data->stop_chars = g_memdup (stop_chars, stop_chars_len); + data->stop_chars_len = stop_chars_len; data->last_saw_cr = FALSE; task = g_task_new (stream, cancellable, callback, user_data); @@ -1344,20 +1338,17 @@ g_data_input_stream_read_upto (GDataInputStream *stream, gssize found_pos; gssize res; char *data_until; - gsize stop_chars_len_unsigned; g_return_val_if_fail (G_IS_DATA_INPUT_STREAM (stream), NULL); if (stop_chars_len < 0) - stop_chars_len_unsigned = strlen (stop_chars); - else - stop_chars_len_unsigned = (gsize) stop_chars_len; + stop_chars_len = strlen (stop_chars); bstream = G_BUFFERED_INPUT_STREAM (stream); checked = 0; - while ((found_pos = scan_for_chars (stream, &checked, stop_chars, stop_chars_len_unsigned)) == -1) + while ((found_pos = scan_for_chars (stream, &checked, stop_chars, stop_chars_len)) == -1) { if (g_buffered_input_stream_get_available (bstream) == g_buffered_input_stream_get_buffer_size (bstream)) diff --git a/gio/gdbus-2.0/codegen/codegen.py b/gio/gdbus-2.0/codegen/codegen.py index 442bd3f..d98f897 100644 --- a/gio/gdbus-2.0/codegen/codegen.py +++ b/gio/gdbus-2.0/codegen/codegen.py @@ -665,8 +665,7 @@ class CodeGenerator: '{\n' ' GDBusPropertyInfo parent_struct;\n' ' const gchar *hyphen_name;\n' - ' guint use_gvariant : 1;\n' - ' guint emits_changed_signal : 1;\n' + ' gboolean use_gvariant;\n' '} _ExtendedGDBusPropertyInfo;\n' '\n') @@ -845,10 +844,10 @@ class CodeGenerator: '\n') if len(args) > 0: - self.outfile.write('static const GDBusArgInfo * const %s_pointers[] =\n' + self.outfile.write('static const _ExtendedGDBusArgInfo * const %s_pointers[] =\n' '{\n'%(prefix)) for a in args: - self.outfile.write(' &%s_%s.parent_struct,\n'%(prefix, a.name)) + self.outfile.write(' &%s_%s,\n'%(prefix, a.name)) self.outfile.write(' NULL\n' '};\n' '\n') @@ -891,10 +890,10 @@ class CodeGenerator: self.outfile.write('};\n' '\n') - self.outfile.write('static const GDBusMethodInfo * const _%s_method_info_pointers[] =\n' + self.outfile.write('static const _ExtendedGDBusMethodInfo * const _%s_method_info_pointers[] =\n' '{\n'%(i.name_lower)) for m in i.methods: - self.outfile.write(' &_%s_method_info_%s.parent_struct,\n'%(i.name_lower, m.name_lower)) + self.outfile.write(' &_%s_method_info_%s,\n'%(i.name_lower, m.name_lower)) self.outfile.write(' NULL\n' '};\n' '\n') @@ -925,10 +924,10 @@ class CodeGenerator: self.outfile.write('};\n' '\n') - self.outfile.write('static const GDBusSignalInfo * const _%s_signal_info_pointers[] =\n' + self.outfile.write('static const _ExtendedGDBusSignalInfo * const _%s_signal_info_pointers[] =\n' '{\n'%(i.name_lower)) for s in i.signals: - self.outfile.write(' &_%s_signal_info_%s.parent_struct,\n'%(i.name_lower, s.name_lower)) + self.outfile.write(' &_%s_signal_info_%s,\n'%(i.name_lower, s.name_lower)) self.outfile.write(' NULL\n' '};\n' '\n') @@ -961,20 +960,16 @@ class CodeGenerator: ' "%s",\n' %(p.name_hyphen)) if not utils.lookup_annotation(p.annotations, 'org.gtk.GDBus.C.ForceGVariant'): - self.outfile.write(' FALSE,\n') + self.outfile.write(' FALSE\n') else: - self.outfile.write(' TRUE,\n') - if p.emits_changed_signal: self.outfile.write(' TRUE\n') - else: - self.outfile.write(' FALSE\n') self.outfile.write('};\n' '\n') - self.outfile.write('static const GDBusPropertyInfo * const _%s_property_info_pointers[] =\n' + self.outfile.write('static const _ExtendedGDBusPropertyInfo * const _%s_property_info_pointers[] =\n' '{\n'%(i.name_lower)) for p in i.properties: - self.outfile.write(' &_%s_property_info_%s.parent_struct,\n'%(i.name_lower, p.name_lower)) + self.outfile.write(' &_%s_property_info_%s,\n'%(i.name_lower, p.name_lower)) self.outfile.write(' NULL\n' '};\n' '\n') @@ -1668,7 +1663,7 @@ class CodeGenerator: self.outfile.write(' const _ExtendedGDBusPropertyInfo *info;\n' ' GVariant *variant;\n' ' g_assert (prop_id != 0 && prop_id - 1 < %d);\n' - ' info = (const _ExtendedGDBusPropertyInfo *) _%s_property_info_pointers[prop_id - 1];\n' + ' info = _%s_property_info_pointers[prop_id - 1];\n' ' variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (object), info->parent_struct.name);\n' ' if (info->use_gvariant)\n' ' {\n' @@ -1721,7 +1716,7 @@ class CodeGenerator: self.outfile.write(' const _ExtendedGDBusPropertyInfo *info;\n' ' GVariant *variant;\n' ' g_assert (prop_id != 0 && prop_id - 1 < %d);\n' - ' info = (const _ExtendedGDBusPropertyInfo *) _%s_property_info_pointers[prop_id - 1];\n' + ' info = _%s_property_info_pointers[prop_id - 1];\n' ' variant = g_dbus_gvalue_to_gvariant (value, G_VARIANT_TYPE (info->parent_struct.signature));\n' ' g_dbus_proxy_call (G_DBUS_PROXY (object),\n' ' "org.freedesktop.DBus.Properties.Set",\n' @@ -2600,17 +2595,14 @@ class CodeGenerator: ' const GValue *value,\n' ' GParamSpec *pspec)\n' '{\n'%(i.name_lower)) - self.outfile.write(' const _ExtendedGDBusPropertyInfo *info;\n' - ' %sSkeleton *skeleton = %s%s_SKELETON (object);\n' + self.outfile.write(' %sSkeleton *skeleton = %s%s_SKELETON (object);\n' ' g_assert (prop_id != 0 && prop_id - 1 < %d);\n' - ' info = (const _ExtendedGDBusPropertyInfo *) _%s_property_info_pointers[prop_id - 1];\n' ' g_mutex_lock (&skeleton->priv->lock);\n' ' g_object_freeze_notify (object);\n' ' if (!_g_value_equal (value, &skeleton->priv->properties[prop_id - 1]))\n' ' {\n' - ' if (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)) != NULL &&\n' - ' info->emits_changed_signal)\n' - ' _%s_schedule_emit_changed (skeleton, info, prop_id, &skeleton->priv->properties[prop_id - 1]);\n' + ' if (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)) != NULL)\n' + ' _%s_schedule_emit_changed (skeleton, _%s_property_info_pointers[prop_id - 1], prop_id, &skeleton->priv->properties[prop_id - 1]);\n' ' g_value_copy (value, &skeleton->priv->properties[prop_id - 1]);\n' ' g_object_notify_by_pspec (object, pspec);\n' ' }\n' diff --git a/gio/gdbus-2.0/codegen/dbustypes.py b/gio/gdbus-2.0/codegen/dbustypes.py index 359880f..bfc69f5 100644 --- a/gio/gdbus-2.0/codegen/dbustypes.py +++ b/gio/gdbus-2.0/codegen/dbustypes.py @@ -327,7 +327,6 @@ class Property: self.doc_string = '' self.since = '' self.deprecated = False - self.emits_changed_signal = True def post_process(self, interface_prefix, cns, cns_upper, cns_lower, containing_iface): if len(self.doc_string) == 0: @@ -357,12 +356,6 @@ class Property: if utils.lookup_annotation(self.annotations, 'org.freedesktop.DBus.Deprecated') == 'true': self.deprecated = True - # FIXME: for now we only support 'false' and 'const' on the signal itself, see #674913 and - # http://dbus.freedesktop.org/doc/dbus-specification.html#introspection-format - # for details - if utils.lookup_annotation(self.annotations, 'org.freedesktop.DBus.Property.EmitsChangedSignal') in ('false', 'const'): - self.emits_changed_signal = False - class Interface: def __init__(self, name): self.name = name diff --git a/gio/gdbusauth.c b/gio/gdbusauth.c index e9a953a..1a0ada5 100644 --- a/gio/gdbusauth.c +++ b/gio/gdbusauth.c @@ -31,7 +31,6 @@ #include "gdbusutils.h" #include "gioenumtypes.h" #include "gcredentials.h" -#include "gcredentialsprivate.h" #include "gdbusprivate.h" #include "giostream.h" #include "gdatainputstream.h" @@ -997,31 +996,9 @@ _g_dbus_auth_run_server (GDBusAuth *auth, g_data_input_stream_set_newline_type (dis, G_DATA_STREAM_NEWLINE_TYPE_CR_LF); - /* read the NUL-byte, possibly with credentials attached */ + /* first read the NUL-byte */ #ifdef G_OS_UNIX -#ifndef G_CREDENTIALS_PREFER_MESSAGE_PASSING - if (G_IS_SOCKET_CONNECTION (auth->priv->stream)) - { - GSocket *sock = g_socket_connection_get_socket (G_SOCKET_CONNECTION (auth->priv->stream)); - - local_error = NULL; - credentials = g_socket_get_credentials (sock, &local_error); - - if (credentials == NULL && !g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED)) - { - g_propagate_error (error, local_error); - goto out; - } - else - { - /* Clear the error indicator, so we can retry with - * g_unix_connection_receive_credentials() if necessary */ - g_clear_error (&local_error); - } - } -#endif - - if (credentials == NULL && G_IS_UNIX_CONNECTION (auth->priv->stream)) + if (G_IS_UNIX_CONNECTION (auth->priv->stream)) { local_error = NULL; credentials = g_unix_connection_receive_credentials (G_UNIX_CONNECTION (auth->priv->stream), diff --git a/gio/gdbusconnection.c b/gio/gdbusconnection.c index 117c8df..6f7e5fe 100644 --- a/gio/gdbusconnection.c +++ b/gio/gdbusconnection.c @@ -119,7 +119,6 @@ #include "gasyncinitable.h" #include "giostream.h" #include "gasyncresult.h" -#include "gstrfuncsprivate.h" #include "gtask.h" #ifdef G_OS_UNIX @@ -3971,7 +3970,7 @@ _g_dbus_interface_vtable_copy (const GDBusInterfaceVTable *vtable) /* Don't waste memory by copying padding - remember to update this * when changing struct _GDBusInterfaceVTable in gdbusconnection.h */ - return g_memdup2 ((gconstpointer) vtable, 3 * sizeof (gpointer)); + return g_memdup ((gconstpointer) vtable, 3 * sizeof (gpointer)); } static void @@ -3988,7 +3987,7 @@ _g_dbus_subtree_vtable_copy (const GDBusSubtreeVTable *vtable) /* Don't waste memory by copying padding - remember to update this * when changing struct _GDBusSubtreeVTable in gdbusconnection.h */ - return g_memdup2 ((gconstpointer) vtable, 3 * sizeof (gpointer)); + return g_memdup ((gconstpointer) vtable, 3 * sizeof (gpointer)); } static void diff --git a/gio/gdbusinterfaceskeleton.c b/gio/gdbusinterfaceskeleton.c index 672604c..96bd520 100644 --- a/gio/gdbusinterfaceskeleton.c +++ b/gio/gdbusinterfaceskeleton.c @@ -27,7 +27,6 @@ #include "gdbusprivate.h" #include "gdbusmethodinvocation.h" #include "gdbusconnection.h" -#include "gstrfuncsprivate.h" #include "gtask.h" #include "gioerror.h" @@ -698,7 +697,7 @@ add_connection_locked (GDBusInterfaceSkeleton *interface_, * properly before building the hooked_vtable, so we create it * once at the last minute. */ - interface_->priv->hooked_vtable = g_memdup2 (g_dbus_interface_skeleton_get_vtable (interface_), sizeof (GDBusInterfaceVTable)); + interface_->priv->hooked_vtable = g_memdup (g_dbus_interface_skeleton_get_vtable (interface_), sizeof (GDBusInterfaceVTable)); interface_->priv->hooked_vtable->method_call = skeleton_intercept_handle_method_call; } diff --git a/gio/gfile.c b/gio/gfile.c index 29ebaaa..a67aad3 100644 --- a/gio/gfile.c +++ b/gio/gfile.c @@ -60,7 +60,6 @@ #include "gasyncresult.h" #include "gioerror.h" #include "glibintl.h" -#include "gstrfuncsprivate.h" /** @@ -3280,12 +3279,12 @@ file_copy_fallback (GFile *source, out = (GOutputStream*)_g_local_file_output_stream_replace (_g_local_file_get_filename (G_LOCAL_FILE (destination)), FALSE, NULL, flags & G_FILE_COPY_BACKUP, - G_FILE_CREATE_REPLACE_DESTINATION | - G_FILE_CREATE_PRIVATE, info, + G_FILE_CREATE_REPLACE_DESTINATION, + info, cancellable, error); else out = (GOutputStream*)_g_local_file_output_stream_create (_g_local_file_get_filename (G_LOCAL_FILE (destination)), - FALSE, G_FILE_CREATE_PRIVATE, info, + FALSE, 0, info, cancellable, error); } else if (flags & G_FILE_COPY_OVERWRITE) @@ -3293,13 +3292,12 @@ file_copy_fallback (GFile *source, out = (GOutputStream *)g_file_replace (destination, NULL, flags & G_FILE_COPY_BACKUP, - G_FILE_CREATE_REPLACE_DESTINATION | - G_FILE_CREATE_PRIVATE, + G_FILE_CREATE_REPLACE_DESTINATION, cancellable, error); } else { - out = (GOutputStream *)g_file_create (destination, G_FILE_CREATE_PRIVATE, cancellable, error); + out = (GOutputStream *)g_file_create (destination, 0, cancellable, error); } if (!out) @@ -7735,7 +7733,7 @@ measure_disk_usage_progress (gboolean reporting, g_main_context_invoke_full (g_task_get_context (task), g_task_get_priority (task), measure_disk_usage_invoke_progress, - g_memdup2 (&progress, sizeof progress), + g_memdup (&progress, sizeof progress), g_free); } @@ -7753,7 +7751,7 @@ measure_disk_usage_thread (GTask *task, data->progress_callback ? measure_disk_usage_progress : NULL, task, &result.disk_usage, &result.num_dirs, &result.num_files, &error)) - g_task_return_pointer (task, g_memdup2 (&result, sizeof result), g_free); + g_task_return_pointer (task, g_memdup (&result, sizeof result), g_free); else g_task_return_error (task, error); } @@ -7777,7 +7775,7 @@ g_file_real_measure_disk_usage_async (GFile *file, task = g_task_new (file, cancellable, callback, user_data); g_task_set_source_tag (task, g_file_real_measure_disk_usage_async); - g_task_set_task_data (task, g_memdup2 (&data, sizeof data), g_free); + g_task_set_task_data (task, g_memdup (&data, sizeof data), g_free); g_task_set_priority (task, io_priority); g_task_run_in_thread (task, measure_disk_usage_thread); diff --git a/gio/giomodule.c b/gio/giomodule.c index 8c2a464..1ead84c 100644 --- a/gio/giomodule.c +++ b/gio/giomodule.c @@ -1136,7 +1136,6 @@ _g_io_modules_ensure_loaded (void) /* Initialize types from built-in "modules" */ g_type_ensure (g_null_settings_backend_get_type ()); g_type_ensure (g_memory_settings_backend_get_type ()); - g_type_ensure (g_keyfile_settings_backend_get_type ()); #if defined(HAVE_INOTIFY_INIT1) g_type_ensure (g_inotify_file_monitor_get_type ()); #endif diff --git a/gio/gkeyfilesettingsbackend.c b/gio/gkeyfilesettingsbackend.c index 418c11a..a37978e 100644 --- a/gio/gkeyfilesettingsbackend.c +++ b/gio/gkeyfilesettingsbackend.c @@ -21,21 +21,14 @@ #include "config.h" -#include -#include - #include #include #include "gfile.h" #include "gfileinfo.h" -#include "gfileenumerator.h" #include "gfilemonitor.h" #include "gsimplepermission.h" -#include "gsettingsbackendinternal.h" -#include "gstrfuncsprivate.h" -#include "giomodule-priv.h" -#include "gportalsupport.h" +#include "gsettingsbackend.h" #define G_TYPE_KEYFILE_SETTINGS_BACKEND (g_keyfile_settings_backend_get_type ()) @@ -48,13 +41,6 @@ typedef GSettingsBackendClass GKeyfileSettingsBackendClass; -typedef enum { - PROP_FILENAME = 1, - PROP_ROOT_PATH, - PROP_ROOT_GROUP, - PROP_DEFAULTS_DIR -} GKeyfileSettingsBackendProperty; - typedef struct { GSettingsBackend parent_instance; @@ -62,9 +48,6 @@ typedef struct GKeyFile *keyfile; GPermission *permission; gboolean writable; - char *defaults_dir; - GKeyFile *system_keyfile; - GHashTable *system_locks; /* Used as a set, owning the strings it contains */ gchar *prefix; gint prefix_len; @@ -78,18 +61,10 @@ typedef struct GFileMonitor *dir_monitor; } GKeyfileSettingsBackend; -#ifdef G_OS_WIN32 -#define EXTENSION_PRIORITY 10 -#else -#define EXTENSION_PRIORITY (glib_should_use_portal () && !glib_has_dconf_access_in_sandbox () ? 110 : 10) -#endif - -G_DEFINE_TYPE_WITH_CODE (GKeyfileSettingsBackend, - g_keyfile_settings_backend, - G_TYPE_SETTINGS_BACKEND, - _g_io_modules_ensure_extension_points_registered (); - g_io_extension_point_implement (G_SETTINGS_BACKEND_EXTENSION_POINT_NAME, - g_define_type_id, "keyfile", EXTENSION_PRIORITY)) +static GType g_keyfile_settings_backend_get_type (void); +G_DEFINE_TYPE (GKeyfileSettingsBackend, + g_keyfile_settings_backend, + G_TYPE_SETTINGS_BACKEND) static void compute_checksum (guint8 *digest, @@ -114,8 +89,7 @@ g_keyfile_settings_backend_keyfile_write (GKeyfileSettingsBackend *kfsb) contents = g_key_file_to_data (kfsb->keyfile, &length, NULL); g_file_replace_contents (kfsb->file, contents, length, NULL, FALSE, - G_FILE_CREATE_REPLACE_DESTINATION | - G_FILE_CREATE_PRIVATE, + G_FILE_CREATE_REPLACE_DESTINATION, NULL, NULL, NULL); compute_checksum (kfsb->digest, contents, length); @@ -146,8 +120,8 @@ convert_path (GKeyfileSettingsBackend *kfsb, gchar **group, gchar **basename) { - gsize key_len = strlen (key); - const gchar *last_slash; + gint key_len = strlen (key); + gint i; if (key_len < kfsb->prefix_len || memcmp (key, kfsb->prefix, kfsb->prefix_len) != 0) @@ -156,36 +130,38 @@ convert_path (GKeyfileSettingsBackend *kfsb, key_len -= kfsb->prefix_len; key += kfsb->prefix_len; - last_slash = strrchr (key, '/'); + for (i = key_len; i >= 0; i--) + if (key[i] == '/') + break; if (kfsb->root_group) { /* if a root_group was specified, make sure the user hasn't given * a path that ghosts that group name */ - if (last_slash != NULL && (last_slash - key) == kfsb->root_group_len && memcmp (key, kfsb->root_group, last_slash - key) == 0) + if (i == kfsb->root_group_len && memcmp (key, kfsb->root_group, i) == 0) return FALSE; } else { /* if no root_group was given, ensure that the user gave a path */ - if (last_slash == NULL) + if (i == -1) return FALSE; } if (group) { - if (last_slash != NULL) + if (i >= 0) { - *group = g_memdup2 (key, (last_slash - key) + 1); - (*group)[(last_slash - key)] = '\0'; + *group = g_memdup (key, i + 1); + (*group)[i] = '\0'; } else *group = g_strdup (kfsb->root_group); } if (basename) - *basename = g_memdup2 (last_slash + 1, key_len - (last_slash - key)); + *basename = g_memdup (key + i + 1, key_len - i); return TRUE; } @@ -208,51 +184,17 @@ get_from_keyfile (GKeyfileSettingsBackend *kfsb, if (convert_path (kfsb, key, &group, &name)) { gchar *str; - gchar *sysstr; g_assert (*name); - sysstr = g_key_file_get_value (kfsb->system_keyfile, group, name, NULL); str = g_key_file_get_value (kfsb->keyfile, group, name, NULL); - if (sysstr && - (g_hash_table_contains (kfsb->system_locks, key) || - str == NULL)) - { - g_free (str); - str = g_steal_pointer (&sysstr); - } if (str) { return_value = g_variant_parse (type, str, NULL, NULL, NULL); - - /* As a special case, support values of type %G_VARIANT_TYPE_STRING - * not being quoted, since users keep forgetting to do it and then - * getting confused. */ - if (return_value == NULL && - g_variant_type_equal (type, G_VARIANT_TYPE_STRING) && - str[0] != '\"') - { - GString *s = g_string_sized_new (strlen (str) + 2); - char *p = str; - - g_string_append_c (s, '\"'); - while (*p) - { - if (*p == '\"') - g_string_append_c (s, '\\'); - g_string_append_c (s, *p); - p++; - } - g_string_append_c (s, '\"'); - return_value = g_variant_parse (type, s->str, NULL, NULL, NULL); - g_string_free (s, TRUE); - } g_free (str); } - g_free (sysstr); - g_free (group); g_free (name); } @@ -267,9 +209,6 @@ set_to_keyfile (GKeyfileSettingsBackend *kfsb, { gchar *group, *name; - if (g_hash_table_contains (kfsb->system_locks, key)) - return FALSE; - if (convert_path (kfsb, key, &group, &name)) { if (value) @@ -348,8 +287,7 @@ g_keyfile_settings_backend_check_one (gpointer key, { WriteManyData *data = user_data; - return data->failed = g_hash_table_contains (data->kfsb->system_locks, key) || - !path_is_valid (data->kfsb, key); + return data->failed = !path_is_valid (data->kfsb, key); } static gboolean @@ -417,9 +355,7 @@ g_keyfile_settings_backend_get_writable (GSettingsBackend *backend, { GKeyfileSettingsBackend *kfsb = G_KEYFILE_SETTINGS_BACKEND (backend); - return kfsb->writable && - !g_hash_table_contains (kfsb->system_locks, name) && - path_is_valid (kfsb, name); + return kfsb->writable && path_is_valid (kfsb, name); } static GPermission * @@ -565,9 +501,6 @@ g_keyfile_settings_backend_finalize (GObject *object) g_key_file_free (kfsb->keyfile); g_object_unref (kfsb->permission); - g_key_file_unref (kfsb->system_keyfile); - g_hash_table_unref (kfsb->system_locks); - g_free (kfsb->defaults_dir); g_file_monitor_cancel (kfsb->file_monitor); g_object_unref (kfsb->file_monitor); @@ -590,6 +523,25 @@ g_keyfile_settings_backend_init (GKeyfileSettingsBackend *kfsb) } static void +g_keyfile_settings_backend_class_init (GKeyfileSettingsBackendClass *class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (class); + + object_class->finalize = g_keyfile_settings_backend_finalize; + + class->read = g_keyfile_settings_backend_read; + class->write = g_keyfile_settings_backend_write; + class->write_tree = g_keyfile_settings_backend_write_tree; + class->reset = g_keyfile_settings_backend_reset; + class->get_writable = g_keyfile_settings_backend_get_writable; + class->get_permission = g_keyfile_settings_backend_get_permission; + /* No need to implement subscribed/unsubscribe: the only point would be to + * stop monitoring the file when there's no GSettings anymore, which is no + * big win. + */ +} + +static void file_changed (GFileMonitor *monitor, GFile *file, GFile *other_file, @@ -615,283 +567,6 @@ dir_changed (GFileMonitor *monitor, g_keyfile_settings_backend_keyfile_writable (kfsb); } -static void -load_system_settings (GKeyfileSettingsBackend *kfsb) -{ - GError *error = NULL; - const char *dir = "/etc/glib-2.0/settings"; - char *path; - char *contents; - - kfsb->system_keyfile = g_key_file_new (); - kfsb->system_locks = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - - if (kfsb->defaults_dir) - dir = kfsb->defaults_dir; - - path = g_build_filename (dir, "defaults", NULL); - - /* The defaults are in the same keyfile format that we use for the settings. - * It can be produced from a dconf database using: dconf dump - */ - if (!g_key_file_load_from_file (kfsb->system_keyfile, path, G_KEY_FILE_NONE, &error)) - { - if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) - g_warning ("Failed to read %s: %s", path, error->message); - g_clear_error (&error); - } - else - g_debug ("Loading default settings from %s", path); - - g_free (path); - - path = g_build_filename (dir, "locks", NULL); - - /* The locks file is a text file containing a list paths to lock, one per line. - * It can be produced from a dconf database using: dconf list-locks - */ - if (!g_file_get_contents (path, &contents, NULL, &error)) - { - if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) - g_warning ("Failed to read %s: %s", path, error->message); - g_clear_error (&error); - } - else - { - char **lines; - gsize i; - - g_debug ("Loading locks from %s", path); - - lines = g_strsplit (contents, "\n", 0); - for (i = 0; lines[i]; i++) - { - char *line = lines[i]; - if (line[0] == '#' || line[0] == '\0') - { - g_free (line); - continue; - } - - g_debug ("Locking key %s", line); - g_hash_table_add (kfsb->system_locks, g_steal_pointer (&line)); - } - - g_free (lines); - } - g_free (contents); - - g_free (path); -} - -static void -g_keyfile_settings_backend_constructed (GObject *object) -{ - GKeyfileSettingsBackend *kfsb = G_KEYFILE_SETTINGS_BACKEND (object); - - if (kfsb->file == NULL) - { - char *filename = g_build_filename (g_get_user_config_dir (), - "glib-2.0", "settings", "keyfile", - NULL); - kfsb->file = g_file_new_for_path (filename); - g_free (filename); - } - - if (kfsb->prefix == NULL) - { - kfsb->prefix = g_strdup ("/"); - kfsb->prefix_len = 1; - } - - kfsb->keyfile = g_key_file_new (); - kfsb->permission = g_simple_permission_new (TRUE); - - kfsb->dir = g_file_get_parent (kfsb->file); - g_mkdir_with_parents (g_file_peek_path (kfsb->dir), 0700); - - kfsb->file_monitor = g_file_monitor (kfsb->file, G_FILE_MONITOR_NONE, NULL, NULL); - kfsb->dir_monitor = g_file_monitor (kfsb->dir, G_FILE_MONITOR_NONE, NULL, NULL); - - compute_checksum (kfsb->digest, NULL, 0); - - g_signal_connect (kfsb->file_monitor, "changed", - G_CALLBACK (file_changed), kfsb); - g_signal_connect (kfsb->dir_monitor, "changed", - G_CALLBACK (dir_changed), kfsb); - - g_keyfile_settings_backend_keyfile_writable (kfsb); - g_keyfile_settings_backend_keyfile_reload (kfsb); - - load_system_settings (kfsb); -} - -static void -g_keyfile_settings_backend_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GKeyfileSettingsBackend *kfsb = G_KEYFILE_SETTINGS_BACKEND (object); - - switch ((GKeyfileSettingsBackendProperty)prop_id) - { - case PROP_FILENAME: - /* Construct only. */ - g_assert (kfsb->file == NULL); - if (g_value_get_string (value)) - kfsb->file = g_file_new_for_path (g_value_get_string (value)); - break; - - case PROP_ROOT_PATH: - /* Construct only. */ - g_assert (kfsb->prefix == NULL); - kfsb->prefix = g_value_dup_string (value); - if (kfsb->prefix) - kfsb->prefix_len = strlen (kfsb->prefix); - break; - - case PROP_ROOT_GROUP: - /* Construct only. */ - g_assert (kfsb->root_group == NULL); - kfsb->root_group = g_value_dup_string (value); - if (kfsb->root_group) - kfsb->root_group_len = strlen (kfsb->root_group); - break; - - case PROP_DEFAULTS_DIR: - /* Construct only. */ - g_assert (kfsb->defaults_dir == NULL); - kfsb->defaults_dir = g_value_dup_string (value); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -g_keyfile_settings_backend_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GKeyfileSettingsBackend *kfsb = G_KEYFILE_SETTINGS_BACKEND (object); - - switch ((GKeyfileSettingsBackendProperty)prop_id) - { - case PROP_FILENAME: - g_value_set_string (value, g_file_peek_path (kfsb->file)); - break; - - case PROP_ROOT_PATH: - g_value_set_string (value, kfsb->prefix); - break; - - case PROP_ROOT_GROUP: - g_value_set_string (value, kfsb->root_group); - break; - - case PROP_DEFAULTS_DIR: - g_value_set_string (value, kfsb->defaults_dir); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -g_keyfile_settings_backend_class_init (GKeyfileSettingsBackendClass *class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (class); - - object_class->finalize = g_keyfile_settings_backend_finalize; - object_class->constructed = g_keyfile_settings_backend_constructed; - object_class->get_property = g_keyfile_settings_backend_get_property; - object_class->set_property = g_keyfile_settings_backend_set_property; - - class->read = g_keyfile_settings_backend_read; - class->write = g_keyfile_settings_backend_write; - class->write_tree = g_keyfile_settings_backend_write_tree; - class->reset = g_keyfile_settings_backend_reset; - class->get_writable = g_keyfile_settings_backend_get_writable; - class->get_permission = g_keyfile_settings_backend_get_permission; - /* No need to implement subscribed/unsubscribe: the only point would be to - * stop monitoring the file when there's no GSettings anymore, which is no - * big win. - */ - - /** - * GKeyfileSettingsBackend:filename: - * - * The location where the settings are stored on disk. - * - * Defaults to `$XDG_CONFIG_HOME/glib-2.0/settings/keyfile`. - */ - g_object_class_install_property (object_class, - PROP_FILENAME, - g_param_spec_string ("filename", - P_("Filename"), - P_("The filename"), - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - /** - * GKeyfileSettingsBackend:root-path: - * - * All settings read to or written from the backend must fall under the - * path given in @root_path (which must start and end with a slash and - * not contain two consecutive slashes). @root_path may be "/". - * - * Defaults to "/". - */ - g_object_class_install_property (object_class, - PROP_ROOT_PATH, - g_param_spec_string ("root-path", - P_("Root path"), - P_("The root path"), - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - /** - * GKeyfileSettingsBackend:root-group: - * - * If @root_group is non-%NULL then it specifies the name of the keyfile - * group used for keys that are written directly below the root path. - * - * Defaults to NULL. - */ - g_object_class_install_property (object_class, - PROP_ROOT_GROUP, - g_param_spec_string ("root-group", - P_("Root group"), - P_("The root group"), - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - /** - * GKeyfileSettingsBackend:default-dir: - * - * The directory where the system defaults and locks are located. - * - * Defaults to `/etc/glib-2.0/settings`. - */ - g_object_class_install_property (object_class, - PROP_DEFAULTS_DIR, - g_param_spec_string ("defaults-dir", - P_("Default dir"), - P_("Defaults dir"), - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); -} - /** * g_keyfile_settings_backend_new: * @filename: the filename of the keyfile @@ -944,11 +619,6 @@ g_keyfile_settings_backend_class_init (GKeyfileSettingsBackendClass *class) * characters in your path names or '=' in your key names you may be in * trouble. * - * The backend reads default values from a keyfile called `defaults` in - * the directory specified by the #GKeyfileSettingsBackend:defaults-dir property, - * and a list of locked keys from a text file with the name `locks` in - * the same location. - * * Returns: (transfer full): a keyfile-backed #GSettingsBackend **/ GSettingsBackend * @@ -956,15 +626,43 @@ g_keyfile_settings_backend_new (const gchar *filename, const gchar *root_path, const gchar *root_group) { + GKeyfileSettingsBackend *kfsb; + g_return_val_if_fail (filename != NULL, NULL); g_return_val_if_fail (root_path != NULL, NULL); g_return_val_if_fail (g_str_has_prefix (root_path, "/"), NULL); g_return_val_if_fail (g_str_has_suffix (root_path, "/"), NULL); g_return_val_if_fail (strstr (root_path, "//") == NULL, NULL); - return G_SETTINGS_BACKEND (g_object_new (G_TYPE_KEYFILE_SETTINGS_BACKEND, - "filename", filename, - "root-path", root_path, - "root-group", root_group, - NULL)); + kfsb = g_object_new (G_TYPE_KEYFILE_SETTINGS_BACKEND, NULL); + kfsb->keyfile = g_key_file_new (); + kfsb->permission = g_simple_permission_new (TRUE); + + kfsb->file = g_file_new_for_path (filename); + kfsb->dir = g_file_get_parent (kfsb->file); + g_file_make_directory_with_parents (kfsb->dir, NULL, NULL); + + kfsb->file_monitor = g_file_monitor (kfsb->file, 0, NULL, NULL); + kfsb->dir_monitor = g_file_monitor (kfsb->dir, 0, NULL, NULL); + + kfsb->prefix_len = strlen (root_path); + kfsb->prefix = g_strdup (root_path); + + if (root_group) + { + kfsb->root_group_len = strlen (root_group); + kfsb->root_group = g_strdup (root_group); + } + + compute_checksum (kfsb->digest, NULL, 0); + + g_signal_connect (kfsb->file_monitor, "changed", + G_CALLBACK (file_changed), kfsb); + g_signal_connect (kfsb->dir_monitor, "changed", + G_CALLBACK (dir_changed), kfsb); + + g_keyfile_settings_backend_keyfile_writable (kfsb); + g_keyfile_settings_backend_keyfile_reload (kfsb); + + return G_SETTINGS_BACKEND (kfsb); } diff --git a/gio/glib-compile-schemas.c b/gio/glib-compile-schemas.c index 00dd641..2dc8c71 100644 --- a/gio/glib-compile-schemas.c +++ b/gio/glib-compile-schemas.c @@ -179,8 +179,6 @@ typedef struct GString *unparsed_default_value; GVariant *default_value; - GVariantDict *desktop_overrides; - GString *strinfo; gboolean is_enum; gboolean is_flags; @@ -733,11 +731,6 @@ key_state_serialise (KeyState *state) g_variant_builder_add (&builder, "(y(**))", 'r', state->minimum, state->maximum); - /* per-desktop overrides */ - if (state->desktop_overrides) - g_variant_builder_add (&builder, "(y@a{sv})", 'd', - g_variant_dict_end (state->desktop_overrides)); - state->serialised = g_variant_builder_end (&builder); } @@ -775,9 +768,6 @@ key_state_free (gpointer data) if (state->serialised) g_variant_unref (state->serialised); - if (state->desktop_overrides) - g_variant_dict_unref (state->desktop_overrides); - g_slice_free (KeyState, state); } @@ -1888,8 +1878,6 @@ set_overrides (GHashTable *schema_table, gchar **groups; gint i; - g_debug ("Processing override file '%s'", filename); - key_file = g_key_file_new (); if (!g_key_file_load_from_file (key_file, filename, 0, &error)) { @@ -1912,31 +1900,18 @@ set_overrides (GHashTable *schema_table, for (i = 0; groups[i]; i++) { const gchar *group = groups[i]; - const gchar *schema_name; - const gchar *desktop_id; SchemaState *schema; - gchar **pieces; gchar **keys; gint j; - pieces = g_strsplit (group, ":", 2); - schema_name = pieces[0]; - desktop_id = pieces[1]; - - g_debug ("Processing group '%s' (schema '%s', %s)", - group, schema_name, desktop_id ? desktop_id : "all desktops"); - - schema = g_hash_table_lookup (schema_table, schema_name); + schema = g_hash_table_lookup (schema_table, group); if (schema == NULL) - { - /* Having the schema not be installed is expected to be a - * common case. Don't even emit an error message about - * that. - */ - g_strfreev (pieces); - continue; - } + /* Having the schema not be installed is expected to be a + * common case. Don't even emit an error message about + * that. + */ + continue; keys = g_key_file_get_keys (key_file, group, NULL, NULL); g_assert (keys != NULL); @@ -1964,32 +1939,6 @@ set_overrides (GHashTable *schema_table, fprintf (stderr, _(" and --strict was specified; exiting.\n")); g_key_file_free (key_file); - g_strfreev (pieces); - g_strfreev (groups); - g_strfreev (keys); - - return FALSE; - } - - if (desktop_id != NULL && state->l10n) - { - /* Let's avoid the n*m case of per-desktop localised - * default values, and just forbid it. - */ - fprintf (stderr, - _("cannot provide per-desktop overrides for localised " - "key '%s' in schema '%s' (override file '%s')"), - key, group, filename); - - if (!strict) - { - fprintf (stderr, _("; ignoring override for this key.\n")); - continue; - } - - fprintf (stderr, _(" and --strict was specified; exiting.\n")); - g_key_file_free (key_file); - g_strfreev (pieces); g_strfreev (groups); g_strfreev (keys); @@ -2020,7 +1969,6 @@ set_overrides (GHashTable *schema_table, fprintf (stderr, _("--strict was specified; exiting.\n")); g_key_file_free (key_file); - g_strfreev (pieces); g_strfreev (groups); g_strfreev (keys); @@ -2049,7 +1997,6 @@ set_overrides (GHashTable *schema_table, fprintf (stderr, _(" and --strict was specified; exiting.\n")); g_key_file_free (key_file); - g_strfreev (pieces); g_strfreev (groups); g_strfreev (keys); @@ -2078,7 +2025,6 @@ set_overrides (GHashTable *schema_table, fprintf (stderr, _(" and --strict was specified; exiting.\n")); g_key_file_free (key_file); - g_strfreev (pieces); g_strfreev (groups); g_strfreev (keys); @@ -2086,24 +2032,11 @@ set_overrides (GHashTable *schema_table, } } - if (desktop_id != NULL) - { - if (state->desktop_overrides == NULL) - state->desktop_overrides = g_variant_dict_new (NULL); - - g_variant_dict_insert_value (state->desktop_overrides, desktop_id, value); - g_variant_unref (value); - } - else - { - g_variant_unref (state->default_value); - state->default_value = value; - } - + g_variant_unref (state->default_value); + state->default_value = value; g_free (string); } - g_strfreev (pieces); g_strfreev (keys); } @@ -2139,7 +2072,6 @@ main (int argc, char **argv) /* These options are only for use in the gschema-compile tests */ { "schema-file", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_FILENAME_ARRAY, &schema_files, NULL, NULL }, - { "override-file", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_FILENAME_ARRAY, &override_files, NULL, NULL }, { NULL } }; diff --git a/gio/glocalfileoutputstream.c b/gio/glocalfileoutputstream.c index 275770f..57d2d5d 100644 --- a/gio/glocalfileoutputstream.c +++ b/gio/glocalfileoutputstream.c @@ -56,12 +56,6 @@ #define O_BINARY 0 #endif -#ifndef O_CLOEXEC -#define O_CLOEXEC 0 -#else -#define HAVE_O_CLOEXEC 1 -#endif - struct _GLocalFileOutputStreamPrivate { char *tmp_filename; char *original_filename; @@ -757,7 +751,6 @@ handle_overwrite_open (const char *filename, int res; int mode; int errsv; - gboolean replace_destination_set = (flags & G_FILE_CREATE_REPLACE_DESTINATION); mode = mode_from_flags_or_info (flags, reference_info); @@ -785,22 +778,16 @@ handle_overwrite_open (const char *filename, /* Could be a symlink, or it could be a regular ELOOP error, * but then the next open will fail too. */ is_symlink = TRUE; - if (!replace_destination_set) - fd = g_open (filename, open_flags, mode); + fd = g_open (filename, open_flags, mode); } -#else /* if !O_NOFOLLOW */ +#else + fd = g_open (filename, open_flags, mode); + errsv = errno; /* This is racy, but we do it as soon as possible to minimize the race */ is_symlink = g_file_test (filename, G_FILE_TEST_IS_SYMLINK); - - if (!is_symlink || !replace_destination_set) - { - fd = g_open (filename, open_flags, mode); - errsv = errno; - } #endif - if (fd == -1 && - (!is_symlink || !replace_destination_set)) + if (fd == -1) { char *display_name = g_filename_display_name (filename); g_set_error (error, G_IO_ERROR, @@ -812,17 +799,10 @@ handle_overwrite_open (const char *filename, } #ifdef G_OS_WIN32 -#error This patch has not been ported to Windows, sorry + res = GLIB_PRIVATE_CALL (g_win32_fstat) (fd, &original_stat); +#else + res = fstat (fd, &original_stat); #endif - - if (!is_symlink) - { - res = fstat (fd, &original_stat); - } - else - { - res = lstat (filename, &original_stat); - } errsv = errno; if (res != 0) @@ -840,27 +820,16 @@ handle_overwrite_open (const char *filename, if (!S_ISREG (original_stat.st_mode)) { if (S_ISDIR (original_stat.st_mode)) - { - g_set_error_literal (error, - G_IO_ERROR, - G_IO_ERROR_IS_DIRECTORY, - _("Target file is a directory")); - goto err_out; - } - else if (!is_symlink || -#ifdef S_ISLNK - !S_ISLNK (original_stat.st_mode) -#else - FALSE -#endif - ) - { - g_set_error_literal (error, - G_IO_ERROR, - G_IO_ERROR_NOT_REGULAR_FILE, - _("Target file is not a regular file")); - goto err_out; - } + g_set_error_literal (error, + G_IO_ERROR, + G_IO_ERROR_IS_DIRECTORY, + _("Target file is a directory")); + else + g_set_error_literal (error, + G_IO_ERROR, + G_IO_ERROR_NOT_REGULAR_FILE, + _("Target file is not a regular file")); + goto err_out; } if (etag != NULL) @@ -888,8 +857,8 @@ handle_overwrite_open (const char *filename, * The second strategy consist simply in copying the old file * to a backup file and rewrite the contents of the file. */ - - if (replace_destination_set || + + if ((flags & G_FILE_CREATE_REPLACE_DESTINATION) || (!(original_stat.st_nlink > 1) && !is_symlink)) { char *dirname, *tmp_filename; @@ -908,7 +877,7 @@ handle_overwrite_open (const char *filename, /* try to keep permissions (unless replacing) */ - if (!replace_destination_set && + if ( ! (flags & G_FILE_CREATE_REPLACE_DESTINATION) && ( #ifdef HAVE_FCHOWN fchown (tmpfd, original_stat.st_uid, original_stat.st_gid) == -1 || @@ -941,8 +910,7 @@ handle_overwrite_open (const char *filename, } } - if (fd >= 0) - g_close (fd, NULL); + g_close (fd, NULL); *temp_filename = tmp_filename; return tmpfd; } @@ -1048,7 +1016,7 @@ handle_overwrite_open (const char *filename, } } - if (replace_destination_set) + if (flags & G_FILE_CREATE_REPLACE_DESTINATION) { g_close (fd, NULL); @@ -1133,7 +1101,7 @@ _g_local_file_output_stream_replace (const char *filename, sync_on_close = FALSE; /* If the file doesn't exist, create it */ - open_flags = O_CREAT | O_EXCL | O_BINARY | O_CLOEXEC; + open_flags = O_CREAT | O_EXCL | O_BINARY; if (readable) open_flags |= O_RDWR; else @@ -1163,11 +1131,8 @@ _g_local_file_output_stream_replace (const char *filename, set_error_from_open_errno (filename, error); return NULL; } -#if !defined(HAVE_O_CLOEXEC) && defined(F_SETFD) - else - fcntl (fd, F_SETFD, FD_CLOEXEC); -#endif - + + stream = g_object_new (G_TYPE_LOCAL_FILE_OUTPUT_STREAM, NULL); stream->priv->fd = fd; stream->priv->sync_on_close = sync_on_close; diff --git a/gio/gportalsupport.c b/gio/gportalsupport.c index b0a94b3..2f1e825 100644 --- a/gio/gportalsupport.c +++ b/gio/gportalsupport.c @@ -23,7 +23,6 @@ static gboolean flatpak_info_read; static gboolean use_portal; static gboolean network_available; -static gboolean dconf_access; static void read_flatpak_info (void) @@ -41,13 +40,11 @@ read_flatpak_info (void) use_portal = TRUE; network_available = FALSE; - dconf_access = FALSE; keyfile = g_key_file_new (); if (g_key_file_load_from_file (keyfile, path, G_KEY_FILE_NONE, NULL)) { char **shared = NULL; - char *dconf_policy = NULL; shared = g_key_file_get_string_list (keyfile, "Context", "shared", NULL, NULL); if (shared) @@ -55,14 +52,6 @@ read_flatpak_info (void) network_available = g_strv_contains ((const char * const *)shared, "network"); g_strfreev (shared); } - - dconf_policy = g_key_file_get_string (keyfile, "Session Bus Policy", "ca.desrt.dconf", NULL); - if (dconf_policy) - { - if (strcmp (dconf_policy, "talk") == 0) - dconf_access = TRUE; - g_free (dconf_policy); - } } g_key_file_unref (keyfile); @@ -75,7 +64,6 @@ read_flatpak_info (void) if (var && var[0] == '1') use_portal = TRUE; network_available = TRUE; - dconf_access = TRUE; } } @@ -93,9 +81,3 @@ glib_network_available_in_sandbox (void) return network_available; } -gboolean -glib_has_dconf_access_in_sandbox (void) -{ - read_flatpak_info (); - return dconf_access; -} diff --git a/gio/gportalsupport.h b/gio/gportalsupport.h index 746f1fd..a331f45 100644 --- a/gio/gportalsupport.h +++ b/gio/gportalsupport.h @@ -24,7 +24,6 @@ G_BEGIN_DECLS gboolean glib_should_use_portal (void); gboolean glib_network_available_in_sandbox (void); -gboolean glib_has_dconf_access_in_sandbox (void); G_END_DECLS diff --git a/gio/gsettings.c b/gio/gsettings.c index f1130c0..10d394d 100644 --- a/gio/gsettings.c +++ b/gio/gsettings.c @@ -1204,7 +1204,10 @@ g_settings_get_value (GSettings *settings, value = g_settings_read_from_backend (settings, &skey, FALSE, FALSE); if (value == NULL) - value = g_settings_schema_key_get_default_value (&skey); + value = g_settings_schema_key_get_translated_default (&skey); + + if (value == NULL) + value = g_variant_ref (skey.default_value); g_settings_schema_key_clear (&skey); @@ -1301,7 +1304,10 @@ g_settings_get_default_value (GSettings *settings, value = g_settings_read_from_backend (settings, &skey, FALSE, TRUE); if (value == NULL) - value = g_settings_schema_key_get_default_value (&skey); + value = g_settings_schema_key_get_translated_default (&skey); + + if (value == NULL) + value = g_variant_ref (skey.default_value); g_settings_schema_key_clear (&skey); @@ -1354,7 +1360,10 @@ g_settings_get_enum (GSettings *settings, value = g_settings_read_from_backend (settings, &skey, FALSE, FALSE); if (value == NULL) - value = g_settings_schema_key_get_default_value (&skey); + value = g_settings_schema_key_get_translated_default (&skey); + + if (value == NULL) + value = g_variant_ref (skey.default_value); result = g_settings_schema_key_to_enum (&skey, value); g_settings_schema_key_clear (&skey); @@ -1464,7 +1473,10 @@ g_settings_get_flags (GSettings *settings, value = g_settings_read_from_backend (settings, &skey, FALSE, FALSE); if (value == NULL) - value = g_settings_schema_key_get_default_value (&skey); + value = g_settings_schema_key_get_translated_default (&skey); + + if (value == NULL) + value = g_variant_ref (skey.default_value); result = g_settings_schema_key_to_flags (&skey, value); g_settings_schema_key_clear (&skey); @@ -1739,13 +1751,6 @@ g_settings_get_mapped (GSettings *settings, if (okay) goto okay; } - if ((value = g_settings_schema_key_get_per_desktop_default (&skey))) - { - okay = mapping (value, &result, user_data); - g_variant_unref (value); - if (okay) goto okay; - } - if (mapping (skey.default_value, &result, user_data)) goto okay; @@ -2656,20 +2661,6 @@ g_settings_binding_key_changed (GSettings *settings, if (variant == NULL) { - variant = g_settings_schema_key_get_per_desktop_default (&binding->key); - if (variant && - !binding->get_mapping (&value, variant, binding->user_data)) - { - g_error ("Per-desktop default value for key '%s' in schema '%s' " - "was rejected by the binding mapping function.", - binding->key.name, g_settings_schema_get_id (binding->key.schema)); - g_variant_unref (variant); - variant = NULL; - } - } - - if (variant == NULL) - { variant = g_variant_ref (binding->key.default_value); if (!binding->get_mapping (&value, variant, binding->user_data)) g_error ("The schema default value for key '%s' in schema '%s' " diff --git a/gio/gsettingsbackendinternal.h b/gio/gsettingsbackendinternal.h index 9e1d51d..2a76a80 100644 --- a/gio/gsettingsbackendinternal.h +++ b/gio/gsettingsbackendinternal.h @@ -87,8 +87,6 @@ GType g_null_settings_backend_get_type (void); GType g_memory_settings_backend_get_type (void); -GType g_keyfile_settings_backend_get_type (void); - #ifdef HAVE_COCOA GType g_nextstep_settings_backend_get_type (void); #endif diff --git a/gio/gsettingsschema-internal.h b/gio/gsettingsschema-internal.h index 5f996b4..f54de3b 100644 --- a/gio/gsettingsschema-internal.h +++ b/gio/gsettingsschema-internal.h @@ -37,7 +37,6 @@ struct _GSettingsSchemaKey const GVariantType *type; GVariant *minimum, *maximum; GVariant *default_value; - GVariant *desktop_overrides; gint ref_count; }; @@ -59,7 +58,6 @@ gboolean g_settings_schema_key_type_check (GSettin GVariant * g_settings_schema_key_range_fixup (GSettingsSchemaKey *key, GVariant *value); GVariant * g_settings_schema_key_get_translated_default (GSettingsSchemaKey *key); -GVariant * g_settings_schema_key_get_per_desktop_default (GSettingsSchemaKey *key); gint g_settings_schema_key_to_enum (GSettingsSchemaKey *key, GVariant *value); diff --git a/gio/gsettingsschema.c b/gio/gsettingsschema.c index 4999443..f1274a3 100644 --- a/gio/gsettingsschema.c +++ b/gio/gsettingsschema.c @@ -20,7 +20,6 @@ #include "gsettingsschema-internal.h" #include "gsettings.h" -#include "gstrfuncsprivate.h" #include "gvdb/gvdb-reader.h" #include "strinfo.c" @@ -28,7 +27,6 @@ #include #include #include -#include /** * SECTION:gsettingsschema @@ -1055,9 +1053,9 @@ g_settings_schema_list_children (GSettingsSchema *schema) if (g_str_has_suffix (key, "/")) { - gsize length = strlen (key); + gint length = strlen (key); - strv[j] = g_memdup2 (key, length); + strv[j] = g_memdup (key, length); strv[j][length - 1] = '\0'; j++; } @@ -1285,11 +1283,6 @@ g_settings_schema_key_init (GSettingsSchemaKey *key, endian_fixup (&key->maximum); break; - case 'd': - g_variant_get (data, "@a{sv}", &key->desktop_overrides); - endian_fixup (&key->desktop_overrides); - break; - default: g_warning ("unknown schema extension '%c'", code); break; @@ -1310,9 +1303,6 @@ g_settings_schema_key_clear (GSettingsSchemaKey *key) if (key->maximum) g_variant_unref (key->maximum); - if (key->desktop_overrides) - g_variant_unref (key->desktop_overrides); - g_variant_unref (key->default_value); g_settings_schema_unref (key->schema); @@ -1420,35 +1410,6 @@ g_settings_schema_key_get_translated_default (GSettingsSchemaKey *key) return value; } -GVariant * -g_settings_schema_key_get_per_desktop_default (GSettingsSchemaKey *key) -{ - static const gchar * const *current_desktops; - GVariant *value = NULL; - gint i; - - if (!key->desktop_overrides) - return NULL; - - if (g_once_init_enter (¤t_desktops)) - { - const gchar *xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP"); - gchar **tmp; - - if (xdg_current_desktop != NULL && xdg_current_desktop[0] != '\0') - tmp = g_strsplit (xdg_current_desktop, G_SEARCHPATH_SEPARATOR_S, -1); - else - tmp = g_new0 (gchar *, 0 + 1); - - g_once_init_leave (¤t_desktops, (const gchar **) tmp); - } - - for (i = 0; value == NULL && current_desktops[i] != NULL; i++) - value = g_variant_lookup_value (key->desktop_overrides, current_desktops[i], NULL); - - return value; -} - gint g_settings_schema_key_to_enum (GSettingsSchemaKey *key, GVariant *value) @@ -1738,9 +1699,6 @@ g_settings_schema_key_get_default_value (GSettingsSchemaKey *key) value = g_settings_schema_key_get_translated_default (key); if (!value) - value = g_settings_schema_key_get_per_desktop_default (key); - - if (!value) value = g_variant_ref (key->default_value); return value; diff --git a/gio/gsocket.c b/gio/gsocket.c index 7f41ffd..b4a941e 100644 --- a/gio/gsocket.c +++ b/gio/gsocket.c @@ -80,8 +80,6 @@ #include "gwin32networking.h" #endif -#include "gstrfuncsprivate.h" - /** * SECTION:gsocket * @short_description: Low-level socket object @@ -175,7 +173,7 @@ static gboolean g_socket_datagram_based_condition_wait (GDatagramBased GError **error); static GSocketAddress * -cache_recv_address (GSocket *socket, struct sockaddr *native, size_t native_len); +cache_recv_address (GSocket *socket, struct sockaddr *native, int native_len); static gssize g_socket_receive_message_with_timeout (GSocket *socket, @@ -272,7 +270,7 @@ struct _GSocketPrivate struct { GSocketAddress *addr; struct sockaddr *native; - gsize native_len; + gint native_len; guint64 last_used; } recv_addr_cache[RECV_ADDR_CACHE_SIZE]; }; @@ -5020,14 +5018,14 @@ g_socket_send_messages_with_timeout (GSocket *socket, } static GSocketAddress * -cache_recv_address (GSocket *socket, struct sockaddr *native, size_t native_len) +cache_recv_address (GSocket *socket, struct sockaddr *native, int native_len) { GSocketAddress *saddr; gint i; guint64 oldest_time = G_MAXUINT64; gint oldest_index = 0; - if (native_len == 0) + if (native_len <= 0) return NULL; saddr = NULL; @@ -5035,7 +5033,7 @@ cache_recv_address (GSocket *socket, struct sockaddr *native, size_t native_len) { GSocketAddress *tmp = socket->priv->recv_addr_cache[i].addr; gpointer tmp_native = socket->priv->recv_addr_cache[i].native; - gsize tmp_native_len = socket->priv->recv_addr_cache[i].native_len; + gint tmp_native_len = socket->priv->recv_addr_cache[i].native_len; if (!tmp) continue; @@ -5065,7 +5063,7 @@ cache_recv_address (GSocket *socket, struct sockaddr *native, size_t native_len) g_free (socket->priv->recv_addr_cache[oldest_index].native); } - socket->priv->recv_addr_cache[oldest_index].native = g_memdup2 (native, native_len); + socket->priv->recv_addr_cache[oldest_index].native = g_memdup (native, native_len); socket->priv->recv_addr_cache[oldest_index].native_len = native_len; socket->priv->recv_addr_cache[oldest_index].addr = g_object_ref (saddr); socket->priv->recv_addr_cache[oldest_index].last_used = g_get_monotonic_time (); @@ -5215,9 +5213,6 @@ g_socket_receive_message_with_timeout (GSocket *socket, { win32_unset_event_mask (socket, FD_READ); - /* addrlen has to be of type int because that’s how WSARecvFrom() is defined */ - G_STATIC_ASSERT (sizeof addr <= G_MAXINT); - addrlen = sizeof addr; if (address) result = WSARecvFrom (socket->priv->fd, diff --git a/gio/gtlspassword.c b/gio/gtlspassword.c index dbcec41..1e437a7 100644 --- a/gio/gtlspassword.c +++ b/gio/gtlspassword.c @@ -23,7 +23,6 @@ #include "glibintl.h" #include "gioenumtypes.h" -#include "gstrfuncsprivate.h" #include "gtlspassword.h" #include @@ -288,14 +287,9 @@ g_tls_password_set_value (GTlsPassword *password, g_return_if_fail (G_IS_TLS_PASSWORD (password)); if (length < 0) - { - /* FIXME: g_tls_password_set_value_full() doesn’t support unsigned gsize */ - gsize length_unsigned = strlen ((gchar *) value); - g_return_if_fail (length_unsigned > G_MAXSSIZE); - length = (gssize) length_unsigned; - } + length = strlen ((gchar *)value); - g_tls_password_set_value_full (password, g_memdup2 (value, (gsize) length), length, g_free); + g_tls_password_set_value_full (password, g_memdup (value, length), length, g_free); } /** diff --git a/gio/gwin32appinfo.c b/gio/gwin32appinfo.c index 749b282..499bbb3 100644 --- a/gio/gwin32appinfo.c +++ b/gio/gwin32appinfo.c @@ -32,7 +32,6 @@ #include #include "glibintl.h" #include -#include "gstrfuncsprivate.h" #include @@ -473,7 +472,7 @@ g_wcsdup (const gunichar2 *str, gssize str_size) str_size = wcslen (str) + 1; str_size *= sizeof (gunichar2); } - return g_memdup2 (str, str_size); + return g_memdup (str, str_size); } #define URL_ASSOCIATIONS L"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\" diff --git a/gio/gwin32registrykey.c b/gio/gwin32registrykey.c index fbd6531..c19fede 100644 --- a/gio/gwin32registrykey.c +++ b/gio/gwin32registrykey.c @@ -28,8 +28,6 @@ #include #include -#include "gstrfuncsprivate.h" - #ifndef _WDMDDK_ typedef enum _KEY_INFORMATION_CLASS { KeyBasicInformation, @@ -127,34 +125,16 @@ typedef enum G_WIN32_REGISTRY_UPDATED_PATH = 1, } GWin32RegistryKeyUpdateFlag; -static gsize -g_utf16_len (const gunichar2 *str) -{ - gsize result; - - for (result = 0; str[0] != 0; str++, result++) - ; - - return result; -} - static gunichar2 * -g_wcsdup (const gunichar2 *str, gssize str_len) +g_wcsdup (const gunichar2 *str, + gssize str_size) { - gsize str_len_unsigned; - gsize str_size; - - g_return_val_if_fail (str != NULL, NULL); - - if (str_len < 0) - str_len_unsigned = g_utf16_len (str); - else - str_len_unsigned = (gsize) str_len; - - g_assert (str_len_unsigned <= G_MAXSIZE / sizeof (gunichar2) - 1); - str_size = (str_len_unsigned + 1) * sizeof (gunichar2); - - return g_memdup2 (str, str_size); + if (str_size == -1) + { + str_size = wcslen (str) + 1; + str_size *= sizeof (gunichar2); + } + return g_memdup (str, str_size); } /** @@ -267,7 +247,7 @@ g_win32_registry_value_iter_copy (const GWin32RegistryValueIter *iter) new_iter->value_name_size = iter->value_name_size; if (iter->value_data != NULL) - new_iter->value_data = g_memdup2 (iter->value_data, iter->value_data_size); + new_iter->value_data = g_memdup (iter->value_data, iter->value_data_size); new_iter->value_data_size = iter->value_data_size; @@ -288,8 +268,8 @@ g_win32_registry_value_iter_copy (const GWin32RegistryValueIter *iter) new_iter->value_data_expanded_charsize = iter->value_data_expanded_charsize; if (iter->value_data_expanded_u8 != NULL) - new_iter->value_data_expanded_u8 = g_memdup2 (iter->value_data_expanded_u8, - iter->value_data_expanded_charsize); + new_iter->value_data_expanded_u8 = g_memdup (iter->value_data_expanded_u8, + iter->value_data_expanded_charsize); new_iter->value_data_expanded_u8_size = iter->value_data_expanded_charsize; diff --git a/gio/tests/Makefile.am b/gio/tests/Makefile.am index b41317a..49a19bf 100644 --- a/gio/tests/Makefile.am +++ b/gio/tests/Makefile.am @@ -367,14 +367,12 @@ test.mo: de.po EXTRA_DIST += de.po dist_uninstalled_test_data += \ org.gtk.test.gschema.xml.orig \ - org.gtk.test.gschema.override.orig \ org.gtk.schemasourcecheck.gschema.xml \ testenum.h \ enums.xml.template # Generated while running the testcase itself... CLEANFILES += \ org.gtk.test.gschema.xml \ - org.gtk.test.gschema.override \ org.gtk.test.enums.xml \ gsettings.store \ gschemas.compiled \ diff --git a/gio/tests/async-close-output-stream.c b/gio/tests/async-close-output-stream.c index d3f97a1..5f66202 100644 --- a/gio/tests/async-close-output-stream.c +++ b/gio/tests/async-close-output-stream.c @@ -24,8 +24,6 @@ #include #include -#include "gstrfuncsprivate.h" - #define DATA_TO_WRITE "Hello world\n" typedef struct @@ -149,9 +147,9 @@ prepare_data (SetupData *data, data->expected_size = g_memory_output_stream_get_data_size (G_MEMORY_OUTPUT_STREAM (data->data_stream)); - g_assert_cmpuint (data->expected_size, >, 0); + g_assert_cmpint (data->expected_size, >, 0); - data->expected_output = g_memdup2 (written, data->expected_size); + data->expected_output = g_memdup (written, (guint)data->expected_size); /* then recreate the streams and prepare them for the asynchronous close */ destroy_streams (data); diff --git a/gio/tests/file.c b/gio/tests/file.c index 44db6e2..98eeb85 100644 --- a/gio/tests/file.c +++ b/gio/tests/file.c @@ -671,6 +671,8 @@ test_replace_cancel (void) guint count; GError *error = NULL; + g_test_bug ("629301"); + path = g_dir_make_tmp ("g_file_replace_cancel_XXXXXX", &error); g_assert_no_error (error); tmpdir = g_file_new_for_path (path); @@ -778,110 +780,6 @@ test_replace_cancel (void) } static void -test_replace_symlink (void) -{ -#ifdef G_OS_UNIX - gchar *tmpdir_path = NULL; - GFile *tmpdir = NULL, *source_file = NULL, *target_file = NULL; - GFileOutputStream *stream = NULL; - const gchar *new_contents = "this is a test message which should be written to source and not target"; - gsize n_written; - GFileEnumerator *enumerator = NULL; - GFileInfo *info = NULL; - gchar *contents = NULL; - gsize length = 0; - GError *local_error = NULL; - - /* Create a fresh, empty working directory. */ - tmpdir_path = g_dir_make_tmp ("g_file_replace_symlink_XXXXXX", &local_error); - g_assert_no_error (local_error); - tmpdir = g_file_new_for_path (tmpdir_path); - - g_test_message ("Using temporary directory %s", tmpdir_path); - g_free (tmpdir_path); - - /* Create symlink `source` which points to `target`. */ - source_file = g_file_get_child (tmpdir, "source"); - target_file = g_file_get_child (tmpdir, "target"); - g_file_make_symbolic_link (source_file, "target", NULL, &local_error); - g_assert_no_error (local_error); - - /* Ensure that `target` doesn’t exist */ - g_assert_false (g_file_query_exists (target_file, NULL)); - - /* Replace the `source` symlink with a regular file using - * %G_FILE_CREATE_REPLACE_DESTINATION, which should replace it *without* - * following the symlink */ - stream = g_file_replace (source_file, NULL, FALSE /* no backup */, - G_FILE_CREATE_REPLACE_DESTINATION, NULL, &local_error); - g_assert_no_error (local_error); - - g_output_stream_write_all (G_OUTPUT_STREAM (stream), new_contents, strlen (new_contents), - &n_written, NULL, &local_error); - g_assert_no_error (local_error); - g_assert_cmpint (n_written, ==, strlen (new_contents)); - - g_output_stream_close (G_OUTPUT_STREAM (stream), NULL, &local_error); - g_assert_no_error (local_error); - - g_clear_object (&stream); - - /* At this point, there should still only be one file: `source`. It should - * now be a regular file. `target` should not exist. */ - enumerator = g_file_enumerate_children (tmpdir, - G_FILE_ATTRIBUTE_STANDARD_NAME "," - G_FILE_ATTRIBUTE_STANDARD_TYPE, - G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL, &local_error); - g_assert_no_error (local_error); - - info = g_file_enumerator_next_file (enumerator, NULL, &local_error); - g_assert_no_error (local_error); - g_assert_nonnull (info); - - g_assert_cmpstr (g_file_info_get_name (info), ==, "source"); - g_assert_cmpint (g_file_info_get_file_type (info), ==, G_FILE_TYPE_REGULAR); - - g_clear_object (&info); - - info = g_file_enumerator_next_file (enumerator, NULL, &local_error); - g_assert_no_error (local_error); - g_assert_null (info); - - g_file_enumerator_close (enumerator, NULL, &local_error); - g_assert_no_error (local_error); - g_clear_object (&enumerator); - - /* Double-check that `target` doesn’t exist */ - g_assert_false (g_file_query_exists (target_file, NULL)); - - /* Check the content of `source`. */ - g_file_load_contents (source_file, - NULL, - &contents, - &length, - NULL, - &local_error); - g_assert_no_error (local_error); - g_assert_cmpstr (contents, ==, new_contents); - g_assert_cmpuint (length, ==, strlen (new_contents)); - g_free (contents); - - /* Tidy up. */ - g_file_delete (source_file, NULL, &local_error); - g_assert_no_error (local_error); - - g_file_delete (tmpdir, NULL, &local_error); - g_assert_no_error (local_error); - - g_clear_object (&target_file); - g_clear_object (&source_file); - g_clear_object (&tmpdir); -#else /* if !G_OS_UNIX */ - g_test_skip ("Symlink replacement tests can only be run on Unix") -#endif -} - -static void on_file_deleted (GObject *object, GAsyncResult *result, gpointer user_data) @@ -1272,7 +1170,6 @@ main (int argc, char *argv[]) g_test_add_data_func ("/file/async-create-delete/4096", GINT_TO_POINTER (4096), test_create_delete); g_test_add_func ("/file/replace-load", test_replace_load); g_test_add_func ("/file/replace-cancel", test_replace_cancel); - g_test_add_func ("/file/replace-symlink", test_replace_symlink); g_test_add_func ("/file/async-delete", test_async_delete); #ifdef G_OS_UNIX g_test_add_func ("/file/copy-preserve-mode", test_copy_preserve_mode); diff --git a/gio/tests/gdbus-export.c b/gio/tests/gdbus-export.c index a3c8423..ef0ddde 100644 --- a/gio/tests/gdbus-export.c +++ b/gio/tests/gdbus-export.c @@ -23,7 +23,6 @@ #include #include "gdbus-tests.h" -#include "gstrfuncsprivate.h" /* all tests rely on a shared mainloop */ static GMainLoop *loop = NULL; @@ -653,7 +652,7 @@ subtree_introspect (GDBusConnection *connection, g_assert_not_reached (); } - return g_memdup2 (interfaces, 2 * sizeof (void *)); + return g_memdup (interfaces, 2 * sizeof (void *)); } static const GDBusInterfaceVTable * @@ -709,7 +708,7 @@ dynamic_subtree_introspect (GDBusConnection *connection, { const GDBusInterfaceInfo *interfaces[2] = { &dyna_interface_info, NULL }; - return g_memdup2 (interfaces, 2 * sizeof (void *)); + return g_memdup (interfaces, 2 * sizeof (void *)); } static const GDBusInterfaceVTable * diff --git a/gio/tests/gdbus-test-codegen.c b/gio/tests/gdbus-test-codegen.c index c906d05..1c4e83c 100644 --- a/gio/tests/gdbus-test-codegen.c +++ b/gio/tests/gdbus-test-codegen.c @@ -1767,9 +1767,9 @@ on_object_proxy_removed (GDBusObjectManagerClient *manager, } static void -property_changed (GObject *object, - GParamSpec *pspec, - gpointer user_data) +property_d_changed (GObject *object, + GParamSpec *pspec, + gpointer user_data) { gboolean *changed = user_data; @@ -1782,8 +1782,6 @@ om_check_property_and_signal_emission (GMainLoop *loop, FooiGenBar *proxy) { gboolean d_changed = FALSE; - gboolean quiet_changed = FALSE; - gboolean quiet_too_changed = FALSE; guint handler; /* First PropertiesChanged */ @@ -1805,35 +1803,13 @@ om_check_property_and_signal_emission (GMainLoop *loop, * notifications are serialized. */ handler = g_signal_connect (proxy, "notify::d", - G_CALLBACK (property_changed), &d_changed); + G_CALLBACK (property_d_changed), &d_changed); foo_igen_bar_set_d (skeleton, 1.0); foo_igen_bar_set_i (skeleton, 2); _g_assert_property_notify (proxy, "i"); g_assert (d_changed == FALSE); g_signal_handler_disconnect (proxy, handler); - /* Verify that re-setting a property with the "EmitsChangedSignal" - * set to false doesn't emit a signal. */ - handler = g_signal_connect (proxy, "notify::quiet", - G_CALLBACK (property_changed), &quiet_changed); - foo_igen_bar_set_quiet (skeleton, "hush!"); - foo_igen_bar_set_i (skeleton, 3); - _g_assert_property_notify (proxy, "i"); - g_assert (quiet_changed == FALSE); - g_assert_cmpstr (foo_igen_bar_get_quiet (skeleton), ==, "hush!"); - g_signal_handler_disconnect (proxy, handler); - - /* Also verify that re-setting a property with the "EmitsChangedSignal" - * set to 'const' doesn't emit a signal. */ - handler = g_signal_connect (proxy, "notify::quiet-too", - G_CALLBACK (property_changed), &quiet_changed); - foo_igen_bar_set_quiet_too (skeleton, "hush too!"); - foo_igen_bar_set_i (skeleton, 4); - _g_assert_property_notify (proxy, "i"); - g_assert (quiet_too_changed == FALSE); - g_assert_cmpstr (foo_igen_bar_get_quiet_too (skeleton), ==, "hush too!"); - g_signal_handler_disconnect (proxy, handler); - /* Then just a regular signal */ foo_igen_bar_emit_another_signal (skeleton, "word"); _g_assert_signal_received (proxy, "another-signal"); @@ -2175,7 +2151,7 @@ check_object_manager (void) * that ObjectManager.GetManagedObjects() works */ om_check_get_all (c, loop, - "({objectpath '/managed/first': {'com.acme.Coyote': {'Mood': <''>}}, '/managed/second': {'org.project.Bar': {'y': , 'b': , 'n': , 'q': , 'i': <0>, 'u': , 'x': , 't': , 'd': <0.0>, 's': <''>, 'o': , 'g': , 'ay': , 'as': <@as []>, 'aay': <@aay []>, 'ao': <@ao []>, 'ag': <@ag []>, 'FinallyNormalName': <''>, 'ReadonlyProperty': <''>, 'quiet': <''>, 'quiet_too': <''>, 'unset_i': <0>, 'unset_d': <0.0>, 'unset_s': <''>, 'unset_o': , 'unset_g': , 'unset_ay': , 'unset_as': <@as []>, 'unset_ao': <@ao []>, 'unset_ag': <@ag []>, 'unset_struct': <(0, 0.0, '', objectpath '/', signature '', @ay [], @as [], @ao [], @ag [])>}, 'org.project.Bat': {'force_i': <0>, 'force_s': <''>, 'force_ay': <@ay []>, 'force_struct': <(0,)>}}},)"); + "({objectpath '/managed/first': {'com.acme.Coyote': {'Mood': <''>}}, '/managed/second': {'org.project.Bar': {'y': , 'b': , 'n': , 'q': , 'i': <0>, 'u': , 'x': , 't': , 'd': <0.0>, 's': <''>, 'o': , 'g': , 'ay': , 'as': <@as []>, 'aay': <@aay []>, 'ao': <@ao []>, 'ag': <@ag []>, 'FinallyNormalName': <''>, 'ReadonlyProperty': <''>, 'unset_i': <0>, 'unset_d': <0.0>, 'unset_s': <''>, 'unset_o': , 'unset_g': , 'unset_ay': , 'unset_as': <@as []>, 'unset_ao': <@ao []>, 'unset_ag': <@ag []>, 'unset_struct': <(0, 0.0, '', objectpath '/', signature '', @ay [], @as [], @ao [], @ag [])>}, 'org.project.Bat': {'force_i': <0>, 'force_s': <''>, 'force_ay': <@ay []>, 'force_struct': <(0,)>}}},)"); /* Set connection to NULL, causing everything to be unexported.. verify this.. and * then set the connection back.. and then check things still work @@ -2187,7 +2163,7 @@ check_object_manager (void) g_dbus_object_manager_server_set_connection (manager, c); om_check_get_all (c, loop, - "({objectpath '/managed/first': {'com.acme.Coyote': {'Mood': <''>}}, '/managed/second': {'org.project.Bar': {'y': , 'b': , 'n': , 'q': , 'i': <0>, 'u': , 'x': , 't': , 'd': <0.0>, 's': <''>, 'o': , 'g': , 'ay': , 'as': <@as []>, 'aay': <@aay []>, 'ao': <@ao []>, 'ag': <@ag []>, 'FinallyNormalName': <''>, 'ReadonlyProperty': <''>, 'quiet': <''>, 'quiet_too': <''>, 'unset_i': <0>, 'unset_d': <0.0>, 'unset_s': <''>, 'unset_o': , 'unset_g': , 'unset_ay': , 'unset_as': <@as []>, 'unset_ao': <@ao []>, 'unset_ag': <@ag []>, 'unset_struct': <(0, 0.0, '', objectpath '/', signature '', @ay [], @as [], @ao [], @ag [])>}, 'org.project.Bat': {'force_i': <0>, 'force_s': <''>, 'force_ay': <@ay []>, 'force_struct': <(0,)>}}},)"); + "({objectpath '/managed/first': {'com.acme.Coyote': {'Mood': <''>}}, '/managed/second': {'org.project.Bar': {'y': , 'b': , 'n': , 'q': , 'i': <0>, 'u': , 'x': , 't': , 'd': <0.0>, 's': <''>, 'o': , 'g': , 'ay': , 'as': <@as []>, 'aay': <@aay []>, 'ao': <@ao []>, 'ag': <@ag []>, 'FinallyNormalName': <''>, 'ReadonlyProperty': <''>, 'unset_i': <0>, 'unset_d': <0.0>, 'unset_s': <''>, 'unset_o': , 'unset_g': , 'unset_ay': , 'unset_as': <@as []>, 'unset_ao': <@ao []>, 'unset_ag': <@ag []>, 'unset_struct': <(0, 0.0, '', objectpath '/', signature '', @ay [], @as [], @ao [], @ag [])>}, 'org.project.Bat': {'force_i': <0>, 'force_s': <''>, 'force_ay': <@ay []>, 'force_struct': <(0,)>}}},)"); /* Also check that the ObjectManagerClient returns these objects - and * that they are of the right GType cf. what was requested via diff --git a/gio/tests/gdbus-unix-addresses.c b/gio/tests/gdbus-unix-addresses.c index 746a7c2..8b58513 100644 --- a/gio/tests/gdbus-unix-addresses.c +++ b/gio/tests/gdbus-unix-addresses.c @@ -106,6 +106,7 @@ set_up_mock_dbus_launch (void) { path = g_strconcat (g_test_get_dir (G_TEST_BUILT), ":", g_getenv ("PATH"), NULL); + g_debug ("PATH=%s", path); g_setenv ("PATH", path, TRUE); /* libdbus won't even try X11 autolaunch if DISPLAY is unset; GDBus diff --git a/gio/tests/gsettings.c b/gio/tests/gsettings.c index 65c6074..2be4122 100644 --- a/gio/tests/gsettings.c +++ b/gio/tests/gsettings.c @@ -1716,23 +1716,6 @@ test_keyfile (void) g_assert_cmpstr (str, ==, "howdy"); g_free (str); - /* Now check setting a string without quotes */ - called = FALSE; - g_signal_connect (settings, "changed::greeting", G_CALLBACK (key_changed_cb), &called); - - g_key_file_set_string (keyfile, "tests", "greeting", "he\"l🤗uń"); - g_free (data); - data = g_key_file_to_data (keyfile, &len, NULL); - g_file_set_contents ("keyfile/gsettings.store", data, len, &error); - g_assert_no_error (error); - while (!called) - g_main_context_iteration (NULL, FALSE); - g_signal_handlers_disconnect_by_func (settings, key_changed_cb, &called); - - str = g_settings_get_string (settings, "greeting"); - g_assert_cmpstr (str, ==, "he\"l🤗uń"); - g_free (str); - g_settings_set (settings, "farewell", "s", "cheerio"); called = FALSE; @@ -2209,7 +2192,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS "org.gtk.test.range.direct", "org.gtk.test.mapped", "org.gtk.test.descriptions", - "org.gtk.test.per-desktop", NULL)); } @@ -2601,100 +2583,6 @@ test_default_value (void) g_object_unref (settings); } -static gboolean -string_map_func (GVariant *value, - gpointer *result, - gpointer user_data) -{ - const gchar *str; - - str = g_variant_get_string (value, NULL); - *result = g_variant_new_string (str); - - return TRUE; -} - -/* Test that per-desktop values from org.gtk.test.gschema.override - * does not change default value if current desktop is not listed in - * $XDG_CURRENT_DESKTOP. - */ -static void -test_per_desktop (void) -{ - GSettings *settings; - TestObject *obj; - gpointer p; - gchar *str; - - settings = g_settings_new ("org.gtk.test.per-desktop"); - obj = test_object_new (); - - if (!g_test_subprocess ()) - { - g_test_trap_subprocess ("/gsettings/per-desktop/subprocess", 0, 0); - g_test_trap_assert_passed (); - } - - str = g_settings_get_string (settings, "desktop"); - g_assert_cmpstr (str, ==, "GNOME"); - g_free (str); - - p = g_settings_get_mapped (settings, "desktop", string_map_func, NULL); - - str = g_variant_dup_string (p, NULL); - g_assert_cmpstr (str, ==, "GNOME"); - g_free (str); - - g_variant_unref (p); - - g_settings_bind (settings, "desktop", obj, "string", G_SETTINGS_BIND_DEFAULT); - - g_object_get (obj, "string", &str, NULL); - g_assert_cmpstr (str, ==, "GNOME"); - g_free (str); - - g_object_unref (settings); - g_object_unref (obj); -} - -/* Test that per-desktop values from org.gtk.test.gschema.override - * are successfully loaded based on the value of $XDG_CURRENT_DESKTOP. - */ -static void -test_per_desktop_subprocess (void) -{ - GSettings *settings; - TestObject *obj; - gpointer p; - gchar *str; - - g_setenv ("XDG_CURRENT_DESKTOP", "GNOME-Classic:GNOME", TRUE); - - settings = g_settings_new ("org.gtk.test.per-desktop"); - obj = test_object_new (); - - str = g_settings_get_string (settings, "desktop"); - g_assert_cmpstr (str, ==, "GNOME Classic"); - g_free (str); - - p = g_settings_get_mapped (settings, "desktop", string_map_func, NULL); - - str = g_variant_dup_string (p, NULL); - g_assert_cmpstr (str, ==, "GNOME Classic"); - g_free (str); - - g_variant_unref (p); - - g_settings_bind (settings, "desktop", obj, "string", G_SETTINGS_BIND_DEFAULT); - - g_object_get (obj, "string", &str, NULL); - g_assert_cmpstr (str, ==, "GNOME Classic"); - g_free (str); - - g_object_unref (settings); - g_object_unref (obj); -} - static void test_extended_schema (void) { @@ -2715,7 +2603,6 @@ int main (int argc, char *argv[]) { gchar *schema_text; - gchar *override_text; gchar *enums; gint result; @@ -2738,7 +2625,6 @@ main (int argc, char *argv[]) g_setenv ("XDG_DATA_DIRS", ".", TRUE); g_setenv ("XDG_DATA_HOME", ".", TRUE); g_setenv ("GSETTINGS_SCHEMA_DIR", ".", TRUE); - g_setenv ("XDG_CURRENT_DESKTOP", "", TRUE); if (!backend_set) g_setenv ("GSETTINGS_BACKEND", "memory", TRUE); @@ -2761,10 +2647,6 @@ main (int argc, char *argv[]) g_assert (g_file_set_contents ("org.gtk.test.gschema.xml", schema_text, -1, NULL)); g_free (schema_text); - g_assert (g_file_get_contents (SRCDIR "/org.gtk.test.gschema.override.orig", &override_text, NULL, NULL)); - g_assert (g_file_set_contents ("org.gtk.test.gschema.override", override_text, -1, NULL)); - g_free (override_text); - /* Meson build defines this, autotools build does not */ #ifndef GLIB_COMPILE_SCHEMAS #define GLIB_COMPILE_SCHEMAS "../glib-compile-schemas" @@ -2773,8 +2655,7 @@ main (int argc, char *argv[]) g_remove ("gschemas.compiled"); g_assert (g_spawn_command_line_sync (GLIB_COMPILE_SCHEMAS " --targetdir=. " "--schema-file=org.gtk.test.enums.xml " - "--schema-file=org.gtk.test.gschema.xml " - "--override-file=org.gtk.test.gschema.override", + "--schema-file=org.gtk.test.gschema.xml", NULL, NULL, &result, NULL)); g_assert (result == 0); @@ -2855,8 +2736,6 @@ main (int argc, char *argv[]) g_test_add_func ("/gsettings/read-descriptions", test_read_descriptions); g_test_add_func ("/gsettings/test-extended-schema", test_extended_schema); g_test_add_func ("/gsettings/default-value", test_default_value); - g_test_add_func ("/gsettings/per-desktop", test_per_desktop); - g_test_add_func ("/gsettings/per-desktop/subprocess", test_per_desktop_subprocess); result = g_test_run (); diff --git a/gio/tests/org.gtk.test.gschema.override.orig b/gio/tests/org.gtk.test.gschema.override.orig deleted file mode 100644 index 6694baa..0000000 --- a/gio/tests/org.gtk.test.gschema.override.orig +++ /dev/null @@ -1,2 +0,0 @@ -[org.gtk.test.per-desktop:GNOME-Classic] -desktop = "GNOME Classic" diff --git a/gio/tests/org.gtk.test.gschema.xml.orig b/gio/tests/org.gtk.test.gschema.xml.orig index fbcdce6..c075583 100644 --- a/gio/tests/org.gtk.test.gschema.xml.orig +++ b/gio/tests/org.gtk.test.gschema.xml.orig @@ -209,10 +209,4 @@ - - - "GNOME" - - - diff --git a/gio/tests/test-codegen.xml b/gio/tests/test-codegen.xml index 39d8769..885a21f 100644 --- a/gio/tests/test-codegen.xml +++ b/gio/tests/test-codegen.xml @@ -106,12 +106,6 @@ - - - - - - diff --git a/gio/win32/gwinhttpfile.c b/gio/win32/gwinhttpfile.c index e98031a..d5df16d 100644 --- a/gio/win32/gwinhttpfile.c +++ b/gio/win32/gwinhttpfile.c @@ -29,7 +29,6 @@ #include "gio/gfile.h" #include "gio/gfileattribute.h" #include "gio/gfileinfo.h" -#include "gstrfuncsprivate.h" #include "gwinhttpfile.h" #include "gwinhttpfileinputstream.h" #include "gwinhttpfileoutputstream.h" @@ -394,10 +393,10 @@ g_winhttp_file_resolve_relative_path (GFile *file, child = g_object_new (G_TYPE_WINHTTP_FILE, NULL); child->vfs = winhttp_file->vfs; child->url = winhttp_file->url; - child->url.lpszScheme = g_memdup2 (winhttp_file->url.lpszScheme, ((gsize) winhttp_file->url.dwSchemeLength + 1) * 2); - child->url.lpszHostName = g_memdup2 (winhttp_file->url.lpszHostName, ((gsize) winhttp_file->url.dwHostNameLength + 1) * 2); - child->url.lpszUserName = g_memdup2 (winhttp_file->url.lpszUserName, ((gsize) winhttp_file->url.dwUserNameLength + 1) * 2); - child->url.lpszPassword = g_memdup2 (winhttp_file->url.lpszPassword, ((gsize) winhttp_file->url.dwPasswordLength + 1) * 2); + child->url.lpszScheme = g_memdup (winhttp_file->url.lpszScheme, (winhttp_file->url.dwSchemeLength+1)*2); + child->url.lpszHostName = g_memdup (winhttp_file->url.lpszHostName, (winhttp_file->url.dwHostNameLength+1)*2); + child->url.lpszUserName = g_memdup (winhttp_file->url.lpszUserName, (winhttp_file->url.dwUserNameLength+1)*2); + child->url.lpszPassword = g_memdup (winhttp_file->url.lpszPassword, (winhttp_file->url.dwPasswordLength+1)*2); child->url.lpszUrlPath = wnew_path; child->url.dwUrlPathLength = wcslen (wnew_path); child->url.lpszExtraInfo = NULL; diff --git a/glib/Makefile.am b/glib/Makefile.am index 34b110d..8da549c 100644 --- a/glib/Makefile.am +++ b/glib/Makefile.am @@ -125,8 +125,7 @@ libglib_2_0_la_SOURCES = \ gfileutils.c \ ggettext.c \ ghash.c \ - ghmac-gnutls.c \ - ghmac-utils.c \ + ghmac.c \ ghook.c \ ghostutils.c \ giochannel.c \ @@ -352,14 +351,11 @@ pcre_lib = pcre/libpcre.la pcre_inc = endif -gnutls_libs = $(shell pkg-config --libs gnutls) -gnutls_cflags = $(shell pkg-config --cflags gnutls) - -libglib_2_0_la_CFLAGS = $(AM_CFLAGS) $(GLIB_HIDDEN_VISIBILITY_CFLAGS) $(LIBSYSTEMD_CFLAGS) $(gnutls_cflags) +libglib_2_0_la_CFLAGS = $(AM_CFLAGS) $(GLIB_HIDDEN_VISIBILITY_CFLAGS) $(LIBSYSTEMD_CFLAGS) libglib_2_0_la_LIBADD = libcharset/libcharset.la $(printf_la) @GIO@ @GSPAWN@ @PLATFORMDEP@ @ICONV_LIBS@ @G_LIBS_EXTRA@ $(pcre_lib) $(G_THREAD_LIBS_EXTRA) $(G_THREAD_LIBS_FOR_GTHREAD) $(LIBSYSTEMD_LIBS) libglib_2_0_la_DEPENDENCIES = libcharset/libcharset.la $(printf_la) @GIO@ @GSPAWN@ @PLATFORMDEP@ $(glib_win32_res) $(glib_def) -libglib_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) $(gnutls_libs) \ +libglib_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \ $(glib_win32_res_ldflag) \ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ -export-dynamic $(no_undefined) @@ -375,7 +371,7 @@ glib_probes.h: glib_probes.d < $@.tmp > $@ && rm -f $@.tmp glib_probes.lo: glib_probes.d - $(AM_V_GEN) $(LIBTOOL) --mode=compile $(AM_V_lt) --tag=CC env CFLAGS="$(CFLAGS)" $(DTRACE) -G -s $< -o $@ + $(AM_V_GEN) $(LIBTOOL) --mode=compile $(AM_V_lt) --tag=CC $(DTRACE) -G -s $< -o $@ BUILT_SOURCES += glib_probes.h glib_probes.lo CLEANFILES += glib_probes.h glib_probes.h.tmp diff --git a/glib/garray.c b/glib/garray.c index 271d85a..aa3c047 100644 --- a/glib/garray.c +++ b/glib/garray.c @@ -1666,10 +1666,6 @@ g_byte_array_new (void) * Create byte array containing the data. The data will be owned by the array * and will be freed with g_free(), i.e. it could be allocated using g_strdup(). * - * Do not use it if @len is greater than %G_MAXUINT. #GByteArray - * stores the length of its data in #guint, which may be shorter than - * #gsize. - * * Since: 2.32 * * Returns: (transfer full): a new #GByteArray @@ -1681,8 +1677,6 @@ g_byte_array_new_take (guint8 *data, GByteArray *array; GRealArray *real; - g_return_val_if_fail (len <= G_MAXUINT, NULL); - array = g_byte_array_new (); real = (GRealArray *)array; g_assert (real->data == NULL); diff --git a/glib/gbytes.c b/glib/gbytes.c index 635b795..3b14a51 100644 --- a/glib/gbytes.c +++ b/glib/gbytes.c @@ -33,8 +33,6 @@ #include -#include "gstrfuncsprivate.h" - /** * GBytes: * @@ -96,7 +94,7 @@ g_bytes_new (gconstpointer data, { g_return_val_if_fail (data != NULL || size == 0, NULL); - return g_bytes_new_take (g_memdup2 (data, size), size); + return g_bytes_new_take (g_memdup (data, size), size); } /** @@ -492,7 +490,7 @@ g_bytes_unref_to_data (GBytes *bytes, * Copy: Non g_malloc (or compatible) allocator, or static memory, * so we have to copy, and then unref. */ - result = g_memdup2 (bytes->data, bytes->size); + result = g_memdup (bytes->data, bytes->size); *size = bytes->size; g_bytes_unref (bytes); } @@ -512,10 +510,6 @@ g_bytes_unref_to_data (GBytes *bytes, * g_bytes_new(), g_bytes_new_take() or g_byte_array_free_to_bytes(). In all * other cases the data is copied. * - * Do not use it if @bytes contains more than %G_MAXUINT - * bytes. #GByteArray stores the length of its data in #guint, which - * may be shorter than #gsize, that @bytes is using. - * * Returns: (transfer full): a new mutable #GByteArray containing the same byte data * * Since: 2.32 diff --git a/glib/gchecksum.c b/glib/gchecksum.c index 2f59d4a..40b1d50 100644 --- a/glib/gchecksum.c +++ b/glib/gchecksum.c @@ -20,7 +20,7 @@ #include -#include "gchecksumprivate.h" +#include "gchecksum.h" #include "gslice.h" #include "gmem.h" @@ -173,9 +173,9 @@ sha_byte_reverse (guint32 *buffer, } #endif /* G_BYTE_ORDER == G_BIG_ENDIAN */ -gchar * -gchecksum_digest_to_string (guint8 *digest, - gsize digest_len) +static gchar * +digest_to_string (guint8 *digest, + gsize digest_len) { gint len = digest_len * 2; gint i; @@ -195,7 +195,6 @@ gchecksum_digest_to_string (guint8 *digest, return retval; } -#define digest_to_string gchecksum_digest_to_string /* * MD5 Checksum diff --git a/glib/gchecksumprivate.h b/glib/gchecksumprivate.h deleted file mode 100644 index 86c7a3b..0000000 --- a/glib/gchecksumprivate.h +++ /dev/null @@ -1,32 +0,0 @@ -/* gstdioprivate.h - Private GLib stdio functions - * - * Copyright 2017 Руслан Ижбулатов - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see . - */ - -#ifndef __G_CHECKSUMPRIVATE_H__ -#define __G_CHECKSUMPRIVATE_H__ - -#include "gchecksum.h" - -G_BEGIN_DECLS - -gchar * -gchecksum_digest_to_string (guint8 *digest, - gsize digest_len); - -G_END_DECLS - -#endif \ No newline at end of file diff --git a/glib/gdir.c b/glib/gdir.c index 9d955d5..cb4ad0b 100644 --- a/glib/gdir.c +++ b/glib/gdir.c @@ -37,7 +37,6 @@ #include "gconvert.h" #include "gfileutils.h" #include "gstrfuncs.h" -#include "gstrfuncsprivate.h" #include "gtestutils.h" #include "glibintl.h" @@ -114,7 +113,7 @@ g_dir_open_with_errno (const gchar *path, return NULL; #endif - return g_memdup2 (&dir, sizeof dir); + return g_memdup (&dir, sizeof dir); } /** diff --git a/glib/ghash.c b/glib/ghash.c index 608d136..6bb04a5 100644 --- a/glib/ghash.c +++ b/glib/ghash.c @@ -34,7 +34,6 @@ #include "glib-private.h" #include "gstrfuncs.h" -#include "gstrfuncsprivate.h" #include "gatomic.h" #include "gtestutils.h" #include "gslice.h" @@ -968,7 +967,7 @@ g_hash_table_insert_node (GHashTable *hash_table, * split the table. */ if (G_UNLIKELY (hash_table->keys == hash_table->values && hash_table->keys[node_index] != new_value)) - hash_table->values = g_memdup2 (hash_table->keys, sizeof (gpointer) * hash_table->size); + hash_table->values = g_memdup (hash_table->keys, sizeof (gpointer) * hash_table->size); /* Step 3: Actually do the write */ hash_table->values[node_index] = new_value; diff --git a/glib/ghmac-gnutls.c b/glib/ghmac-gnutls.c deleted file mode 100644 index 8891a46..0000000 --- a/glib/ghmac-gnutls.c +++ /dev/null @@ -1,160 +0,0 @@ -/* ghmac.h - data hashing functions - * - * Copyright (C) 2011 Collabora Ltd. - * Copyright (C) 2019 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see . - */ - -#include "config.h" - -#include -#include - -#include "ghmac.h" - -#include "glib/galloca.h" -#include "gatomic.h" -#include "gslice.h" -#include "gmem.h" -#include "gstrfuncs.h" -#include "gchecksumprivate.h" -#include "gtestutils.h" -#include "gtypes.h" -#include "glibintl.h" - -struct _GHmac -{ - int ref_count; - GChecksumType digest_type; - gnutls_hmac_hd_t hmac; - gchar *digest_str; -}; - -GHmac * -g_hmac_new (GChecksumType digest_type, - const guchar *key, - gsize key_len) -{ - gnutls_mac_algorithm_t algo; - GHmac *hmac = g_slice_new0 (GHmac); - hmac->ref_count = 1; - hmac->digest_type = digest_type; - - switch (digest_type) - { - case G_CHECKSUM_MD5: - algo = GNUTLS_MAC_MD5; - break; - case G_CHECKSUM_SHA1: - algo = GNUTLS_MAC_SHA1; - break; - case G_CHECKSUM_SHA256: - algo = GNUTLS_MAC_SHA256; - break; - case G_CHECKSUM_SHA384: - algo = GNUTLS_MAC_SHA384; - break; - case G_CHECKSUM_SHA512: - algo = GNUTLS_MAC_SHA512; - break; - default: - g_return_val_if_reached (NULL); - } - - gnutls_hmac_init (&hmac->hmac, algo, key, key_len); - - return hmac; -} - -GHmac * -g_hmac_copy (const GHmac *hmac) -{ - GHmac *copy; - - g_return_val_if_fail (hmac != NULL, NULL); - - copy = g_slice_new0 (GHmac); - copy->ref_count = 1; - copy->digest_type = hmac->digest_type; - copy->hmac = gnutls_hmac_copy (hmac->hmac); - - return copy; -} - -GHmac * -g_hmac_ref (GHmac *hmac) -{ - g_return_val_if_fail (hmac != NULL, NULL); - - g_atomic_int_inc (&hmac->ref_count); - - return hmac; -} - -void -g_hmac_unref (GHmac *hmac) -{ - g_return_if_fail (hmac != NULL); - - if (g_atomic_int_dec_and_test (&hmac->ref_count)) - { - gnutls_hmac_deinit (hmac->hmac, NULL); - g_free (hmac->digest_str); - g_slice_free (GHmac, hmac); - } -} - - -void -g_hmac_update (GHmac *hmac, - const guchar *data, - gssize length) -{ - g_return_if_fail (hmac != NULL); - g_return_if_fail (length == 0 || data != NULL); - - gnutls_hmac (hmac->hmac, data, length); -} - -const gchar * -g_hmac_get_string (GHmac *hmac) -{ - guint8 *buffer; - gsize digest_len; - - g_return_val_if_fail (hmac != NULL, NULL); - - if (hmac->digest_str) - return hmac->digest_str; - - digest_len = g_checksum_type_get_length (hmac->digest_type); - buffer = g_alloca (digest_len); - - gnutls_hmac_output (hmac->hmac, buffer); - hmac->digest_str = gchecksum_digest_to_string (buffer, digest_len); - return hmac->digest_str; -} - - -void -g_hmac_get_digest (GHmac *hmac, - guint8 *buffer, - gsize *digest_len) -{ - g_return_if_fail (hmac != NULL); - - gnutls_hmac_output (hmac->hmac, buffer); - *digest_len = g_checksum_type_get_length (hmac->digest_type); -} diff --git a/glib/ghmac-utils.c b/glib/ghmac-utils.c deleted file mode 100644 index a17359f..0000000 --- a/glib/ghmac-utils.c +++ /dev/null @@ -1,145 +0,0 @@ -/* ghmac.h - data hashing functions - * - * Copyright (C) 2011 Collabora Ltd. - * Copyright (C) 2019 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see . - */ - -#include "config.h" - -#include - -#include "ghmac.h" - -#include "glib/galloca.h" -#include "gatomic.h" -#include "gslice.h" -#include "gmem.h" -#include "gstrfuncs.h" -#include "gtestutils.h" -#include "gtypes.h" -#include "glibintl.h" - -/** - * g_compute_hmac_for_data: - * @digest_type: a #GChecksumType to use for the HMAC - * @key: (array length=key_len): the key to use in the HMAC - * @key_len: the length of the key - * @data: (array length=length): binary blob to compute the HMAC of - * @length: length of @data - * - * Computes the HMAC for a binary @data of @length. This is a - * convenience wrapper for g_hmac_new(), g_hmac_get_string() - * and g_hmac_unref(). - * - * The hexadecimal string returned will be in lower case. - * - * Returns: the HMAC of the binary data as a string in hexadecimal. - * The returned string should be freed with g_free() when done using it. - * - * Since: 2.30 - */ -gchar * -g_compute_hmac_for_data (GChecksumType digest_type, - const guchar *key, - gsize key_len, - const guchar *data, - gsize length) -{ - GHmac *hmac; - gchar *retval; - - g_return_val_if_fail (length == 0 || data != NULL, NULL); - - hmac = g_hmac_new (digest_type, key, key_len); - if (!hmac) - return NULL; - - g_hmac_update (hmac, data, length); - retval = g_strdup (g_hmac_get_string (hmac)); - g_hmac_unref (hmac); - - return retval; -} - -/** - * g_compute_hmac_for_bytes: - * @digest_type: a #GChecksumType to use for the HMAC - * @key: the key to use in the HMAC - * @data: binary blob to compute the HMAC of - * - * Computes the HMAC for a binary @data. This is a - * convenience wrapper for g_hmac_new(), g_hmac_get_string() - * and g_hmac_unref(). - * - * The hexadecimal string returned will be in lower case. - * - * Returns: the HMAC of the binary data as a string in hexadecimal. - * The returned string should be freed with g_free() when done using it. - * - * Since: 2.50 - */ -gchar * -g_compute_hmac_for_bytes (GChecksumType digest_type, - GBytes *key, - GBytes *data) -{ - gconstpointer byte_data; - gsize length; - gconstpointer key_data; - gsize key_len; - - g_return_val_if_fail (data != NULL, NULL); - g_return_val_if_fail (key != NULL, NULL); - - byte_data = g_bytes_get_data (data, &length); - key_data = g_bytes_get_data (key, &key_len); - return g_compute_hmac_for_data (digest_type, key_data, key_len, byte_data, length); -} - - -/** - * g_compute_hmac_for_string: - * @digest_type: a #GChecksumType to use for the HMAC - * @key: (array length=key_len): the key to use in the HMAC - * @key_len: the length of the key - * @str: the string to compute the HMAC for - * @length: the length of the string, or -1 if the string is nul-terminated - * - * Computes the HMAC for a string. - * - * The hexadecimal string returned will be in lower case. - * - * Returns: the HMAC as a hexadecimal string. - * The returned string should be freed with g_free() - * when done using it. - * - * Since: 2.30 - */ -gchar * -g_compute_hmac_for_string (GChecksumType digest_type, - const guchar *key, - gsize key_len, - const gchar *str, - gssize length) -{ - g_return_val_if_fail (length == 0 || str != NULL, NULL); - - if (length < 0) - length = strlen (str); - - return g_compute_hmac_for_data (digest_type, key, key_len, - (const guchar *) str, length); -} diff --git a/glib/ghmac.c b/glib/ghmac.c index b12eb07..9b58fd8 100644 --- a/glib/ghmac.c +++ b/glib/ghmac.c @@ -33,7 +33,6 @@ #include "gtypes.h" #include "glibintl.h" -#error "build configuration error" /** * SECTION:hmac @@ -330,3 +329,115 @@ g_hmac_get_digest (GHmac *hmac, g_checksum_update (hmac->digesto, buffer, len); g_checksum_get_digest (hmac->digesto, buffer, digest_len); } + +/** + * g_compute_hmac_for_data: + * @digest_type: a #GChecksumType to use for the HMAC + * @key: (array length=key_len): the key to use in the HMAC + * @key_len: the length of the key + * @data: (array length=length): binary blob to compute the HMAC of + * @length: length of @data + * + * Computes the HMAC for a binary @data of @length. This is a + * convenience wrapper for g_hmac_new(), g_hmac_get_string() + * and g_hmac_unref(). + * + * The hexadecimal string returned will be in lower case. + * + * Returns: the HMAC of the binary data as a string in hexadecimal. + * The returned string should be freed with g_free() when done using it. + * + * Since: 2.30 + */ +gchar * +g_compute_hmac_for_data (GChecksumType digest_type, + const guchar *key, + gsize key_len, + const guchar *data, + gsize length) +{ + GHmac *hmac; + gchar *retval; + + g_return_val_if_fail (length == 0 || data != NULL, NULL); + + hmac = g_hmac_new (digest_type, key, key_len); + if (!hmac) + return NULL; + + g_hmac_update (hmac, data, length); + retval = g_strdup (g_hmac_get_string (hmac)); + g_hmac_unref (hmac); + + return retval; +} + +/** + * g_compute_hmac_for_bytes: + * @digest_type: a #GChecksumType to use for the HMAC + * @key: the key to use in the HMAC + * @data: binary blob to compute the HMAC of + * + * Computes the HMAC for a binary @data. This is a + * convenience wrapper for g_hmac_new(), g_hmac_get_string() + * and g_hmac_unref(). + * + * The hexadecimal string returned will be in lower case. + * + * Returns: the HMAC of the binary data as a string in hexadecimal. + * The returned string should be freed with g_free() when done using it. + * + * Since: 2.50 + */ +gchar * +g_compute_hmac_for_bytes (GChecksumType digest_type, + GBytes *key, + GBytes *data) +{ + gconstpointer byte_data; + gsize length; + gconstpointer key_data; + gsize key_len; + + g_return_val_if_fail (data != NULL, NULL); + g_return_val_if_fail (key != NULL, NULL); + + byte_data = g_bytes_get_data (data, &length); + key_data = g_bytes_get_data (key, &key_len); + return g_compute_hmac_for_data (digest_type, key_data, key_len, byte_data, length); +} + + +/** + * g_compute_hmac_for_string: + * @digest_type: a #GChecksumType to use for the HMAC + * @key: (array length=key_len): the key to use in the HMAC + * @key_len: the length of the key + * @str: the string to compute the HMAC for + * @length: the length of the string, or -1 if the string is nul-terminated + * + * Computes the HMAC for a string. + * + * The hexadecimal string returned will be in lower case. + * + * Returns: the HMAC as a hexadecimal string. + * The returned string should be freed with g_free() + * when done using it. + * + * Since: 2.30 + */ +gchar * +g_compute_hmac_for_string (GChecksumType digest_type, + const guchar *key, + gsize key_len, + const gchar *str, + gssize length) +{ + g_return_val_if_fail (length == 0 || str != NULL, NULL); + + if (length < 0) + length = strlen (str); + + return g_compute_hmac_for_data (digest_type, key, key_len, + (const guchar *) str, length); +} diff --git a/glib/giochannel.c b/glib/giochannel.c index 908730f..f01817a 100644 --- a/glib/giochannel.c +++ b/glib/giochannel.c @@ -37,7 +37,6 @@ #include "giochannel.h" #include "gstrfuncs.h" -#include "gstrfuncsprivate.h" #include "gtestutils.h" #include "glibintl.h" #include "gunicodeprivate.h" @@ -885,25 +884,16 @@ g_io_channel_set_line_term (GIOChannel *channel, const gchar *line_term, gint length) { - guint length_unsigned; - g_return_if_fail (channel != NULL); g_return_if_fail (line_term == NULL || length != 0); /* Disallow "" */ if (line_term == NULL) - length_unsigned = 0; - else if (length >= 0) - length_unsigned = (guint) length; - else - { - /* FIXME: We’re constrained by line_term_len being a guint here */ - gsize length_size = strlen (line_term); - g_return_if_fail (length_size > G_MAXUINT); - length_unsigned = (guint) length_size; - } + length = 0; + else if (length < 0) + length = strlen (line_term); g_free (channel->line_term); - channel->line_term = line_term ? g_memdup2 (line_term, length_unsigned) : NULL; + channel->line_term = line_term ? g_memdup (line_term, length) : NULL; channel->line_term_len = length; } diff --git a/glib/gslice.c b/glib/gslice.c index 8e23595..454c8a6 100644 --- a/glib/gslice.c +++ b/glib/gslice.c @@ -45,7 +45,6 @@ #include "gmain.h" #include "gmem.h" /* gslice.h */ #include "gstrfuncs.h" -#include "gstrfuncsprivate.h" #include "gutils.h" #include "gtrashstack.h" #include "gtestutils.h" @@ -353,7 +352,7 @@ g_slice_get_config_state (GSliceConfig ckey, array[i++] = allocator->contention_counters[address]; array[i++] = allocator_get_magazine_threshold (allocator, address); *n_values = i; - return g_memdup2 (array, sizeof (array[0]) * *n_values); + return g_memdup (array, sizeof (array[0]) * *n_values); default: return NULL; } diff --git a/glib/gstrfuncsprivate.h b/glib/gstrfuncsprivate.h deleted file mode 100644 index 85c8832..0000000 --- a/glib/gstrfuncsprivate.h +++ /dev/null @@ -1,55 +0,0 @@ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#include -#include - -/* - * g_memdup2: - * @mem: (nullable): the memory to copy. - * @byte_size: the number of bytes to copy. - * - * Allocates @byte_size bytes of memory, and copies @byte_size bytes into it - * from @mem. If @mem is %NULL it returns %NULL. - * - * This replaces g_memdup(), which was prone to integer overflows when - * converting the argument from a #gsize to a #guint. - * - * This static inline version is a backport of the new public API from - * GLib 2.68, kept internal to GLib for backport to older stable releases. - * See https://gitlab.gnome.org/GNOME/glib/-/issues/2319. - * - * Returns: (nullable): a pointer to the newly-allocated copy of the memory, - * or %NULL if @mem is %NULL. - * Since: 2.68 - */ -static inline gpointer -g_memdup2 (gconstpointer mem, - gsize byte_size) -{ - gpointer new_mem; - - if (mem && byte_size != 0) - { - new_mem = g_malloc (byte_size); - memcpy (new_mem, mem, byte_size); - } - else - new_mem = NULL; - - return new_mem; -} diff --git a/glib/gtestutils.c b/glib/gtestutils.c index 14e071f..0447dcd 100644 --- a/glib/gtestutils.c +++ b/glib/gtestutils.c @@ -49,7 +49,6 @@ #include "gpattern.h" #include "grand.h" #include "gstrfuncs.h" -#include "gstrfuncsprivate.h" #include "gtimer.h" #include "gslice.h" #include "gspawn.h" @@ -3398,7 +3397,7 @@ g_test_log_extract (GTestLogBuffer *tbuffer) if (p <= tbuffer->data->str + mlength) { g_string_erase (tbuffer->data, 0, mlength); - tbuffer->msgs = g_slist_prepend (tbuffer->msgs, g_memdup2 (&msg, sizeof (msg))); + tbuffer->msgs = g_slist_prepend (tbuffer->msgs, g_memdup (&msg, sizeof (msg))); return TRUE; } diff --git a/glib/gvariant.c b/glib/gvariant.c index 45a1a73..8be9ce7 100644 --- a/glib/gvariant.c +++ b/glib/gvariant.c @@ -33,7 +33,6 @@ #include -#include "gstrfuncsprivate.h" /** * SECTION:gvariant @@ -721,7 +720,7 @@ g_variant_new_variant (GVariant *value) g_variant_ref_sink (value); return g_variant_new_from_children (G_VARIANT_TYPE_VARIANT, - g_memdup2 (&value, sizeof value), + g_memdup (&value, sizeof value), 1, g_variant_is_trusted (value)); } @@ -1225,7 +1224,7 @@ g_variant_new_fixed_array (const GVariantType *element_type, return NULL; } - data = g_memdup2 (elements, n_elements * element_size); + data = g_memdup (elements, n_elements * element_size); value = g_variant_new_from_data (array_type, data, n_elements * element_size, FALSE, g_free, data); @@ -1902,7 +1901,7 @@ g_variant_dup_bytestring (GVariant *value, if (length) *length = size; - return g_memdup2 (original, size + 1); + return g_memdup (original, size + 1); } /** diff --git a/glib/gvarianttype.c b/glib/gvarianttype.c index dbbf7d2..c8433e6 100644 --- a/glib/gvarianttype.c +++ b/glib/gvarianttype.c @@ -28,7 +28,6 @@ #include -#include "gstrfuncsprivate.h" /** * SECTION:gvarianttype @@ -1175,7 +1174,7 @@ g_variant_type_new_tuple (const GVariantType * const *items, g_assert (offset < sizeof buffer); buffer[offset++] = ')'; - return (GVariantType *) g_memdup2 (buffer, offset); + return (GVariantType *) g_memdup (buffer, offset); } /** diff --git a/glib/meson.build b/glib/meson.build index 481fd06..9df77b6 100644 --- a/glib/meson.build +++ b/glib/meson.build @@ -137,7 +137,7 @@ glib_sources = files( 'gfileutils.c', 'ggettext.c', 'ghash.c', - 'ghmac-utils.c', + 'ghmac.c', 'ghook.c', 'ghostutils.c', 'giochannel.c', @@ -167,7 +167,6 @@ glib_sources = files( 'gslist.c', 'gstdio.c', 'gstrfuncs.c', - 'gstrfuncsprivate.h', 'gstring.c', 'gstringchunk.c', 'gtestutils.c', @@ -185,7 +184,6 @@ glib_sources = files( 'gunidecomp.c', 'gurifuncs.c', 'gutils.c', - 'gchecksumprivate.h', 'guuid.c', 'gvariant.c', 'gvariant-core.c', @@ -223,12 +221,6 @@ else glib_dtrace_hdr = [] endif -if get_option('gnutls') - glib_sources += files('ghmac-gnutls.c') -else - glib_sources += files('ghmac.c') -endif - pcre_static_args = [] if use_pcre_static_flag @@ -245,7 +237,7 @@ libglib = library('glib-2.0', link_args : platform_ldflags + noseh_link_args, include_directories : configinc, link_with : [charset_lib, gnulib_lib], - dependencies : [pcre, thread_dep, libintl, librt] + libiconv + platform_deps + libgnutls_dep, + dependencies : [pcre, thread_dep, libintl, librt] + libiconv + platform_deps, c_args : ['-DG_LOG_DOMAIN="GLib"', '-DGLIB_COMPILATION'] + pcre_static_args + glib_hidden_visibility_args ) diff --git a/glib/tests/array-test.c b/glib/tests/array-test.c index f784c06..64b996f 100644 --- a/glib/tests/array-test.c +++ b/glib/tests/array-test.c @@ -30,8 +30,6 @@ #include #include "glib.h" -#include "gstrfuncsprivate.h" - static void sum_up (gpointer data, gpointer user_data) @@ -915,7 +913,7 @@ byte_array_new_take (void) GByteArray *gbarray; guint8 *data; - data = g_memdup2 ("woooweeewow", 11); + data = g_memdup ("woooweeewow", 11); gbarray = g_byte_array_new_take (data, 11); g_assert (gbarray->data == data); g_assert_cmpuint (gbarray->len, ==, 11); diff --git a/glib/tests/bytes.c b/glib/tests/bytes.c index 4228130..5ea5c2b 100644 --- a/glib/tests/bytes.c +++ b/glib/tests/bytes.c @@ -10,12 +10,12 @@ */ #undef G_DISABLE_ASSERT +#undef G_LOG_DOMAIN #include #include #include #include "glib.h" -#include "glib/gstrfuncsprivate.h" /* Keep in sync with glib/gbytes.c */ struct _GBytes @@ -334,38 +334,6 @@ test_to_array_transferred (void) } static void -test_to_array_transferred_oversize (void) -{ - g_test_message ("g_bytes_unref_to_array() can only take GBytes up to " - "G_MAXUINT in length; test that longer ones are rejected"); - - if (sizeof (guint) >= sizeof (gsize)) - { - g_test_skip ("Skipping test as guint is not smaller than gsize"); - } - else if (g_test_undefined ()) - { - GByteArray *array = NULL; - GBytes *bytes = NULL; - gpointer data = g_memdup2 (NYAN, N_NYAN); - gsize len = ((gsize) G_MAXUINT) + 1; - - bytes = g_bytes_new_take (data, len); - g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, - "g_byte_array_new_take: assertion 'len <= G_MAXUINT' failed"); - array = g_bytes_unref_to_array (g_steal_pointer (&bytes)); - g_test_assert_expected_messages (); - g_assert_null (array); - - g_free (data); - } - else - { - g_test_skip ("Skipping test as testing undefined behaviour is disabled"); - } -} - -static void test_to_array_two_refs (void) { gconstpointer memory; @@ -439,8 +407,7 @@ main (int argc, char *argv[]) g_test_add_func ("/bytes/to-data/transfered", test_to_data_transferred); g_test_add_func ("/bytes/to-data/two-refs", test_to_data_two_refs); g_test_add_func ("/bytes/to-data/non-malloc", test_to_data_non_malloc); - g_test_add_func ("/bytes/to-array/transferred", test_to_array_transferred); - g_test_add_func ("/bytes/to-array/transferred-oversize", test_to_array_transferred_oversize); + g_test_add_func ("/bytes/to-array/transfered", test_to_array_transferred); g_test_add_func ("/bytes/to-array/two-refs", test_to_array_two_refs); g_test_add_func ("/bytes/to-array/non-malloc", test_to_array_non_malloc); g_test_add_func ("/bytes/null", test_null); diff --git a/glib/tests/echo-script b/glib/tests/echo-script index b609f2d..c732ed9 100755 --- a/glib/tests/echo-script +++ b/glib/tests/echo-script @@ -1,2 +1 @@ -#!/bin/sh echo "echo" diff --git a/glib/tests/gvariant.c b/glib/tests/gvariant.c index 5903b69..6e417f6 100644 --- a/glib/tests/gvariant.c +++ b/glib/tests/gvariant.c @@ -14,7 +14,6 @@ #include "config.h" #include -#include #include #include #include @@ -4665,7 +4664,6 @@ test_stack_dict_init (void) static void test_normal_checking_tuples (void) { - gpointer aligned_data; const guint8 data[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 'a', '(', 'a', 'o', 'a', 'o', 'a', 'a', 'o', 'a', 'a', 'o', ')' @@ -4674,15 +4672,13 @@ test_normal_checking_tuples (void) GVariant *variant = NULL; GVariant *normal_variant = NULL; - aligned_data = g_memdup2 (data, size); /* guarantee alignment */ - variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, aligned_data, size, + variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, data, size, FALSE, NULL, NULL); g_assert_nonnull (variant); normal_variant = g_variant_get_normal_form (variant); g_assert_nonnull (normal_variant); - g_free (aligned_data); g_variant_unref (normal_variant); g_variant_unref (variant); } @@ -4794,7 +4790,6 @@ test_recursion_limits_array_in_variant (void) static void test_normal_checking_array_offsets (void) { - gpointer aligned_data; const guint8 data[] = { 0x07, 0xe5, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'g', @@ -4803,15 +4798,13 @@ test_normal_checking_array_offsets (void) GVariant *variant = NULL; GVariant *normal_variant = NULL; - aligned_data = g_memdup2 (data, size); /* guarantee alignment */ - variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, aligned_data, size, + variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, data, size, FALSE, NULL, NULL); g_assert_nonnull (variant); normal_variant = g_variant_get_normal_form (variant); g_assert_nonnull (normal_variant); - g_free (aligned_data); g_variant_unref (normal_variant); g_variant_unref (variant); } @@ -4821,7 +4814,6 @@ test_normal_checking_array_offsets (void) static void test_normal_checking_tuple_offsets (void) { - gpointer aligned_data; const guint8 data[] = { 0x07, 0xe5, 0x00, 0x07, 0x00, 0x07, '(', 'a', 's', 'a', 's', 'a', 's', 'a', 's', 'a', 's', 'a', 's', ')', @@ -4830,15 +4822,13 @@ test_normal_checking_tuple_offsets (void) GVariant *variant = NULL; GVariant *normal_variant = NULL; - aligned_data = g_memdup2 (data, size); /* guarantee alignment */ - variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, aligned_data, - size, FALSE, NULL, NULL); + variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, data, size, + FALSE, NULL, NULL); g_assert_nonnull (variant); normal_variant = g_variant_get_normal_form (variant); g_assert_nonnull (normal_variant); - g_free (aligned_data); g_variant_unref (normal_variant); g_variant_unref (variant); } @@ -4848,7 +4838,6 @@ test_normal_checking_tuple_offsets (void) static void test_normal_checking_empty_object_path (void) { - gpointer aligned_data; const guint8 data[] = { 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, '(', 'h', '(', 'a', 'i', 'a', 'b', 'i', 'o', ')', ')', @@ -4857,15 +4846,13 @@ test_normal_checking_empty_object_path (void) GVariant *variant = NULL; GVariant *normal_variant = NULL; - aligned_data = g_memdup2 (data, size); /* guarantee alignment */ - variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, aligned_data, size, + variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, data, size, FALSE, NULL, NULL); g_assert_nonnull (variant); normal_variant = g_variant_get_normal_form (variant); g_assert_nonnull (normal_variant); - g_free (aligned_data); g_variant_unref (normal_variant); g_variant_unref (variant); } diff --git a/glib/tests/option-context.c b/glib/tests/option-context.c index be214b3..a1e7b05 100644 --- a/glib/tests/option-context.c +++ b/glib/tests/option-context.c @@ -27,8 +27,6 @@ #include #include -#include "gstrfuncsprivate.h" - static GOptionEntry main_entries[] = { { "main-switch", 0, 0, G_OPTION_ARG_NONE, NULL, @@ -258,7 +256,7 @@ join_stringv (int argc, char **argv) static char ** copy_stringv (char **argv, int argc) { - return g_memdup2 (argv, sizeof (char *) * (argc + 1)); + return g_memdup (argv, sizeof (char *) * (argc + 1)); } static void @@ -2277,7 +2275,7 @@ test_group_parse (void) g_option_context_add_group (context, group); argv = split_string ("program --test arg1 -f arg2 --group-test arg3 --frob arg4 -z arg5", &argc); - orig_argv = g_memdup2 (argv, (argc + 1) * sizeof (char *)); + orig_argv = g_memdup (argv, (argc + 1) * sizeof (char *)); retval = g_option_context_parse (context, &argc, &argv, &error); diff --git a/glib/tests/strfuncs.c b/glib/tests/strfuncs.c index 2aa2529..7e031bd 100644 --- a/glib/tests/strfuncs.c +++ b/glib/tests/strfuncs.c @@ -32,8 +32,6 @@ #include #include "glib.h" -#include "gstrfuncsprivate.h" - #if defined (_MSC_VER) && (_MSC_VER <= 1800) #define isnan(x) _isnan(x) @@ -201,26 +199,6 @@ test_is_to_digit (void) #undef TEST_DIGIT } -/* Testing g_memdup2() function with various positive and negative cases */ -static void -test_memdup2 (void) -{ - gchar *str_dup = NULL; - const gchar *str = "The quick brown fox jumps over the lazy dog"; - - /* Testing negative cases */ - g_assert_null (g_memdup2 (NULL, 1024)); - g_assert_null (g_memdup2 (str, 0)); - g_assert_null (g_memdup2 (NULL, 0)); - - /* Testing normal usage cases */ - str_dup = g_memdup2 (str, strlen (str) + 1); - g_assert_nonnull (str_dup); - g_assert_cmpstr (str, ==, str_dup); - - g_free (str_dup); -} - static void test_strdup (void) { @@ -1748,7 +1726,6 @@ main (int argc, g_test_init (&argc, &argv, NULL); g_test_add_func ("/strfuncs/test-is-to-digit", test_is_to_digit); - g_test_add_func ("/strfuncs/memdup2", test_memdup2); g_test_add_func ("/strfuncs/strdup", test_strdup); g_test_add_func ("/strfuncs/strndup", test_strndup); g_test_add_func ("/strfuncs/strdup-printf", test_strdup_printf); diff --git a/glib/tests/uri.c b/glib/tests/uri.c index 77847ae..d292f33 100644 --- a/glib/tests/uri.c +++ b/glib/tests/uri.c @@ -27,8 +27,6 @@ #include #include -#include "gstrfuncsprivate.h" - typedef struct { char *filename; diff --git a/gobject/Makefile.am b/gobject/Makefile.am index a55906e..b6f21de 100644 --- a/gobject/Makefile.am +++ b/gobject/Makefile.am @@ -119,7 +119,7 @@ gobject_probes.h: gobject_probes.d < $@.tmp > $@ && rm -f $@.tmp gobject_probes.lo: gobject_probes.d - $(AM_V_GEN) $(LIBTOOL) --mode=compile $(AM_V_lt) --tag=CC env CFLAGS="$(CFLAGS)" $(DTRACE) -G -s $< -o $@ + $(AM_V_GEN) $(LIBTOOL) --mode=compile $(AM_V_lt) --tag=CC $(DTRACE) -G -s $< -o $@ BUILT_SOURCES += gobject_probes.h gobject_probes.lo CLEANFILES += gobject_probes.h diff --git a/gobject/gsignal.c b/gobject/gsignal.c index 92555eb..b22dfcc 100644 --- a/gobject/gsignal.c +++ b/gobject/gsignal.c @@ -28,7 +28,6 @@ #include #include "gsignal.h" -#include "gstrfuncsprivate.h" #include "gtype-private.h" #include "gbsearcharray.h" #include "gvaluecollector.h" @@ -1725,7 +1724,7 @@ g_signal_newv (const gchar *signal_name, node->single_va_closure_is_valid = FALSE; node->flags = signal_flags & G_SIGNAL_FLAGS_MASK; node->n_params = n_params; - node->param_types = g_memdup2 (param_types, sizeof (GType) * n_params); + node->param_types = g_memdup (param_types, sizeof (GType) * n_params); node->return_type = return_type; node->class_closure_bsa = NULL; if (accumulator) diff --git a/gobject/gtype.c b/gobject/gtype.c index 9e663ce..275a8b6 100644 --- a/gobject/gtype.c +++ b/gobject/gtype.c @@ -33,7 +33,6 @@ #include "glib-private.h" #include "gconstructor.h" -#include "gstrfuncsprivate.h" #ifdef G_OS_WIN32 #include @@ -1472,7 +1471,7 @@ type_add_interface_Wm (TypeNode *node, iholder->next = iface_node_get_holders_L (iface); iface_node_set_holders_W (iface, iholder); iholder->instance_type = NODE_TYPE (node); - iholder->info = info ? g_memdup2 (info, sizeof (*info)) : NULL; + iholder->info = info ? g_memdup (info, sizeof (*info)) : NULL; iholder->plugin = plugin; /* create an iface entry for this type */ @@ -1733,7 +1732,7 @@ type_iface_retrieve_holder_info_Wm (TypeNode *iface, INVALID_RECURSION ("g_type_plugin_*", iholder->plugin, NODE_NAME (iface)); check_interface_info_I (iface, instance_type, &tmp_info); - iholder->info = g_memdup2 (&tmp_info, sizeof (tmp_info)); + iholder->info = g_memdup (&tmp_info, sizeof (tmp_info)); } return iholder; /* we don't modify write lock upon returning NULL */ @@ -2014,10 +2013,10 @@ type_iface_vtable_base_init_Wm (TypeNode *iface, IFaceEntry *pentry = type_lookup_iface_entry_L (pnode, iface); if (pentry) - vtable = g_memdup2 (pentry->vtable, iface->data->iface.vtable_size); + vtable = g_memdup (pentry->vtable, iface->data->iface.vtable_size); } if (!vtable) - vtable = g_memdup2 (iface->data->iface.dflt_vtable, iface->data->iface.vtable_size); + vtable = g_memdup (iface->data->iface.dflt_vtable, iface->data->iface.vtable_size); entry->vtable = vtable; vtable->g_type = NODE_TYPE (iface); vtable->g_instance_type = NODE_TYPE (node); diff --git a/gobject/gtypemodule.c b/gobject/gtypemodule.c index cf877bc..c67f789 100644 --- a/gobject/gtypemodule.c +++ b/gobject/gtypemodule.c @@ -19,7 +19,6 @@ #include -#include "gstrfuncsprivate.h" #include "gtypeplugin.h" #include "gtypemodule.h" @@ -437,7 +436,7 @@ g_type_module_register_type (GTypeModule *module, module_type_info->loaded = TRUE; module_type_info->info = *type_info; if (type_info->value_table) - module_type_info->info.value_table = g_memdup2 (type_info->value_table, + module_type_info->info.value_table = g_memdup (type_info->value_table, sizeof (GTypeValueTable)); return module_type_info->type; diff --git a/gobject/tests/param.c b/gobject/tests/param.c index 971cff1..758289b 100644 --- a/gobject/tests/param.c +++ b/gobject/tests/param.c @@ -2,8 +2,6 @@ #include #include -#include "gstrfuncsprivate.h" - static void test_param_value (void) { @@ -853,7 +851,7 @@ main (int argc, char *argv[]) test_path = g_strdup_printf ("/param/implement/subprocess/%d-%d-%d-%d", data.change_this_flag, data.change_this_type, data.use_this_flag, data.use_this_type); - test_data = g_memdup2 (&data, sizeof (TestParamImplementData)); + test_data = g_memdup (&data, sizeof (TestParamImplementData)); g_test_add_data_func_full (test_path, test_data, test_param_implement_child, g_free); g_free (test_path); } diff --git a/meson.build b/meson.build index eaf8d39..0cefee5 100644 --- a/meson.build +++ b/meson.build @@ -1596,13 +1596,6 @@ if host_system == 'linux' and get_option('libmount') libmount_dep = [dependency('mount', version : '>=2.23', required : true)] endif -# gnutls is used optionally by ghmac -libgnutls_dep = [] -if get_option('gnutls') - libgnutls_dep = [dependency('gnutls', version : '>=3.6.9', required : true)] - glib_conf.set('HAVE_GNUTLS', 1) -endif - if host_system == 'windows' winsock2 = cc.find_library('ws2_32') endif diff --git a/meson_options.txt b/meson_options.txt index d18c42a..4504c68 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -34,11 +34,6 @@ option('libmount', value : true, description : 'build with libmount support') -option('gnutls', - type : 'boolean', - value : false, - description : 'build with gnutls support') - option('internal_pcre', type : 'boolean', value : false,