summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2017-05-26 14:35:34 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2017-05-26 19:27:11 +0000
commit88a1fc92a9937fafd195d70abc80a30be64fc136 (patch)
treea49fb1b62005e6a48e18b0385a6ba03906246dc1
parent9bf8a8503afa5cc7acacc8203490330292da7f85 (diff)
downloadostree-88a1fc92a9937fafd195d70abc80a30be64fc136.tar.gz
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
-rw-r--r--coccinelle/new-error.cocci19
-rw-r--r--src/libostree/ostree-core.c10
-rw-r--r--src/libostree/ostree-gpg-verify-result.c5
-rw-r--r--src/libostree/ostree-repo-libarchive.c5
-rw-r--r--src/libostree/ostree-repo-static-delta-core.c5
-rw-r--r--src/libostree/ostree-repo-static-delta-processing.c4
-rw-r--r--src/libostree/ostree-sysroot-deploy.c6
-rw-r--r--src/libotutil/ot-tool-util.c8
-rw-r--r--src/libotutil/ot-unix-utils.c12
-rw-r--r--src/ostree/ot-builtin-commit.c4
-rw-r--r--src/ostree/ot-builtin-config.c5
11 files changed, 40 insertions, 43 deletions
diff --git a/coccinelle/new-error.cocci b/coccinelle/new-error.cocci
new file mode 100644
index 00000000..147a8e02
--- /dev/null
+++ b/coccinelle/new-error.cocci
@@ -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);
diff --git a/src/libostree/ostree-core.c b/src/libostree/ostree-core.c
index 7d2ed3c6..54e01bcb 100644
--- a/src/libostree/ostree-core.c
+++ b/src/libostree/ostree-core.c
@@ -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;
}
diff --git a/src/libostree/ostree-gpg-verify-result.c b/src/libostree/ostree-gpg-verify-result.c
index cd709b7c..0277ce1e 100644
--- a/src/libostree/ostree-gpg-verify-result.c
+++ b/src/libostree/ostree-gpg-verify-result.c
@@ -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;
diff --git a/src/libostree/ostree-repo-libarchive.c b/src/libostree/ostree-repo-libarchive.c
index 01982894..02f1364e 100644
--- a/src/libostree/ostree-repo-libarchive.c
+++ b/src/libostree/ostree-repo-libarchive.c
@@ -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);
}
}
}
diff --git a/src/libostree/ostree-repo-static-delta-core.c b/src/libostree/ostree-repo-static-delta-core.c
index 3a14f8bb..d83b7f0f 100644
--- a/src/libostree/ostree-repo-static-delta-core.c
+++ b/src/libostree/ostree-repo-static-delta-core.c
@@ -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);
diff --git a/src/libostree/ostree-repo-static-delta-processing.c b/src/libostree/ostree-repo-static-delta-processing.c
index a71e070f..2280dec9 100644
--- a/src/libostree/ostree-repo-static-delta-processing.c
+++ b/src/libostree/ostree-repo-static-delta-processing.c
@@ -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;
diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c
index 2b45e6da..ed4831c1 100644
--- a/src/libostree/ostree-sysroot-deploy.c
+++ b/src/libostree/ostree-sysroot-deploy.c
@@ -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;
diff --git a/src/libotutil/ot-tool-util.c b/src/libotutil/ot-tool-util.c
index 1043f55f..0743c528 100644
--- a/src/libotutil/ot-tool-util.c
+++ b/src/libotutil/ot-tool-util.c
@@ -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);
diff --git a/src/libotutil/ot-unix-utils.c b/src/libotutil/ot-unix-utils.c
index 46dd346e..54547dd9 100644
--- a/src/libotutil/ot-unix-utils.c
+++ b/src/libotutil/ot-unix-utils.c
@@ -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;
}
diff --git a/src/ostree/ot-builtin-commit.c b/src/ostree/ot-builtin-commit.c
index 4b0d8821..c14cbec5 100644
--- a/src/ostree/ot-builtin-commit.c
+++ b/src/ostree/ot-builtin-commit.c
@@ -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);
diff --git a/src/ostree/ot-builtin-config.c b/src/ostree/ot-builtin-config.c
index 0d8f7b77..a9a5f52a 100644
--- a/src/ostree/ot-builtin-config.c
+++ b/src/ostree/ot-builtin-config.c
@@ -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);