From 5c5acddf010a31e8638e0346aba6e57000e59b6f Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 17 Oct 2011 14:15:26 +0000 Subject: [PATCH] Add _thin_validate_device_id --- libdm/libdm-deptree.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c index 701681c38..1099f9960 100644 --- a/libdm/libdm-deptree.c +++ b/libdm/libdm-deptree.c @@ -2687,6 +2687,17 @@ int dm_tree_node_add_replicator_dev_target(struct dm_tree_node *node, return 1; } +static int _thin_validate_device_id(uint32_t device_id) +{ + if (device_id > DM_THIN_MAX_DEVICE_ID) { + log_error("Device id %u is higher then %u.", + device_id, DM_THIN_MAX_DEVICE_ID); + return 0; + } + + return 1; +} + int dm_tree_node_add_thin_pool_target(struct dm_tree_node *node, uint64_t size, uint64_t transaction_id, @@ -2744,11 +2755,8 @@ int dm_tree_node_add_thin_target(struct dm_tree_node *node, { struct load_segment *seg; - if (device_id > DM_THIN_MAX_DEVICE_ID) { - log_error("Device id %u is higher then %u.", - device_id, DM_THIN_MAX_DEVICE_ID); - return 0; - } + if (!_thin_validate_device_id(device_id)) + return_0; if (!(seg = _add_segment(node, SEG_THIN, size))) return_0; -- 2.43.5