|
|
65aaff |
From f408b24d8d8f5b5f4e1a25c1046c3a18107c8d80 Mon Sep 17 00:00:00 2001
|
|
|
65aaff |
From: Laszlo Ersek <lersek@redhat.com>
|
|
|
65aaff |
Date: Wed, 4 May 2022 15:41:54 +0200
|
|
|
65aaff |
Subject: [PATCH] lib: rename VALID_FORMAT_IFACE to VALID_FORMAT
|
|
|
65aaff |
|
|
|
65aaff |
We no longer use VALID_FORMAT_IFACE for validating "iface"; rename the
|
|
|
65aaff |
macro to reflect that we only check "format" with it.
|
|
|
65aaff |
|
|
|
65aaff |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1844341
|
|
|
65aaff |
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
65aaff |
Message-Id: <20220504134155.11832-4-lersek@redhat.com>
|
|
|
65aaff |
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
|
|
|
65aaff |
(cherry picked from commit c8e3caf9e6000ea2f5cfbe30ffe1240317bb4578)
|
|
|
65aaff |
---
|
|
|
65aaff |
lib/drives.c | 4 ++--
|
|
|
65aaff |
lib/unit-tests.c | 16 ++++++++--------
|
|
|
65aaff |
2 files changed, 10 insertions(+), 10 deletions(-)
|
|
|
65aaff |
|
|
|
65aaff |
diff --git a/lib/drives.c b/lib/drives.c
|
|
|
65aaff |
index 8fe46a41c..c5a208468 100644
|
|
|
65aaff |
--- a/lib/drives.c
|
|
|
65aaff |
+++ b/lib/drives.c
|
|
|
65aaff |
@@ -593,7 +593,7 @@ guestfs_int_free_drives (guestfs_h *g)
|
|
|
65aaff |
* Check string parameter matches regular expression
|
|
|
65aaff |
* C<^[-_[:alnum:]]+$> (in C locale).
|
|
|
65aaff |
*/
|
|
|
65aaff |
-#define VALID_FORMAT_IFACE(str) \
|
|
|
65aaff |
+#define VALID_FORMAT(str) \
|
|
|
65aaff |
guestfs_int_string_is_valid ((str), 1, 0, \
|
|
|
65aaff |
VALID_FLAG_ALPHA|VALID_FLAG_DIGIT, "-_")
|
|
|
65aaff |
|
|
|
65aaff |
@@ -790,7 +790,7 @@ guestfs_impl_add_drive_opts (guestfs_h *g, const char *filename,
|
|
|
65aaff |
return -1;
|
|
|
65aaff |
}
|
|
|
65aaff |
|
|
|
65aaff |
- if (data.format && !VALID_FORMAT_IFACE (data.format)) {
|
|
|
65aaff |
+ if (data.format && !VALID_FORMAT (data.format)) {
|
|
|
65aaff |
error (g, _("%s parameter is empty or contains disallowed characters"),
|
|
|
65aaff |
"format");
|
|
|
65aaff |
free_drive_servers (data.servers, data.nr_servers);
|
|
|
65aaff |
diff --git a/lib/unit-tests.c b/lib/unit-tests.c
|
|
|
65aaff |
index 62457ccba..0e550cb98 100644
|
|
|
65aaff |
--- a/lib/unit-tests.c
|
|
|
65aaff |
+++ b/lib/unit-tests.c
|
|
|
65aaff |
@@ -434,7 +434,7 @@ test_stringsbuf (void)
|
|
|
65aaff |
}
|
|
|
65aaff |
|
|
|
65aaff |
/* Use the same macros as in lib/drives.c */
|
|
|
65aaff |
-#define VALID_FORMAT_IFACE(str) \
|
|
|
65aaff |
+#define VALID_FORMAT(str) \
|
|
|
65aaff |
guestfs_int_string_is_valid ((str), 1, 0, \
|
|
|
65aaff |
VALID_FLAG_ALPHA|VALID_FLAG_DIGIT, "-_")
|
|
|
65aaff |
#define VALID_DISK_LABEL(str) \
|
|
|
65aaff |
@@ -446,18 +446,18 @@ test_stringsbuf (void)
|
|
|
65aaff |
static void
|
|
|
65aaff |
test_valid (void)
|
|
|
65aaff |
{
|
|
|
65aaff |
- assert (!VALID_FORMAT_IFACE (""));
|
|
|
65aaff |
+ assert (!VALID_FORMAT (""));
|
|
|
65aaff |
assert (!VALID_DISK_LABEL (""));
|
|
|
65aaff |
assert (!VALID_HOSTNAME (""));
|
|
|
65aaff |
|
|
|
65aaff |
assert (!VALID_DISK_LABEL ("012345678901234567890"));
|
|
|
65aaff |
|
|
|
65aaff |
- assert (VALID_FORMAT_IFACE ("abc"));
|
|
|
65aaff |
- assert (VALID_FORMAT_IFACE ("ABC"));
|
|
|
65aaff |
- assert (VALID_FORMAT_IFACE ("abc123"));
|
|
|
65aaff |
- assert (VALID_FORMAT_IFACE ("abc123-"));
|
|
|
65aaff |
- assert (VALID_FORMAT_IFACE ("abc123_"));
|
|
|
65aaff |
- assert (!VALID_FORMAT_IFACE ("abc123."));
|
|
|
65aaff |
+ assert (VALID_FORMAT ("abc"));
|
|
|
65aaff |
+ assert (VALID_FORMAT ("ABC"));
|
|
|
65aaff |
+ assert (VALID_FORMAT ("abc123"));
|
|
|
65aaff |
+ assert (VALID_FORMAT ("abc123-"));
|
|
|
65aaff |
+ assert (VALID_FORMAT ("abc123_"));
|
|
|
65aaff |
+ assert (!VALID_FORMAT ("abc123."));
|
|
|
65aaff |
|
|
|
65aaff |
assert (VALID_DISK_LABEL ("abc"));
|
|
|
65aaff |
assert (VALID_DISK_LABEL ("ABC"));
|
|
|
65aaff |
--
|
|
|
65aaff |
2.31.1
|
|
|
65aaff |
|