gchecksum: Drop preconditions for checksum_type being valid

Instead, return `NULL` if the checksum type is unsupported. This may
come in useful if we have to withdraw support for a particular checksum
type in future, due to it being broken.

These semantics were already in place for the return value of
`g_checksum_new()` — see commit 877cc60f and bug
comment https://bugzilla.gnome.org/show_bug.cgi?id=501853#c6.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2020-12-12 18:28:45 +00:00
parent 3fef049472
commit 0755ff97be

View File

@ -1790,7 +1790,6 @@ g_compute_checksum_for_data (GChecksumType checksum_type,
GChecksum *checksum;
gchar *retval;
g_return_val_if_fail (IS_VALID_TYPE (checksum_type), NULL);
g_return_val_if_fail (length == 0 || data != NULL, NULL);
checksum = g_checksum_new (checksum_type);
@ -1825,7 +1824,6 @@ g_compute_checksum_for_string (GChecksumType checksum_type,
const gchar *str,
gssize length)
{
g_return_val_if_fail (IS_VALID_TYPE (checksum_type), NULL);
g_return_val_if_fail (length == 0 || str != NULL, NULL);
if (length < 0)
@ -1859,7 +1857,6 @@ g_compute_checksum_for_bytes (GChecksumType checksum_type,
gconstpointer byte_data;
gsize length;
g_return_val_if_fail (IS_VALID_TYPE (checksum_type), NULL);
g_return_val_if_fail (data != NULL, NULL);
byte_data = g_bytes_get_data (data, &length);