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 <withnall@endlessm.com>

See: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1544#note_846645
This commit is contained in:
Philip Withnall 2020-06-23 10:49:44 +01:00
parent 4abdd10e48
commit aae98ce774
16 changed files with 52 additions and 53 deletions

View File

@ -1511,7 +1511,7 @@ g_local_file_delete (GFile *file,
{ {
int errsv = errno; 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 is G_IO_ERROR_NOT_FOUND, and it's what nautilus
expects */ expects */
if (errsv == EEXIST) if (errsv == EEXIST)

View File

@ -309,7 +309,7 @@ g_menu_model_real_iterate_item_attributes (GMenuModel *model,
else else
{ {
g_critical ("GMenuModel implementation '%s' doesn't override iterate_item_attributes() " 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)); G_OBJECT_TYPE_NAME (model));
result = NULL; result = NULL;
} }
@ -373,7 +373,7 @@ g_menu_model_real_iterate_item_links (GMenuModel *model,
else else
{ {
g_critical ("GMenuModel implementation '%s' doesn't override iterate_item_links() " 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)); G_OBJECT_TYPE_NAME (model));
result = NULL; result = NULL;
} }

View File

@ -315,7 +315,7 @@ g_get_console_charset (const char **charset)
g_free (emsg); 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) if (raw == NULL)
raw = "UTF-8"; raw = "UTF-8";

View File

@ -1,6 +1,6 @@
/* /*
If G_HAS_CONSTRUCTORS is true then the compiler support *both* constructors and 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. your own.
Some compilers need #pragma to handle this, which does not work with macros, Some compilers need #pragma to handle this, which does not work with macros,

View File

@ -83,8 +83,8 @@
* *
* #GDate is simple to use. First you need a "blank" date; you can get a * #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 * dynamically allocated date from g_date_new(), or you can declare an
* automatic variable or array and initialize it to a sane state by * automatic variable or array and initialize it by
* calling g_date_clear(). A cleared date is sane; it's safe to call * 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 * g_date_set_dmy() and the other mutator functions to initialize the
* value of a cleared date. However, a cleared date is initially * value of a cleared date. However, a cleared date is initially
* invalid, meaning that it doesn't represent a day that exists. * 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 * 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 * 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, * becomes valid after you set it to a Julian day or you set a day, month,
* and year. * and year.
*/ */
@ -259,7 +259,7 @@
* g_date_new: * g_date_new:
* *
* Allocates a #GDate and initializes * 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 * 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(). * 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 * @date: pointer to one or more dates to clear
* @n_dates: number of 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 * state. The cleared dates will not represent an existing date, but will
* not contain garbage. Useful to init a date declared on the stack. * not contain garbage. Useful to init a date declared on the stack.
* Validity can be tested with g_date_valid(). * Validity can be tested with g_date_valid().
@ -2055,7 +2055,7 @@ g_date_compare (const GDate *lhs,
* @tm: (not nullable): struct tm to fill * @tm: (not nullable): struct tm to fill
* *
* Fills in the date-related bits of a struct tm using the @date value. * 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 void
g_date_to_struct_tm (const GDate *d, g_date_to_struct_tm (const GDate *d,

View File

@ -178,7 +178,7 @@ GLIB_AVAILABLE_IN_ALL
guint g_date_get_iso8601_week_of_year (const GDate *date); 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 /* 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. * once with the ndates argument.
*/ */
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL

View File

@ -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 * time zone @tz. The time is as accurate as the system allows, to a
* maximum accuracy of 1 microsecond. * maximum accuracy of 1 microsecond.
* *
* This function will always succeed unless the system clock is set to * This function will always succeed unless GLib is still being used after the
* truly insane values (or unless GLib is still being used after the * year 9999.
* year 9999).
* *
* You should release the return value by calling g_date_time_unref() * You should release the return value by calling g_date_time_unref()
* when you are done with it. * when you are done with it.

View File

@ -1126,7 +1126,7 @@ set_cloexec (void *data, gint fd)
} }
static gint static gint
sane_close (gint fd) safe_close (gint fd)
{ {
gint ret; gint ret;
@ -1141,7 +1141,7 @@ G_GNUC_UNUSED static int
close_func (void *data, int fd) close_func (void *data, int fd)
{ {
if (fd >= GPOINTER_TO_INT (data)) if (fd >= GPOINTER_TO_INT (data))
(void) sane_close (fd); (void) safe_close (fd);
return 0; 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; return res;
} }
@ -1290,7 +1290,7 @@ safe_closefrom (int lowfd)
} }
static gint static gint
sane_dup2 (gint fd1, gint fd2) safe_dup2 (gint fd1, gint fd2)
{ {
gint ret; gint ret;
@ -1302,7 +1302,7 @@ sane_dup2 (gint fd1, gint fd2)
} }
static gint static gint
sane_open (const char *path, gint mode) safe_open (const char *path, gint mode)
{ {
gint ret; gint ret;
@ -1349,7 +1349,7 @@ do_exec (gint child_err_report_fd,
{ {
/* dup2 can't actually fail here I don't think */ /* 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, write_err_and_exit (child_err_report_fd,
CHILD_DUP2_FAILED); CHILD_DUP2_FAILED);
@ -1358,9 +1358,9 @@ do_exec (gint child_err_report_fd,
else if (!child_inherits_stdin) else if (!child_inherits_stdin)
{ {
/* Keep process from blocking on a read of 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); g_assert (read_null != -1);
sane_dup2 (read_null, 0); safe_dup2 (read_null, 0);
close_and_invalidate (&read_null); 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 */ /* 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, write_err_and_exit (child_err_report_fd,
CHILD_DUP2_FAILED); CHILD_DUP2_FAILED);
@ -1376,9 +1376,9 @@ do_exec (gint child_err_report_fd,
} }
else if (stdout_to_null) 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); g_assert (write_null != -1);
sane_dup2 (write_null, 1); safe_dup2 (write_null, 1);
close_and_invalidate (&write_null); 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 */ /* 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, write_err_and_exit (child_err_report_fd,
CHILD_DUP2_FAILED); CHILD_DUP2_FAILED);
@ -1394,8 +1394,8 @@ do_exec (gint child_err_report_fd,
} }
else if (stderr_to_null) else if (stderr_to_null)
{ {
gint write_null = sane_open ("/dev/null", O_WRONLY); gint write_null = safe_open ("/dev/null", O_WRONLY);
sane_dup2 (write_null, 2); safe_dup2 (write_null, 2);
close_and_invalidate (&write_null); close_and_invalidate (&write_null);
} }
@ -1408,7 +1408,7 @@ do_exec (gint child_err_report_fd,
{ {
if (child_setup == NULL) 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); set_cloexec (GINT_TO_POINTER (0), 3);
safe_closefrom (4); safe_closefrom (4);
child_err_report_fd = 3; child_err_report_fd = 3;
@ -1565,7 +1565,7 @@ do_posix_spawn (gchar **argv,
else if (!child_inherits_stdin) else if (!child_inherits_stdin)
{ {
/* Keep process from blocking on a read of 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); g_assert (read_null != -1);
parent_close_fds[num_parent_close_fds++] = read_null; parent_close_fds[num_parent_close_fds++] = read_null;
@ -1589,7 +1589,7 @@ do_posix_spawn (gchar **argv,
} }
else if (stdout_to_null) 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); g_assert (write_null != -1);
parent_close_fds[num_parent_close_fds++] = write_null; parent_close_fds[num_parent_close_fds++] = write_null;
@ -1613,7 +1613,7 @@ do_posix_spawn (gchar **argv,
} }
else if (stderr_to_null) 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); g_assert (write_null != -1);
parent_close_fds[num_parent_close_fds++] = write_null; parent_close_fds[num_parent_close_fds++] = write_null;

View File

@ -3067,7 +3067,7 @@ test_trap_clear (void)
#ifdef G_OS_UNIX #ifdef G_OS_UNIX
static int static int
sane_dup2 (int fd1, safe_dup2 (int fd1,
int fd2) int fd2)
{ {
int ret; int ret;
@ -3319,7 +3319,7 @@ g_test_trap_fork (guint64 usec_timeout,
if (fd0 < 0) if (fd0 < 0)
g_error ("failed to open /dev/null for stdin redirection"); 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; errsv = errno;
g_error ("failed to dup2() in forked test program: %s", g_strerror (errsv)); g_error ("failed to dup2() in forked test program: %s", g_strerror (errsv));

View File

@ -3102,7 +3102,7 @@ g_abort (void)
{ {
/* One call to break the debugger */ /* One call to break the debugger */
DebugBreak (); DebugBreak ();
/* One call in case CRT does get saner about abort() behaviour */ /* One call in case CRT changes its abort() behaviour */
abort (); abort ();
/* And one call to bind them all and terminate the program for sure */ /* And one call to bind them all and terminate the program for sure */
ExitProcess (127); ExitProcess (127);

View File

@ -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 /* the "slow" version is needed in case the static buffer of 1024
* bytes is exceeded when running the normal version. this will * 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; GString *string;
gint i; gint i;

View File

@ -2321,7 +2321,7 @@ main (int argc, char *argv[])
TEST_NEW_FAIL ("(*:0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEFG)XX", 0, G_REGEX_ERROR_NAME_TOO_LONG); 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); 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_EXPRESSION_TOO_LARGE
* G_REGEX_ERROR_MEMORY_ERROR * G_REGEX_ERROR_MEMORY_ERROR
* G_REGEX_ERROR_SUBPATTERN_NAME_TOO_LONG * G_REGEX_ERROR_SUBPATTERN_NAME_TOO_LONG

View File

@ -166,7 +166,7 @@ test_spawn_async (void)
* Routine if the file descriptor does not exist. * Routine if the file descriptor does not exist.
*/ */
static void static void
sane_close (int fd) safe_close (int fd)
{ {
if (fd >= 0) if (fd >= 0)
close (fd); close (fd);
@ -252,10 +252,10 @@ test_spawn_async_with_fds (void)
test_pipe[0][0], test_pipe[1][1], test_pipe[2][1], test_pipe[0][0], test_pipe[1][1], test_pipe[2][1],
&error); &error);
g_assert_no_error (error); g_assert_no_error (error);
sane_close (test_pipe[0][0]); safe_close (test_pipe[0][0]);
sane_close (test_pipe[1][1]); safe_close (test_pipe[1][1]);
if (fd_info[2] != STDOUT_PIPE) if (fd_info[2] != STDOUT_PIPE)
sane_close (test_pipe[2][1]); safe_close (test_pipe[2][1]);
data.loop = loop; data.loop = loop;
data.stdout_done = FALSE; data.stdout_done = FALSE;
@ -297,10 +297,10 @@ test_spawn_async_with_fds (void)
g_main_context_unref (context); g_main_context_unref (context);
g_main_loop_unref (loop); g_main_loop_unref (loop);
sane_close (test_pipe[0][1]); safe_close (test_pipe[0][1]);
sane_close (test_pipe[1][0]); safe_close (test_pipe[1][0]);
if (fd_info[2] != STDOUT_PIPE) if (fd_info[2] != STDOUT_PIPE)
sane_close (test_pipe[2][0]); safe_close (test_pipe[2][0]);
} }
g_ptr_array_free (argv, TRUE); g_ptr_array_free (argv, TRUE);

View File

@ -1617,7 +1617,7 @@ object_interface_check_properties (gpointer check_data,
/* We do a number of checks on the properties of an interface to /* We do a number of checks on the properties of an interface to
* make sure that all classes implementing the interface are * 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 * We do the checks in order of importance so that we can give
* more useful error messages first. * more useful error messages first.

View File

@ -2291,7 +2291,7 @@ g_signal_chain_from_overridden_handler (gpointer instance,
g_free (error); g_free (error);
/* we purposely leak the value here, it might not be /* 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--) while (i--)
g_value_unset (param_values + i); g_value_unset (param_values + i);
@ -2347,7 +2347,7 @@ g_signal_chain_from_overridden_handler (gpointer instance,
g_free (error); g_free (error);
/* we purposely leak the value here, it might not be /* 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
*/ */
} }
} }
@ -3446,7 +3446,7 @@ g_signal_emit_valist (gpointer instance,
g_warning ("%s: %s", G_STRLOC, error); g_warning ("%s: %s", G_STRLOC, error);
g_free (error); g_free (error);
/* we purposely leak the value here, it might not be /* 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
*/ */
} }
} }
@ -3483,7 +3483,7 @@ g_signal_emit_valist (gpointer instance,
g_free (error); g_free (error);
/* we purposely leak the value here, it might not be /* 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--) while (i--)
g_value_unset (param_values + i); g_value_unset (param_values + i);
@ -3519,7 +3519,7 @@ g_signal_emit_valist (gpointer instance,
g_free (error); g_free (error);
/* we purposely leak the value here, it might not be /* 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
*/ */
} }
} }

View File

@ -376,7 +376,7 @@ g_value_set_instance (GValue *value,
g_free (error_msg); g_free (error_msg);
/* we purposely leak the value here, it might not be /* 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_meminit (value, g_type);
value_table->value_init (value); value_table->value_init (value);
@ -440,7 +440,7 @@ g_value_init_from_instance (GValue *value,
g_free (error_msg); g_free (error_msg);
/* we purposely leak the value here, it might not be /* 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_meminit (value, g_type);
value_table->value_init (value); value_table->value_init (value);