util: Rename variable "major" in virIsDevMapperDevice

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>
This commit is contained in:
Jiri Denemark 2024-10-10 15:14:36 +02:00
parent f07068d61c
commit 0c653fc9a5

View 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;