The scsi_is_ready() function may be called from a thread, and it is not valid to call printf() from a thread. Convert printf() to dprintf() to avoid this possibility.
This does mean that cdrom detection (from cdrom_boot() ) may not give notification of slow cdrom drives to a user. However, the extra medium detection time is unlikely to be large anyway.
Reported-by: Tobias Diedrich tobiasdiedrich@gmail.com Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/hw/blockcmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/hw/blockcmd.c b/src/hw/blockcmd.c index e20e3fc..0725b46 100644 --- a/src/hw/blockcmd.c +++ b/src/hw/blockcmd.c @@ -168,7 +168,7 @@ scsi_is_ready(struct disk_op_s *op)
if (sense.asc == 0x04 && sense.ascq == 0x01 && !in_progress) { /* IN PROGRESS OF BECOMING READY */ - printf("Waiting for device to detect medium... "); + dprintf(1, "Waiting for device to detect medium... "); /* Allow 30 seconds more */ end = timer_calc(30000); in_progress = 1;
The sector count is a 64bit number that is often reported as a 32bit number (due to limitations in dprintf). Consistently use "%u" reporting to avoid confusing negative numbers.
Reported-by: Tobias Diedrich tobiasdiedrich@gmail.com Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/block.c | 2 +- src/hw/blockcmd.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/block.c b/src/block.c index 1762e2a..b4530fc 100644 --- a/src/block.c +++ b/src/block.c @@ -162,7 +162,7 @@ setup_translation(struct drive_s *drive) // clip to 1024 cylinders in lchs if (cylinders > 1024) cylinders = 1024; - dprintf(1, "drive %p: PCHS=%u/%d/%d translation=%s LCHS=%d/%d/%d s=%d\n" + dprintf(1, "drive %p: PCHS=%u/%d/%d translation=%s LCHS=%d/%d/%d s=%u\n" , drive , drive->pchs.cylinder, drive->pchs.head, drive->pchs.sector , desc diff --git a/src/hw/blockcmd.c b/src/hw/blockcmd.c index 0725b46..093c5d7 100644 --- a/src/hw/blockcmd.c +++ b/src/hw/blockcmd.c @@ -232,7 +232,7 @@ scsi_drive_setup(struct drive_s *drive, const char *s, int prio) return -1; } drive->sectors = (u64)be32_to_cpu(capdata.sectors) + 1; - dprintf(1, "%s blksize=%d sectors=%d\n" + dprintf(1, "%s blksize=%d sectors=%u\n" , s, drive->blksize, (unsigned)drive->sectors);
// We do not recover from USB stalls, so try to be safe and avoid
On Wed, Dec 23, 2015 at 03:48:48PM -0500, Kevin O'Connor wrote:
The scsi_is_ready() function may be called from a thread, and it is not valid to call printf() from a thread. Convert printf() to dprintf() to avoid this possibility.
This does mean that cdrom detection (from cdrom_boot() ) may not give notification of slow cdrom drives to a user. However, the extra medium detection time is unlikely to be large anyway.
FYI, I committed this change.
-Kevin