From e614c9e102629bcf34547eee2082dcfbd384adf6 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sat, 20 Jul 2019 11:02:05 +0300 Subject: [PATCH] genesys: Return errors as exceptions from *repark_head() --- backend/genesys_gl646.cc | 22 ++++------------------ backend/genesys_gl841.cc | 19 ++++--------------- 2 files changed, 8 insertions(+), 33 deletions(-) diff --git a/backend/genesys_gl646.cc b/backend/genesys_gl646.cc index 7bc20d5a5..803724c94 100644 --- a/backend/genesys_gl646.cc +++ b/backend/genesys_gl646.cc @@ -3378,11 +3378,9 @@ gl646_init_regs_for_warmup (Genesys_Device * dev, * so that the head goes to park position. * as a by-product, also check for lock */ -static SANE_Status -gl646_repark_head (Genesys_Device * dev) +static void gl646_repark_head(Genesys_Device* dev) { DBG_HELPER(dbg); - SANE_Status status = SANE_STATUS_GOOD; Genesys_Settings settings; unsigned int expected, steps; @@ -3425,7 +3423,6 @@ gl646_repark_head (Genesys_Device * dev) // toggle motor flag, put an huge step number and redo move backward gl646_slow_back_home(dev, 1); - return status; } /* * @@ -3588,20 +3585,9 @@ gl646_init (Genesys_Device * dev) { if (dev->model->flags & GENESYS_FLAG_REPARK) { - status = gl646_repark_head (dev); - if (status != SANE_STATUS_GOOD) - { - if (status == SANE_STATUS_INVAL) - { - DBG(DBG_error0, "Your scanner is locked. Please move the lock switch to the " - "unlocked position\n"); - return SANE_STATUS_JAMMED; - } - else - DBG(DBG_error, "%s: gl646_repark_head failed: %s\n", __func__, - sane_strstatus(status)); - return status; - } + // FIXME: if repark fails, we should print an error message that the scanner is locked and + // the user should unlock the lock. We should also rethrow with SANE_STATUS_JAMMED + gl646_repark_head(dev); } else { diff --git a/backend/genesys_gl841.cc b/backend/genesys_gl841.cc index ec10b1d73..4f6a26d98 100644 --- a/backend/genesys_gl841.cc +++ b/backend/genesys_gl841.cc @@ -4259,17 +4259,14 @@ gl841_init_regs_for_warmup (Genesys_Device * dev, * so that the head goes to park position. * as a by-product, also check for lock */ -static SANE_Status -sanei_gl841_repark_head (Genesys_Device * dev) +static void sanei_gl841_repark_head(Genesys_Device* dev) { DBG_HELPER(dbg); - SANE_Status status = SANE_STATUS_GOOD; gl841_feed(dev,232); // toggle motor flag, put an huge step number and redo move backward gl841_slow_back_home(dev, SANE_TRUE); - return status; } static bool @@ -4373,17 +4370,9 @@ gl841_init (Genesys_Device * dev) /* ensure head is correctly parked, and check lock */ if (dev->model->flags & GENESYS_FLAG_REPARK) { - status = sanei_gl841_repark_head (dev); - if (status != SANE_STATUS_GOOD) - { - if (status == SANE_STATUS_INVAL) - DBG(DBG_error0, "Your scanner is locked. Please move the lock switch to the unlocked " - "position\n"); - else - DBG(DBG_error, "%s: sanei_gl841_repark_head failed: %s\n", __func__, - sane_strstatus(status)); - return status; - } + // FIXME: if repark fails, we should print an error message that the scanner is locked and + // the user should unlock the lock. We should also rethrow with SANE_STATUS_JAMMED + sanei_gl841_repark_head(dev); } /* send gamma tables */