From 797cd1fb37ee87185ad79fd4bf87648b33599e83 Mon Sep 17 00:00:00 2001 From: Olaf Meeuwissen Date: Sat, 10 Aug 2019 21:05:48 +0900 Subject: [PATCH] epson2, epsonds, kodakaio, magicolor: Don't set invalid value If the value to be set is not valid, it should not change the sval structure (even if doing so has no negative side effects). This also makes the fallthrough less confusing by removing the first cast of two for the br-x and br-y values. --- backend/epson2.c | 3 +-- backend/epsonds.c | 3 +-- backend/kodakaio.c | 3 +-- backend/magicolor.c | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/backend/epson2.c b/backend/epson2.c index ef5358984..e6f678675 100644 --- a/backend/epson2.c +++ b/backend/epson2.c @@ -1889,8 +1889,7 @@ setvalue(SANE_Handle handle, SANE_Int option, void *value, SANE_Int *info) case OPT_BR_X: case OPT_BR_Y: - sval->w = *((SANE_Word *) value); - if (SANE_UNFIX(sval->w) == 0) { + if (SANE_UNFIX(*((SANE_Word *) value)) == 0) { DBG(17, "invalid br-x or br-y\n"); return SANE_STATUS_INVAL; } diff --git a/backend/epsonds.c b/backend/epsonds.c index 45389ceb2..ff5d68106 100644 --- a/backend/epsonds.c +++ b/backend/epsonds.c @@ -1050,8 +1050,7 @@ setvalue(SANE_Handle handle, SANE_Int option, void *value, SANE_Int *info) case OPT_BR_X: case OPT_BR_Y: - sval->w = *((SANE_Word *) value); - if (SANE_UNFIX(sval->w) == 0) { + if (SANE_UNFIX(*((SANE_Word *) value)) == 0) { DBG(17, " invalid br-x or br-y\n"); return SANE_STATUS_INVAL; } diff --git a/backend/kodakaio.c b/backend/kodakaio.c index 331e1e664..d5c2857c0 100644 --- a/backend/kodakaio.c +++ b/backend/kodakaio.c @@ -3276,8 +3276,7 @@ setvalue(SANE_Handle handle, SANE_Int option, void *value, SANE_Int *info) case OPT_BR_X: case OPT_BR_Y: - sval->w = *((SANE_Word *) value); - if (SANE_UNFIX(sval->w) == 0) { + if (SANE_UNFIX(*((SANE_Word *) value)) == 0) { DBG(17, "invalid br-x or br-y\n"); return SANE_STATUS_INVAL; } diff --git a/backend/magicolor.c b/backend/magicolor.c index a2185199b..af9fb1af7 100644 --- a/backend/magicolor.c +++ b/backend/magicolor.c @@ -2789,8 +2789,7 @@ setvalue(SANE_Handle handle, SANE_Int option, void *value, SANE_Int *info) case OPT_BR_X: case OPT_BR_Y: - sval->w = *((SANE_Word *) value); - if (SANE_UNFIX(sval->w) == 0) { + if (SANE_UNFIX(*((SANE_Word *) value)) == 0) { DBG(17, "invalid br-x or br-y\n"); return SANE_STATUS_INVAL; }