From a63efa429108c4a34fe6ede684c6fd8a76b2e78f Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 23 Jun 2020 10:49:44 +0100 Subject: [PATCH] tree: Fix various ableist language In almost all cases, rewording the documentation/comments made things more specific and a little clearer. Signed-off-by: Philip Withnall See: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1544#note_846645 --- gio/glocalfile.c | 2 +- gio/gmenumodel.c | 4 ++-- glib/gcharset.c | 2 +- glib/gconstructor.h | 2 +- glib/gdate.c | 12 +++++------ glib/gdate.h | 2 +- glib/gdatetime.c | 5 ++--- glib/gspawn.c | 36 ++++++++++++++++----------------- glib/gtestutils.c | 4 ++-- glib/gutils.c | 2 +- glib/gvarianttype.c | 2 +- glib/tests/regex.c | 2 +- glib/tests/spawn-singlethread.c | 14 ++++++------- gobject/gobject.c | 2 +- gobject/gsignal.c | 10 ++++----- gobject/gvalue.c | 4 ++-- 16 files changed, 52 insertions(+), 53 deletions(-) diff --git a/gio/glocalfile.c b/gio/glocalfile.c index 4bb9948d8..a92c7b28b 100644 --- a/gio/glocalfile.c +++ b/gio/glocalfile.c @@ -1518,7 +1518,7 @@ g_local_file_delete (GFile *file, { int errsv = errno; - /* Posix allows EEXIST too, but the more sane error + /* Posix allows EEXIST too, but the clearer error is G_IO_ERROR_NOT_FOUND, and it's what nautilus expects */ if (errsv == EEXIST) diff --git a/gio/gmenumodel.c b/gio/gmenumodel.c index 49a416c35..9d7b76615 100644 --- a/gio/gmenumodel.c +++ b/gio/gmenumodel.c @@ -309,7 +309,7 @@ g_menu_model_real_iterate_item_attributes (GMenuModel *model, else { g_critical ("GMenuModel implementation '%s' doesn't override iterate_item_attributes() " - "and fails to return sane values from get_item_attributes()", + "and fails to return valid values from get_item_attributes()", G_OBJECT_TYPE_NAME (model)); result = NULL; } @@ -373,7 +373,7 @@ g_menu_model_real_iterate_item_links (GMenuModel *model, else { g_critical ("GMenuModel implementation '%s' doesn't override iterate_item_links() " - "and fails to return sane values from get_item_links()", + "and fails to return valid values from get_item_links()", G_OBJECT_TYPE_NAME (model)); result = NULL; } diff --git a/glib/gcharset.c b/glib/gcharset.c index 9db56f732..bb775bda4 100644 --- a/glib/gcharset.c +++ b/glib/gcharset.c @@ -315,7 +315,7 @@ g_get_console_charset (const char **charset) g_free (emsg); } } - /* fall-back to UTF-8 if the rest failed (it's a sane and universal default) */ + /* fall-back to UTF-8 if the rest failed (it's a universal default) */ if (raw == NULL) raw = "UTF-8"; diff --git a/glib/gconstructor.h b/glib/gconstructor.h index 603c2dde6..9509e595f 100644 --- a/glib/gconstructor.h +++ b/glib/gconstructor.h @@ -1,6 +1,6 @@ /* If G_HAS_CONSTRUCTORS is true then the compiler support *both* constructors and - destructors, in a sane way, including e.g. on library unload. If not you're on + destructors, in a usable way, including e.g. on library unload. If not you're on your own. Some compilers need #pragma to handle this, which does not work with macros, diff --git a/glib/gdate.c b/glib/gdate.c index 9782a8899..c896c224e 100644 --- a/glib/gdate.c +++ b/glib/gdate.c @@ -83,8 +83,8 @@ * * #GDate is simple to use. First you need a "blank" date; you can get a * dynamically allocated date from g_date_new(), or you can declare an - * automatic variable or array and initialize it to a sane state by - * calling g_date_clear(). A cleared date is sane; it's safe to call + * automatic variable or array and initialize it by + * calling g_date_clear(). A cleared date is safe; it's safe to call * g_date_set_dmy() and the other mutator functions to initialize the * value of a cleared date. However, a cleared date is initially * invalid, meaning that it doesn't represent a day that exists. @@ -146,7 +146,7 @@ * * If it's declared on the stack, it will contain garbage so must be * initialized with g_date_clear(). g_date_clear() makes the date invalid - * but sane. An invalid date doesn't represent a day, it's "empty." A date + * but safe. An invalid date doesn't represent a day, it's "empty." A date * becomes valid after you set it to a Julian day or you set a day, month, * and year. */ @@ -259,7 +259,7 @@ * g_date_new: * * Allocates a #GDate and initializes - * it to a sane state. The new date will + * it to a safe state. The new date will * be cleared (as if you'd called g_date_clear()) but invalid (it won't * represent an existing day). Free the return value with g_date_free(). * @@ -862,7 +862,7 @@ g_date_days_between (const GDate *d1, * @date: pointer to one or more dates to clear * @n_dates: number of dates to clear * - * Initializes one or more #GDate structs to a sane but invalid + * Initializes one or more #GDate structs to a safe but invalid * state. The cleared dates will not represent an existing date, but will * not contain garbage. Useful to init a date declared on the stack. * Validity can be tested with g_date_valid(). @@ -2056,7 +2056,7 @@ g_date_compare (const GDate *lhs, * @tm: (not nullable): struct tm to fill * * Fills in the date-related bits of a struct tm using the @date value. - * Initializes the non-date parts with something sane but meaningless. + * Initializes the non-date parts with something safe but meaningless. */ void g_date_to_struct_tm (const GDate *d, diff --git a/glib/gdate.h b/glib/gdate.h index 3bc07bf5c..65fe811fa 100644 --- a/glib/gdate.h +++ b/glib/gdate.h @@ -178,7 +178,7 @@ GLIB_AVAILABLE_IN_ALL guint g_date_get_iso8601_week_of_year (const GDate *date); /* If you create a static date struct you need to clear it to get it - * in a sane state before use. You can clear a whole array at + * in a safe state before use. You can clear a whole array at * once with the ndates argument. */ GLIB_AVAILABLE_IN_ALL diff --git a/glib/gdatetime.c b/glib/gdatetime.c index a72ad8a45..66132838f 100644 --- a/glib/gdatetime.c +++ b/glib/gdatetime.c @@ -935,9 +935,8 @@ g_date_time_new_from_unix (GTimeZone *tz, * time zone @tz. The time is as accurate as the system allows, to a * maximum accuracy of 1 microsecond. * - * This function will always succeed unless the system clock is set to - * truly insane values (or unless GLib is still being used after the - * year 9999). + * This function will always succeed unless GLib is still being used after the + * year 9999. * * You should release the return value by calling g_date_time_unref() * when you are done with it. diff --git a/glib/gspawn.c b/glib/gspawn.c index 6832ae0b9..2ad0db2af 100644 --- a/glib/gspawn.c +++ b/glib/gspawn.c @@ -1126,7 +1126,7 @@ set_cloexec (void *data, gint fd) } static gint -sane_close (gint fd) +safe_close (gint fd) { gint ret; @@ -1141,7 +1141,7 @@ G_GNUC_UNUSED static int close_func (void *data, int fd) { if (fd >= GPOINTER_TO_INT (data)) - (void) sane_close (fd); + (void) safe_close (fd); return 0; } @@ -1232,7 +1232,7 @@ safe_fdwalk (int (*cb)(void *data, int fd), void *data) } } - sane_close (dir_fd); + safe_close (dir_fd); return res; } @@ -1290,7 +1290,7 @@ safe_closefrom (int lowfd) } static gint -sane_dup2 (gint fd1, gint fd2) +safe_dup2 (gint fd1, gint fd2) { gint ret; @@ -1302,7 +1302,7 @@ sane_dup2 (gint fd1, gint fd2) } static gint -sane_open (const char *path, gint mode) +safe_open (const char *path, gint mode) { gint ret; @@ -1349,7 +1349,7 @@ do_exec (gint child_err_report_fd, { /* dup2 can't actually fail here I don't think */ - if (sane_dup2 (stdin_fd, 0) < 0) + if (safe_dup2 (stdin_fd, 0) < 0) write_err_and_exit (child_err_report_fd, CHILD_DUP2_FAILED); @@ -1358,9 +1358,9 @@ do_exec (gint child_err_report_fd, else if (!child_inherits_stdin) { /* Keep process from blocking on a read of stdin */ - gint read_null = sane_open ("/dev/null", O_RDONLY); + gint read_null = safe_open ("/dev/null", O_RDONLY); g_assert (read_null != -1); - sane_dup2 (read_null, 0); + safe_dup2 (read_null, 0); close_and_invalidate (&read_null); } @@ -1368,7 +1368,7 @@ do_exec (gint child_err_report_fd, { /* dup2 can't actually fail here I don't think */ - if (sane_dup2 (stdout_fd, 1) < 0) + if (safe_dup2 (stdout_fd, 1) < 0) write_err_and_exit (child_err_report_fd, CHILD_DUP2_FAILED); @@ -1376,9 +1376,9 @@ do_exec (gint child_err_report_fd, } else if (stdout_to_null) { - gint write_null = sane_open ("/dev/null", O_WRONLY); + gint write_null = safe_open ("/dev/null", O_WRONLY); g_assert (write_null != -1); - sane_dup2 (write_null, 1); + safe_dup2 (write_null, 1); close_and_invalidate (&write_null); } @@ -1386,7 +1386,7 @@ do_exec (gint child_err_report_fd, { /* dup2 can't actually fail here I don't think */ - if (sane_dup2 (stderr_fd, 2) < 0) + if (safe_dup2 (stderr_fd, 2) < 0) write_err_and_exit (child_err_report_fd, CHILD_DUP2_FAILED); @@ -1394,8 +1394,8 @@ do_exec (gint child_err_report_fd, } else if (stderr_to_null) { - gint write_null = sane_open ("/dev/null", O_WRONLY); - sane_dup2 (write_null, 2); + gint write_null = safe_open ("/dev/null", O_WRONLY); + safe_dup2 (write_null, 2); close_and_invalidate (&write_null); } @@ -1408,7 +1408,7 @@ do_exec (gint child_err_report_fd, { if (child_setup == NULL) { - sane_dup2 (child_err_report_fd, 3); + safe_dup2 (child_err_report_fd, 3); set_cloexec (GINT_TO_POINTER (0), 3); safe_closefrom (4); child_err_report_fd = 3; @@ -1565,7 +1565,7 @@ do_posix_spawn (gchar **argv, else if (!child_inherits_stdin) { /* Keep process from blocking on a read of stdin */ - gint read_null = sane_open ("/dev/null", O_RDONLY | O_CLOEXEC); + gint read_null = safe_open ("/dev/null", O_RDONLY | O_CLOEXEC); g_assert (read_null != -1); parent_close_fds[num_parent_close_fds++] = read_null; @@ -1589,7 +1589,7 @@ do_posix_spawn (gchar **argv, } else if (stdout_to_null) { - gint write_null = sane_open ("/dev/null", O_WRONLY | O_CLOEXEC); + gint write_null = safe_open ("/dev/null", O_WRONLY | O_CLOEXEC); g_assert (write_null != -1); parent_close_fds[num_parent_close_fds++] = write_null; @@ -1613,7 +1613,7 @@ do_posix_spawn (gchar **argv, } else if (stderr_to_null) { - gint write_null = sane_open ("/dev/null", O_WRONLY | O_CLOEXEC); + gint write_null = safe_open ("/dev/null", O_WRONLY | O_CLOEXEC); g_assert (write_null != -1); parent_close_fds[num_parent_close_fds++] = write_null; diff --git a/glib/gtestutils.c b/glib/gtestutils.c index e054cb7b7..785579681 100644 --- a/glib/gtestutils.c +++ b/glib/gtestutils.c @@ -3083,7 +3083,7 @@ test_trap_clear (void) #ifdef G_OS_UNIX static int -sane_dup2 (int fd1, +safe_dup2 (int fd1, int fd2) { int ret; @@ -3335,7 +3335,7 @@ g_test_trap_fork (guint64 usec_timeout, if (fd0 < 0) g_error ("failed to open /dev/null for stdin redirection"); } - if (sane_dup2 (stdout_pipe[1], 1) < 0 || sane_dup2 (stderr_pipe[1], 2) < 0 || (fd0 >= 0 && sane_dup2 (fd0, 0) < 0)) + if (safe_dup2 (stdout_pipe[1], 1) < 0 || safe_dup2 (stderr_pipe[1], 2) < 0 || (fd0 >= 0 && safe_dup2 (fd0, 0) < 0)) { errsv = errno; g_error ("failed to dup2() in forked test program: %s", g_strerror (errsv)); diff --git a/glib/gutils.c b/glib/gutils.c index 572c06ce6..c5aef47fa 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -3102,7 +3102,7 @@ g_abort (void) { /* One call to break the debugger */ DebugBreak (); - /* One call in case CRT does get saner about abort() behaviour */ + /* One call in case CRT changes its abort() behaviour */ abort (); /* And one call to bind them all and terminate the program for sure */ ExitProcess (127); diff --git a/glib/gvarianttype.c b/glib/gvarianttype.c index 1a228f73b..c46f1a2c6 100644 --- a/glib/gvarianttype.c +++ b/glib/gvarianttype.c @@ -1120,7 +1120,7 @@ g_variant_type_new_tuple_slow (const GVariantType * const *items, { /* the "slow" version is needed in case the static buffer of 1024 * bytes is exceeded when running the normal version. this will - * happen only in truly insane code, so it can be slow. + * happen only with very unusually large types, so it can be slow. */ GString *string; gint i; diff --git a/glib/tests/regex.c b/glib/tests/regex.c index 56bd2d5eb..ee9cd21ca 100644 --- a/glib/tests/regex.c +++ b/glib/tests/regex.c @@ -2321,7 +2321,7 @@ main (int argc, char *argv[]) TEST_NEW_FAIL ("(*:0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEFG)XX", 0, G_REGEX_ERROR_NAME_TOO_LONG); TEST_NEW_FAIL ("\\u0100", G_REGEX_RAW | G_REGEX_JAVASCRIPT_COMPAT, G_REGEX_ERROR_CHARACTER_VALUE_TOO_LARGE); - /* These errors can't really be tested sanely: + /* These errors can't really be tested easily: * G_REGEX_ERROR_EXPRESSION_TOO_LARGE * G_REGEX_ERROR_MEMORY_ERROR * G_REGEX_ERROR_SUBPATTERN_NAME_TOO_LONG diff --git a/glib/tests/spawn-singlethread.c b/glib/tests/spawn-singlethread.c index 15f03a0c7..ab449eb95 100644 --- a/glib/tests/spawn-singlethread.c +++ b/glib/tests/spawn-singlethread.c @@ -166,7 +166,7 @@ test_spawn_async (void) * Routine if the file descriptor does not exist. */ static void -sane_close (int fd) +safe_close (int fd) { if (fd >= 0) close (fd); @@ -252,10 +252,10 @@ test_spawn_async_with_fds (void) test_pipe[0][0], test_pipe[1][1], test_pipe[2][1], &error); g_assert_no_error (error); - sane_close (test_pipe[0][0]); - sane_close (test_pipe[1][1]); + safe_close (test_pipe[0][0]); + safe_close (test_pipe[1][1]); if (fd_info[2] != STDOUT_PIPE) - sane_close (test_pipe[2][1]); + safe_close (test_pipe[2][1]); data.loop = loop; data.stdout_done = FALSE; @@ -297,10 +297,10 @@ test_spawn_async_with_fds (void) g_main_context_unref (context); g_main_loop_unref (loop); - sane_close (test_pipe[0][1]); - sane_close (test_pipe[1][0]); + safe_close (test_pipe[0][1]); + safe_close (test_pipe[1][0]); if (fd_info[2] != STDOUT_PIPE) - sane_close (test_pipe[2][0]); + safe_close (test_pipe[2][0]); } g_ptr_array_free (argv, TRUE); diff --git a/gobject/gobject.c b/gobject/gobject.c index ef9552354..a9a4350c2 100644 --- a/gobject/gobject.c +++ b/gobject/gobject.c @@ -1617,7 +1617,7 @@ object_interface_check_properties (gpointer check_data, /* We do a number of checks on the properties of an interface to * make sure that all classes implementing the interface are - * overriding the properties in a sane way. + * overriding the properties correctly. * * We do the checks in order of importance so that we can give * more useful error messages first. diff --git a/gobject/gsignal.c b/gobject/gsignal.c index 12c725a11..ebf5b3c1c 100644 --- a/gobject/gsignal.c +++ b/gobject/gsignal.c @@ -2287,7 +2287,7 @@ g_signal_chain_from_overridden_handler (gpointer instance, g_free (error); /* we purposely leak the value here, it might not be - * in a sane state if an error condition occurred + * in a correct state if an error condition occurred */ while (i--) g_value_unset (param_values + i); @@ -2343,7 +2343,7 @@ g_signal_chain_from_overridden_handler (gpointer instance, g_free (error); /* we purposely leak the value here, it might not be - * in a sane state if an error condition occurred + * in a correct state if an error condition occurred */ } } @@ -3442,7 +3442,7 @@ g_signal_emit_valist (gpointer instance, g_warning ("%s: %s", G_STRLOC, error); g_free (error); /* we purposely leak the value here, it might not be - * in a sane state if an error condition occurred + * in a correct state if an error condition occurred */ } } @@ -3479,7 +3479,7 @@ g_signal_emit_valist (gpointer instance, g_free (error); /* we purposely leak the value here, it might not be - * in a sane state if an error condition occurred + * in a correct state if an error condition occurred */ while (i--) g_value_unset (param_values + i); @@ -3515,7 +3515,7 @@ g_signal_emit_valist (gpointer instance, g_free (error); /* we purposely leak the value here, it might not be - * in a sane state if an error condition occurred + * in a correct state if an error condition occurred */ } } diff --git a/gobject/gvalue.c b/gobject/gvalue.c index c30501a6b..468da2e7d 100644 --- a/gobject/gvalue.c +++ b/gobject/gvalue.c @@ -376,7 +376,7 @@ g_value_set_instance (GValue *value, g_free (error_msg); /* we purposely leak the value here, it might not be - * in a sane state if an error condition occurred + * in a correct state if an error condition occurred */ value_meminit (value, g_type); value_table->value_init (value); @@ -440,7 +440,7 @@ g_value_init_from_instance (GValue *value, g_free (error_msg); /* we purposely leak the value here, it might not be - * in a sane state if an error condition occurred + * in a correct state if an error condition occurred */ value_meminit (value, g_type); value_table->value_init (value);