mirror of
https://github.com/ostreedev/ostree.git
synced 2024-12-21 13:34:34 +03:00
tree-wide: Add+run spatch to use glnx_throw()
I had to run a sed job to add whitespace after, but otherwise this was easy. Closes: #890 Approved by: jlebon
This commit is contained in:
parent
9bf8a8503a
commit
88a1fc92a9
19
coccinelle/new-error.cocci
Normal file
19
coccinelle/new-error.cocci
Normal file
@ -0,0 +1,19 @@
|
||||
// Conversion for G_IO_ERROR_FAILED that could be glnx_throw()
|
||||
@@
|
||||
expression p;
|
||||
@@
|
||||
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, p);
|
||||
- return FALSE;
|
||||
+ return glnx_throw (error, "%s", p);
|
||||
@@
|
||||
expression p;
|
||||
@@
|
||||
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, p);
|
||||
- return FALSE;
|
||||
+ return glnx_throw (error, p);
|
||||
@@
|
||||
expression p, q;
|
||||
@@
|
||||
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, p, q);
|
||||
- return FALSE;
|
||||
+ return glnx_throw (error, p, q);
|
@ -1763,16 +1763,12 @@ validate_variant (GVariant *variant,
|
||||
{
|
||||
if (!g_variant_is_normal_form (variant))
|
||||
{
|
||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Not normal form");
|
||||
return FALSE;
|
||||
return glnx_throw (error, "%s", "Not normal form");
|
||||
}
|
||||
if (!g_variant_is_of_type (variant, variant_type))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Doesn't match variant type '%s'",
|
||||
(char*)variant_type);
|
||||
return FALSE;
|
||||
return glnx_throw (error, "Doesn't match variant type '%s'",
|
||||
(char *)variant_type);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -665,9 +665,8 @@ ostree_gpg_verify_result_require_valid_signature (OstreeGpgVerifyResult *result,
|
||||
|
||||
if (ostree_gpg_verify_result_count_valid (result) == 0)
|
||||
{
|
||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"GPG signatures found, but none are in trusted keyring");
|
||||
return FALSE;
|
||||
return glnx_throw (error, "%s",
|
||||
"GPG signatures found, but none are in trusted keyring");
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -640,9 +640,8 @@ aic_handle_entry (OstreeRepoArchiveImportContext *ctx,
|
||||
return TRUE;
|
||||
else
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Unsupported file type for path \"%s\"", path);
|
||||
return FALSE;
|
||||
return glnx_throw (error, "Unsupported file type for path \"%s\"",
|
||||
path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,9 +45,8 @@ _ostree_static_delta_parse_checksum_array (GVariant *array,
|
||||
if (G_UNLIKELY(n > (G_MAXUINT32/OSTREE_STATIC_DELTA_OBJTYPE_CSUM_LEN) ||
|
||||
(n_checksums * OSTREE_STATIC_DELTA_OBJTYPE_CSUM_LEN) != n))
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Invalid checksum array length %" G_GSIZE_FORMAT, n);
|
||||
return FALSE;
|
||||
return glnx_throw (error,
|
||||
"Invalid checksum array length %" G_GSIZE_FORMAT, n);
|
||||
}
|
||||
|
||||
*out_checksums_array = (gpointer)g_variant_get_data (array);
|
||||
|
@ -115,9 +115,7 @@ read_varuint64 (StaticDeltaExecutionState *state,
|
||||
gsize bytes_read;
|
||||
if (!_ostree_read_varuint64 (state->opdata, state->oplen, out_value, &bytes_read))
|
||||
{
|
||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Unexpected EOF reading varint");
|
||||
return FALSE;
|
||||
return glnx_throw (error, "%s", "Unexpected EOF reading varint");
|
||||
}
|
||||
state->opdata += bytes_read;
|
||||
state->oplen -= bytes_read;
|
||||
|
@ -1028,9 +1028,9 @@ checksum_from_kernel_src (const char *name,
|
||||
const char *last_dash = strrchr (name, '-');
|
||||
if (!last_dash)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Malformed kernel/initramfs name '%s', missing '-'", name);
|
||||
return FALSE;
|
||||
return glnx_throw (error,
|
||||
"Malformed kernel/initramfs name '%s', missing '-'",
|
||||
name);
|
||||
}
|
||||
*out_checksum = g_strdup (last_dash + 1);
|
||||
return TRUE;
|
||||
|
@ -40,9 +40,7 @@ ot_parse_boolean (const char *value,
|
||||
*out_parsed = FALSE;
|
||||
else
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Invalid boolean argument '%s'", value);
|
||||
return FALSE;
|
||||
return glnx_throw (error, "Invalid boolean argument '%s'", value);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -57,9 +55,7 @@ ot_parse_keyvalue (const char *keyvalue,
|
||||
const char *eq = strchr (keyvalue, '=');
|
||||
if (!eq)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Missing '=' in KEY=VALUE for --set");
|
||||
return FALSE;
|
||||
return glnx_throw (error, "Missing '=' in KEY=VALUE for --set");
|
||||
}
|
||||
*out_key = g_strndup (keyvalue, eq - keyvalue);
|
||||
*out_value = g_strdup (eq + 1);
|
||||
|
@ -41,21 +41,15 @@ ot_util_filename_validate (const char *name,
|
||||
{
|
||||
if (strcmp (name, ".") == 0)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Invalid self-referential filename '.'");
|
||||
return FALSE;
|
||||
return glnx_throw (error, "Invalid self-referential filename '.'");
|
||||
}
|
||||
if (strcmp (name, "..") == 0)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Invalid path uplink filename '..'");
|
||||
return FALSE;
|
||||
return glnx_throw (error, "Invalid path uplink filename '..'");
|
||||
}
|
||||
if (strchr (name, '/') != NULL)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Invalid / in filename %s", name);
|
||||
return FALSE;
|
||||
return glnx_throw (error, "Invalid / in filename %s", name);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -147,9 +147,7 @@ handle_statoverride_line (const char *line,
|
||||
spc = strchr (line, ' ');
|
||||
if (spc == NULL)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Malformed statoverride file (no space found)");
|
||||
return FALSE;
|
||||
return glnx_throw (error, "Malformed statoverride file (no space found)");
|
||||
}
|
||||
|
||||
mode_add = (guint32)(gint32)g_ascii_strtod (line, NULL);
|
||||
|
@ -41,9 +41,8 @@ split_key_string (const char *k,
|
||||
|
||||
if (!dot)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Key must be of the form \"sectionname.keyname\"");
|
||||
return FALSE;
|
||||
return glnx_throw (error,
|
||||
"Key must be of the form \"sectionname.keyname\"");
|
||||
}
|
||||
|
||||
*out_section = g_strndup (k, dot - k);
|
||||
|
Loading…
Reference in New Issue
Block a user