[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 06/13] fdc: Throw an assertion on misconfigured fd_fo
From: |
John Snow |
Subject: |
[Qemu-devel] [PULL 06/13] fdc: Throw an assertion on misconfigured fd_formats table |
Date: |
Mon, 25 Jan 2016 14:41:18 -0500 |
pick_geometry is a convoluted function that makes it difficult to tell
at a glance what QEMU's current behavior for choosing a floppy drive
type is when it can't quite identify the diskette.
The code iterates over all entries in the candidate geometry table
("fd_formats") and if our specific drive type matches a row in the table,
then either "match" is set to that entry (an exact match) and the loop
exits, or "first_match" will be non-negative (the first such entry that
shares the same drive type), and the loop continues. If our specific
drive type is NONE, then all drive types in the candidate geometry table
are considered. After iteration, if "match" was not set, we fall back to
"first match".
This means that either "match" was set, or we exited the loop without an
exact match, in which case:
- If drive type is NONE, the default is truly fd_formats[0], a 1.44MB
type, because "first_match" will always get set to the first item.
- If drive type is not NONE, pick_geometry's iteration was fussier and
only looked at rows that matched our drive type. However, since all
possible drive types are represented in the table, we still know that
"first match" was set.
- If drive type is not NONE and the fd_formats table lists no options for
our drive type, we choose fd_formats[1], an incomprehensibly bizarre
choice that can never happen anyway.
Correct this: If first_match is -1, it can ONLY mean we didn't edit our
fd_formats table correctly. Throw an assertion instead.
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: John Snow <address@hidden>
Message-id: address@hidden
---
hw/block/fdc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index 18e363b..a8f0cf2 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -274,7 +274,9 @@ static void pick_geometry(FDrive *drv)
}
if (match == -1) {
if (first_match == -1) {
- match = 1;
+ error_setg(&error_abort, "No candidate geometries present in table
"
+ " for floppy drive type '%s'",
+ FloppyDriveType_lookup[drv->drive]);
} else {
match = first_match;
}
--
2.4.3
- [Qemu-devel] [PULL 00/13] IDE & FDC patches, John Snow, 2016/01/25
- [Qemu-devel] [PULL 02/13] fdc: move pick_geometry, John Snow, 2016/01/25
- [Qemu-devel] [PULL 03/13] fdc: reduce number of pick_geometry arguments, John Snow, 2016/01/25
- [Qemu-devel] [PULL 12/13] qtest/fdc: Support for 2.88MB drives, John Snow, 2016/01/25
- [Qemu-devel] [PULL 01/13] ide: Correct the CHS 'cyls_max' limit to be 65535, John Snow, 2016/01/25
- [Qemu-devel] [PULL 13/13] fdc: change auto fallback drive for ISA FDC to 288, John Snow, 2016/01/25
- [Qemu-devel] [PULL 06/13] fdc: Throw an assertion on misconfigured fd_formats table,
John Snow <=
- [Qemu-devel] [PULL 07/13] fdc: add pick_drive, John Snow, 2016/01/25
- [Qemu-devel] [PULL 10/13] fdc: add physical disk sizes, John Snow, 2016/01/25
- [Qemu-devel] [PULL 11/13] fdc: rework pick_geometry, John Snow, 2016/01/25
- [Qemu-devel] [PULL 08/13] fdc: Add fallback option, John Snow, 2016/01/25
- [Qemu-devel] [PULL 05/13] fdc: add disk field, John Snow, 2016/01/25
- [Qemu-devel] [PULL 09/13] fdc: add drive type option, John Snow, 2016/01/25
- [Qemu-devel] [PULL 04/13] fdc: add drive type qapi enum, John Snow, 2016/01/25