1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

cleanup: cast minor to dev_t

Let the arithmetic run with a single dev_t type (Coverity).
This commit is contained in:
Zdenek Kabelac 2015-05-07 11:03:48 +02:00
parent b8dfd7a53d
commit 5232fd13f3
5 changed files with 10 additions and 10 deletions

View File

@ -433,7 +433,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, (minor - residue)); *result = MKDEV((dev_t)major, (dev_t)(minor - residue));
ret = 2; ret = 2;
} else { } else {
*result = dev->dev; *result = dev->dev;
@ -510,7 +510,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, minor); *result = MKDEV((dev_t)major, (dev_t)minor);
ret = 2; ret = 2;
out: out:
if (fp && fclose(fp)) if (fp && fclose(fp))

View File

@ -245,7 +245,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, minor)) { if (major && buf.st_rdev != MKDEV((dev_t)major, (dev_t)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),
@ -288,7 +288,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, minor)) < 0) { MKDEV((dev_t)major, (dev_t)minor)) < 0) {
log_sys_error("mknod", control); log_sys_error("mknod", control);
(void) dm_prepare_selinux_context(NULL, 0); (void) dm_prepare_selinux_context(NULL, 0);
return 0; return 0;
@ -1142,7 +1142,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, dmt->minor); dmi->dev = MKDEV((dev_t)dmt->major, (dev_t)dmt->minor);
} }
/* Does driver support device number referencing? */ /* Does driver support device number referencing? */

View File

@ -959,7 +959,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, minor); dev_t dev = MKDEV((dev_t)major, (dev_t)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

@ -511,7 +511,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, info->minor); dev = MKDEV((dev_t)info->major, (dev_t)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)) {
@ -535,7 +535,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, minor); dev_t dev = MKDEV((dev_t)major, (dev_t)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

@ -262,7 +262,7 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
ret = ECMD_FAILED; ret = ECMD_FAILED;
continue; continue;
} }
devno = MKDEV((dev_t)major, minor); devno = MKDEV((dev_t)major, (dev_t)minor);
if (!(dev = dev_cache_get_by_devt(devno, cmd->lvmetad_filter))) { if (!(dev = dev_cache_get_by_devt(devno, cmd->lvmetad_filter))) {
if (!(_clear_dev_from_lvmetad_cache(devno, major, minor, handler))) { if (!(_clear_dev_from_lvmetad_cache(devno, major, minor, handler))) {
stack; stack;
@ -295,7 +295,7 @@ static int _pvscan_lvmetad(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, minor); devno = MKDEV((dev_t)major, (dev_t)minor);
if (!(dev = dev_cache_get_by_devt(devno, cmd->lvmetad_filter))) { if (!(dev = dev_cache_get_by_devt(devno, cmd->lvmetad_filter))) {
if (!(_clear_dev_from_lvmetad_cache(devno, major, minor, handler))) { if (!(_clear_dev_from_lvmetad_cache(devno, major, minor, handler))) {