1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-30 17:18:21 +03:00

cleanup: move cast to det_t into MKDEV macro

This commit is contained in:
Zdenek Kabelac 2018-11-03 17:13:10 +01:00
parent d3ebb18f40
commit aa8b2d6a0f
12 changed files with 23 additions and 23 deletions

View File

@ -32,7 +32,7 @@
#else #else
# define MAJOR(x) major((x)) # define MAJOR(x) major((x))
# define MINOR(x) minor((x)) # define MINOR(x) minor((x))
# define MKDEV(x,y) makedev((x),(y)) # define MKDEV(x,y) makedev(((dev_t)x),((dev_t)y))
#endif #endif
#include "device_mapper/misc/dm-ioctl.h" #include "device_mapper/misc/dm-ioctl.h"
@ -261,7 +261,7 @@ static int _control_exists(const char *control, uint32_t major, uint32_t minor)
return -1; return -1;
} }
if (major && buf.st_rdev != MKDEV((dev_t)major, (dev_t)minor)) { if (major && buf.st_rdev != MKDEV(major, minor)) {
log_verbose("%s: Wrong device number: (%u, %u) instead of " log_verbose("%s: Wrong device number: (%u, %u) instead of "
"(%u, %u)", control, "(%u, %u)", control,
MAJOR(buf.st_mode), MINOR(buf.st_mode), MAJOR(buf.st_mode), MINOR(buf.st_mode),
@ -304,7 +304,7 @@ static int _create_control(const char *control, uint32_t major, uint32_t minor)
(void) dm_prepare_selinux_context(control, S_IFCHR); (void) dm_prepare_selinux_context(control, S_IFCHR);
old_umask = umask(DM_CONTROL_NODE_UMASK); old_umask = umask(DM_CONTROL_NODE_UMASK);
if (mknod(control, S_IFCHR | S_IRUSR | S_IWUSR, if (mknod(control, S_IFCHR | S_IRUSR | S_IWUSR,
MKDEV((dev_t)major, (dev_t)minor)) < 0) { MKDEV(major, minor)) < 0) {
log_sys_error("mknod", control); log_sys_error("mknod", control);
ret = 0; ret = 0;
} }
@ -1182,7 +1182,7 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
} }
dmi->flags |= DM_PERSISTENT_DEV_FLAG; dmi->flags |= DM_PERSISTENT_DEV_FLAG;
dmi->dev = MKDEV((dev_t)dmt->major, (dev_t)dmt->minor); dmi->dev = MKDEV(dmt->major, dmt->minor);
} }
/* Does driver support device number referencing? */ /* Does driver support device number referencing? */

View File

@ -1042,7 +1042,7 @@ static int _add_dev_node(const char *dev_name, uint32_t major, uint32_t minor,
{ {
char path[PATH_MAX]; char path[PATH_MAX];
struct stat info; struct stat info;
dev_t dev = MKDEV((dev_t)major, (dev_t)minor); dev_t dev = MKDEV(major, minor);
mode_t old_mask; mode_t old_mask;
if (!_build_dev_path(path, sizeof(path), dev_name)) if (!_build_dev_path(path, sizeof(path), dev_name))

View File

@ -531,7 +531,7 @@ static struct dm_tree_node *_create_dm_tree_node(struct dm_tree *dtree,
dm_list_init(&node->activated); dm_list_init(&node->activated);
dm_list_init(&node->props.segs); dm_list_init(&node->props.segs);
dev = MKDEV((dev_t)info->major, (dev_t)info->minor); dev = MKDEV(info->major, info->minor);
if (!dm_hash_insert_binary(dtree->devs, (const char *) &dev, if (!dm_hash_insert_binary(dtree->devs, (const char *) &dev,
sizeof(dev), node)) { sizeof(dev), node)) {
@ -554,7 +554,7 @@ static struct dm_tree_node *_create_dm_tree_node(struct dm_tree *dtree,
static struct dm_tree_node *_find_dm_tree_node(struct dm_tree *dtree, static struct dm_tree_node *_find_dm_tree_node(struct dm_tree *dtree,
uint32_t major, uint32_t minor) uint32_t major, uint32_t minor)
{ {
dev_t dev = MKDEV((dev_t)major, (dev_t)minor); dev_t dev = MKDEV(major, minor);
return dm_hash_lookup_binary(dtree->devs, (const char *) &dev, return dm_hash_lookup_binary(dtree->devs, (const char *) &dev,
sizeof(dev)); sizeof(dev));

View File

@ -17,6 +17,6 @@
#define MAJOR(dev) ((dev & 0xfff00) >> 8) #define MAJOR(dev) ((dev & 0xfff00) >> 8)
#define MINOR(dev) ((dev & 0xff) | ((dev >> 12) & 0xfff00)) #define MINOR(dev) ((dev & 0xff) | ((dev >> 12) & 0xfff00))
#define MKDEV(ma,mi) ((mi & 0xff) | (ma << 8) | ((mi & ~0xff) << 12)) #define MKDEV(ma,mi) (((dev_t)mi & 0xff) | ((dev_t)ma << 8) | (((dev_t)mi & ~0xff) << 12))
#endif #endif

View File

@ -374,7 +374,7 @@ static int _ignore_blocked_mirror_devices(struct device *dev,
if (!(tmp_dev = dev_create_file(buf, NULL, NULL, 0))) if (!(tmp_dev = dev_create_file(buf, NULL, NULL, 0)))
goto_out; goto_out;
tmp_dev->dev = MKDEV((dev_t)sm->logs[0].major, (dev_t)sm->logs[0].minor); tmp_dev->dev = MKDEV(sm->logs[0].major, sm->logs[0].minor);
if (device_is_usable(tmp_dev, (struct dev_usable_check_params) if (device_is_usable(tmp_dev, (struct dev_usable_check_params)
{ .check_empty = 1, { .check_empty = 1,
.check_blocked = 1, .check_blocked = 1,

View File

@ -479,7 +479,7 @@ static struct device *_get_device_for_sysfs_dev_name_using_devno(const char *dev
return NULL; return NULL;
} }
devno = MKDEV((dev_t)major, (dev_t)minor); devno = MKDEV(major, minor);
if (!(dev = (struct device *) btree_lookup(_cache.devices, (uint32_t) devno))) { if (!(dev = (struct device *) btree_lookup(_cache.devices, (uint32_t) devno))) {
/* /*
* If we get here, it means the device is referenced in sysfs, but it's not yet in /dev. * If we get here, it means the device is referenced in sysfs, but it's not yet in /dev.
@ -947,7 +947,7 @@ static int _dev_cache_iterate_sysfs_for_index(const char *path)
continue; continue;
} }
devno = MKDEV((dev_t)major, (dev_t)minor); devno = MKDEV(major, minor);
if (!(dev = (struct device *) btree_lookup(_cache.devices, (uint32_t) devno)) && if (!(dev = (struct device *) btree_lookup(_cache.devices, (uint32_t) devno)) &&
!(dev = (struct device *) btree_lookup(_cache.sysfs_only_devices, (uint32_t) devno))) { !(dev = (struct device *) btree_lookup(_cache.sysfs_only_devices, (uint32_t) devno))) {
if (!dm_device_get_name(major, minor, 1, devname, sizeof(devname)) || if (!dm_device_get_name(major, minor, 1, devname, sizeof(devname)) ||

View File

@ -506,7 +506,7 @@ int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
*/ */
if ((parts = dt->dev_type_array[major].max_partitions) > 1) { if ((parts = dt->dev_type_array[major].max_partitions) > 1) {
if ((residue = minor % parts)) { if ((residue = minor % parts)) {
*result = MKDEV((dev_t)major, (dev_t)(minor - residue)); *result = MKDEV(major, (minor - residue));
ret = 2; ret = 2;
} else { } else {
*result = dev->dev; *result = dev->dev;
@ -576,7 +576,7 @@ int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
path, buffer); path, buffer);
goto out; goto out;
} }
*result = MKDEV((dev_t)major, (dev_t)minor); *result = MKDEV(major, minor);
ret = 2; ret = 2;
out: out:
if (fp && fclose(fp)) if (fp && fclose(fp))

View File

@ -30,7 +30,7 @@
#else #else
# define MAJOR(x) major((x)) # define MAJOR(x) major((x))
# define MINOR(x) minor((x)) # define MINOR(x) minor((x))
# define MKDEV(x,y) makedev((x),(y)) # define MKDEV(x,y) makedev(((dev_t)x),((dev_t)y))
#endif #endif
#include "libdm/misc/dm-ioctl.h" #include "libdm/misc/dm-ioctl.h"
@ -259,7 +259,7 @@ static int _control_exists(const char *control, uint32_t major, uint32_t minor)
return -1; return -1;
} }
if (major && buf.st_rdev != MKDEV((dev_t)major, (dev_t)minor)) { if (major && buf.st_rdev != MKDEV(major, minor)) {
log_verbose("%s: Wrong device number: (%u, %u) instead of " log_verbose("%s: Wrong device number: (%u, %u) instead of "
"(%u, %u)", control, "(%u, %u)", control,
MAJOR(buf.st_mode), MINOR(buf.st_mode), MAJOR(buf.st_mode), MINOR(buf.st_mode),
@ -302,7 +302,7 @@ static int _create_control(const char *control, uint32_t major, uint32_t minor)
(void) dm_prepare_selinux_context(control, S_IFCHR); (void) dm_prepare_selinux_context(control, S_IFCHR);
old_umask = umask(DM_CONTROL_NODE_UMASK); old_umask = umask(DM_CONTROL_NODE_UMASK);
if (mknod(control, S_IFCHR | S_IRUSR | S_IWUSR, if (mknod(control, S_IFCHR | S_IRUSR | S_IWUSR,
MKDEV((dev_t)major, (dev_t)minor)) < 0) { MKDEV(major, minor)) < 0) {
log_sys_error("mknod", control); log_sys_error("mknod", control);
ret = 0; ret = 0;
} }
@ -1194,7 +1194,7 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
} }
dmi->flags |= DM_PERSISTENT_DEV_FLAG; dmi->flags |= DM_PERSISTENT_DEV_FLAG;
dmi->dev = MKDEV((dev_t)dmt->major, (dev_t)dmt->minor); dmi->dev = MKDEV(dmt->major, dmt->minor);
} }
/* Does driver support device number referencing? */ /* Does driver support device number referencing? */

View File

@ -1040,7 +1040,7 @@ static int _add_dev_node(const char *dev_name, uint32_t major, uint32_t minor,
{ {
char path[PATH_MAX]; char path[PATH_MAX];
struct stat info; struct stat info;
dev_t dev = MKDEV((dev_t)major, (dev_t)minor); dev_t dev = MKDEV(major, minor);
mode_t old_mask; mode_t old_mask;
if (!_build_dev_path(path, sizeof(path), dev_name)) if (!_build_dev_path(path, sizeof(path), dev_name))

View File

@ -523,7 +523,7 @@ static struct dm_tree_node *_create_dm_tree_node(struct dm_tree *dtree,
dm_list_init(&node->activated); dm_list_init(&node->activated);
dm_list_init(&node->props.segs); dm_list_init(&node->props.segs);
dev = MKDEV((dev_t)info->major, (dev_t)info->minor); dev = MKDEV(info->major, info->minor);
if (!dm_hash_insert_binary(dtree->devs, (const char *) &dev, if (!dm_hash_insert_binary(dtree->devs, (const char *) &dev,
sizeof(dev), node)) { sizeof(dev), node)) {
@ -546,7 +546,7 @@ static struct dm_tree_node *_create_dm_tree_node(struct dm_tree *dtree,
static struct dm_tree_node *_find_dm_tree_node(struct dm_tree *dtree, static struct dm_tree_node *_find_dm_tree_node(struct dm_tree *dtree,
uint32_t major, uint32_t minor) uint32_t major, uint32_t minor)
{ {
dev_t dev = MKDEV((dev_t)major, (dev_t)minor); dev_t dev = MKDEV(major, minor);
return dm_hash_lookup_binary(dtree->devs, (const char *) &dev, return dm_hash_lookup_binary(dtree->devs, (const char *) &dev,
sizeof(dev)); sizeof(dev));

View File

@ -17,6 +17,6 @@
#define MAJOR(dev) ((dev & 0xfff00) >> 8) #define MAJOR(dev) ((dev & 0xfff00) >> 8)
#define MINOR(dev) ((dev & 0xff) | ((dev >> 12) & 0xfff00)) #define MINOR(dev) ((dev & 0xff) | ((dev >> 12) & 0xfff00))
#define MKDEV(ma,mi) ((mi & 0xff) | (ma << 8) | ((mi & ~0xff) << 12)) #define MKDEV(ma,mi) (((dev_t)mi & 0xff) | ((dev_t)ma << 8) | (((dev_t)mi & ~0xff) << 12))
#endif #endif

View File

@ -692,7 +692,7 @@ int pvscan_cache_cmd(struct cmd_context *cmd, int argc, char **argv)
log_warn("WARNING: Failed to parse major:minor from %s, skipping.", pv_name); log_warn("WARNING: Failed to parse major:minor from %s, skipping.", pv_name);
continue; continue;
} }
devno = MKDEV((dev_t)major, (dev_t)minor); devno = MKDEV(major, minor);
if (!(dev = dev_cache_get_by_devt(cmd, devno, cmd->lvmetad_filter))) { if (!(dev = dev_cache_get_by_devt(cmd, devno, cmd->lvmetad_filter))) {
log_debug("pvscan arg %d:%d not found.", major, minor); log_debug("pvscan arg %d:%d not found.", major, minor);
@ -748,7 +748,7 @@ int pvscan_cache_cmd(struct cmd_context *cmd, int argc, char **argv)
if (major < 0 || minor < 0) if (major < 0 || minor < 0)
continue; continue;
devno = MKDEV((dev_t)major, (dev_t)minor); devno = MKDEV(major, minor);
if (!(dev = dev_cache_get_by_devt(cmd, devno, cmd->lvmetad_filter))) { if (!(dev = dev_cache_get_by_devt(cmd, devno, cmd->lvmetad_filter))) {
log_debug("pvscan arg %d:%d not found.", major, minor); log_debug("pvscan arg %d:%d not found.", major, minor);