* [PATCH 0/2] Strict aliasing
@ 2010-10-20 14:28 Zdenek Kabelac
2010-10-20 14:28 ` [PATCH 1/2] Fix compiler warning about strict-aliasing break Zdenek Kabelac
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Zdenek Kabelac @ 2010-10-20 14:28 UTC (permalink / raw)
To: lvm-devel
Patch goes with test that executes partition scanning code path
(so improves our coverage a bit)
Looks like are command line --config options has some room
for improvements as I had to change the global config.
Zdenek Kabelac (2):
Fix compiler warning about strict-aliasing break
Testcase for partition table scanning
lib/device/device.c | 18 +++++++++---------
test/t-test-partition.sh | 30 ++++++++++++++++++++++++++++++
test/test-utils.sh | 1 +
3 files changed, 40 insertions(+), 9 deletions(-)
create mode 100755 test/t-test-partition.sh
--
1.7.3.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] Fix compiler warning about strict-aliasing break
2010-10-20 14:28 [PATCH 0/2] Strict aliasing Zdenek Kabelac
@ 2010-10-20 14:28 ` Zdenek Kabelac
2010-10-20 14:28 ` [PATCH 2/2] Testcase for partition table scanning Zdenek Kabelac
2010-10-20 15:01 ` [PATCH 0/2] Strict aliasing Petr Rockai
2 siblings, 0 replies; 4+ messages in thread
From: Zdenek Kabelac @ 2010-10-20 14:28 UTC (permalink / raw)
To: lvm-devel
This patch not really tested - and just show a possible solution
for strict-alliasing error.
So patch is just a proposal of one of many solution.
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
lib/device/device.c | 18 +++++++++---------
1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/lib/device/device.c b/lib/device/device.c
index 593e642..91eb14c 100644
--- a/lib/device/device.c
+++ b/lib/device/device.c
@@ -58,9 +58,11 @@ static int _has_partition_table(struct device *dev)
{
int ret = 0;
unsigned p;
- uint16_t buf[SECTOR_SIZE/sizeof(uint16_t)];
- uint16_t *part_magic;
- struct partition *part;
+ struct {
+ uint8_t skip[PART_OFFSET];
+ struct partition part[4];
+ uint16_t magic;
+ } __attribute__((packed)) buf; /* sizeof() == SECTOR_SIZE */
if (!dev_read(dev, UINT64_C(0), sizeof(buf), &buf))
return_0;
@@ -68,17 +70,15 @@ static int _has_partition_table(struct device *dev)
/* FIXME Check for other types of partition table too */
/* Check for msdos partition table */
- part_magic = buf + PART_MAGIC_OFFSET/sizeof(buf[0]);
- if ((*part_magic == xlate16(PART_MAGIC))) {
- part = (struct partition *) (buf + PART_OFFSET/sizeof(buf[0]));
- for (p = 0; p < 4; p++, part++) {
+ if (buf.magic == xlate16(PART_MAGIC)) {
+ for (p = 0; p < 4; ++p) {
/* Table is invalid if boot indicator not 0 or 0x80 */
- if ((part->boot_ind & 0x7f)) {
+ if (buf.part[p].boot_ind & 0x7f) {
ret = 0;
break;
}
/* Must have at least one non-empty partition */
- if (part->nr_sects)
+ if (buf.part[p].nr_sects)
ret = 1;
}
}
--
1.7.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] Testcase for partition table scanning
2010-10-20 14:28 [PATCH 0/2] Strict aliasing Zdenek Kabelac
2010-10-20 14:28 ` [PATCH 1/2] Fix compiler warning about strict-aliasing break Zdenek Kabelac
@ 2010-10-20 14:28 ` Zdenek Kabelac
2010-10-20 15:01 ` [PATCH 0/2] Strict aliasing Petr Rockai
2 siblings, 0 replies; 4+ messages in thread
From: Zdenek Kabelac @ 2010-10-20 14:28 UTC (permalink / raw)
To: lvm-devel
Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
test/t-test-partition.sh | 30 ++++++++++++++++++++++++++++++
test/test-utils.sh | 1 +
2 files changed, 31 insertions(+), 0 deletions(-)
create mode 100755 test/t-test-partition.sh
diff --git a/test/t-test-partition.sh b/test/t-test-partition.sh
new file mode 100755
index 0000000..45a0aba
--- /dev/null
+++ b/test/t-test-partition.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+# Copyright (C) 2010 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+#
+# Testcase for bugzilla #621173
+# excercises partition table scanning code path
+#
+
+which sfdisk || exit 200
+
+LVM_TEST_CONFIG_DEVICES="types = [\"device-mapper\", 142]"
+
+. ./test-utils.sh
+
+aux prepare_pvs 1 30
+
+pvs
+
+# create small partition table
+echo "1 2" | sfdisk $dev1
+
+pvs
diff --git a/test/test-utils.sh b/test/test-utils.sh
index cc13fa2..c1de6ca 100644
--- a/test/test-utils.sh
+++ b/test/test-utils.sh
@@ -371,6 +371,7 @@ prepare_lvmconf() {
cache_dir = "$TESTDIR/etc"
sysfs_scan = 0
default_data_alignment = 1
+ $LVM_TEST_CONFIG_DEVICES
}
log {
syslog = 0
--
1.7.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 0/2] Strict aliasing
2010-10-20 14:28 [PATCH 0/2] Strict aliasing Zdenek Kabelac
2010-10-20 14:28 ` [PATCH 1/2] Fix compiler warning about strict-aliasing break Zdenek Kabelac
2010-10-20 14:28 ` [PATCH 2/2] Testcase for partition table scanning Zdenek Kabelac
@ 2010-10-20 15:01 ` Petr Rockai
2 siblings, 0 replies; 4+ messages in thread
From: Petr Rockai @ 2010-10-20 15:01 UTC (permalink / raw)
To: lvm-devel
Zdenek Kabelac <zkabelac@redhat.com> writes:
> Zdenek Kabelac (2):
> Fix compiler warning about strict-aliasing break
> Testcase for partition table scanning
Reviewed-by: Petr Rockai <prockai@redhat.com>
Please check in.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-10-20 15:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-20 14:28 [PATCH 0/2] Strict aliasing Zdenek Kabelac
2010-10-20 14:28 ` [PATCH 1/2] Fix compiler warning about strict-aliasing break Zdenek Kabelac
2010-10-20 14:28 ` [PATCH 2/2] Testcase for partition table scanning Zdenek Kabelac
2010-10-20 15:01 ` [PATCH 0/2] Strict aliasing Petr Rockai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.