]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: Drop pointless NUL_TERMINATE macro
authorJiri Denemark <jdenemar@redhat.com>
Thu, 30 Sep 2021 19:02:54 +0000 (21:02 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Tue, 26 Oct 2021 08:03:36 +0000 (10:03 +0200)
It's only used once and open coding it is at least as clear as using the
macro.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/internal.h
src/util/virutil.c

index e1250a59fe7d4b660929cfe50332acfe5e5bf346..d3809bf057aa1c1bec66616c326d5c7d57cc712f 100644 (file)
@@ -91,8 +91,6 @@
 #define STREQ_NULLABLE(a, b) (g_strcmp0(a, b) == 0)
 #define STRNEQ_NULLABLE(a, b) (g_strcmp0(a, b) != 0)
 
-#define NUL_TERMINATE(buf) do { (buf)[sizeof(buf)-1] = '\0'; } while (0)
-
 #ifdef WIN32
 # ifndef O_CLOEXEC
 #  define O_CLOEXEC _O_NOINHERIT
index c9de043c4058c1f224a635e74e0139215d881e39..e04f1343d84f3cdf850a64428e5e08f0ea6cddd7 100644 (file)
@@ -485,7 +485,7 @@ virGetHostnameImpl(bool quiet)
                                  "%s", _("failed to determine host name"));
         return NULL;
     }
-    NUL_TERMINATE(hostname);
+    hostname[sizeof(hostname) - 1] = '\0';
 
     if (STRPREFIX(hostname, "localhost") || strchr(hostname, '.')) {
         /* in this case, gethostname returned localhost (meaning we can't