]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: Rename variable "major" in virIsDevMapperDevice
authorJiri Denemark <jdenemar@redhat.com>
Thu, 10 Oct 2024 13:14:36 +0000 (15:14 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Mon, 14 Oct 2024 09:48:50 +0000 (11:48 +0200)
major() is a macro defined in sys/sysmacros.h so luckily the code works,
but it's very confusing. Let's rename the local variable to make the
difference between it and the macro more obvious. And while touching the
line we can also initialize it to make sure "clever" analyzers do not
think it may be used uninitialized.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
src/util/virdevmapper.c

index 70ce0f0c23e37d9317f11f16c56051d771f7c03c..d0eae671abc85780e966bc209a257fcde6cb8497 100644 (file)
@@ -321,14 +321,14 @@ bool
 virIsDevMapperDevice(const char *dev_name)
 {
     struct stat buf;
-    unsigned int major;
+    unsigned int maj = 0;
 
-    if (virDevMapperGetMajor(&major) < 0)
+    if (virDevMapperGetMajor(&maj) < 0)
         return false;
 
     if (!stat(dev_name, &buf) &&
         S_ISBLK(buf.st_mode) &&
-        major(buf.st_rdev) == major)
+        major(buf.st_rdev) == maj)
         return true;
 
     return false;