summaryrefslogtreecommitdiff
path: root/backend/umax_pp.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2020-02-02 17:13:01 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2020-02-02 17:13:01 +0100
commitffa8801644a7d53cc1c785e3450f794c07a14eb0 (patch)
tree8d72a18a9a08b9151d12badcb1c78ce06a059f62 /backend/umax_pp.c
parent1687222e1b9e74c89cafbb5910e72d8ec7bfd40f (diff)
New upstream version 1.0.29upstream/1.0.29
Diffstat (limited to 'backend/umax_pp.c')
-rw-r--r--backend/umax_pp.c47
1 files changed, 19 insertions, 28 deletions
diff --git a/backend/umax_pp.c b/backend/umax_pp.c
index b1121ef..16adbe3 100644
--- a/backend/umax_pp.c
+++ b/backend/umax_pp.c
@@ -103,10 +103,6 @@
* 129 if you want to know which parameters are unused
*/
-/* history:
- * see Changelog
- */
-
#define UMAX_PP_BUILD 2301
#define UMAX_PP_STATE "release"
@@ -206,34 +202,28 @@ umax_pp_attach (SANEI_Config * config, const char *devname)
SANE_Status status = SANE_STATUS_GOOD;
int ret, prt = 0, mdl;
char model[32];
- char name[64];
- char *val;
-
- memset (name, 0, 64);
+ const char *name = NULL;
+ const char *val;
- if ((strlen (devname) < 3))
+ if (!devname || (strlen (devname) < 3))
return SANE_STATUS_INVAL;
sanei_umax_pp_setastra (atoi((SANE_Char *) config->values[CFG_ASTRA]));
/* if the name begins with a slash, it's a device, else it's an addr */
- if (devname != NULL)
+ if ((devname[0] == '/'))
{
- if ((devname[0] == '/'))
- {
- strncpy (name, devname, 64);
- }
+ name = devname;
+ }
+ else
+ {
+ if ((devname[0] == '0')
+ && ((devname[1] == 'x') || (devname[1] == 'X')))
+ prt = strtol (devname + 2, NULL, 16);
else
- {
- if ((devname[0] == '0')
- && ((devname[1] == 'x') || (devname[1] == 'X')))
- prt = strtol (devname + 2, NULL, 16);
- else
- prt = atoi (devname);
- }
+ prt = atoi (devname);
}
-
for (i = 0; i < num_devices; i++)
{
if (devname[0] == '/')
@@ -295,7 +285,7 @@ umax_pp_attach (SANEI_Config * config, const char *devname)
devname);
return SANE_STATUS_IO_ERROR;
}
- sprintf (model, "Astra %dP", mdl);
+ snprintf (model, sizeof(model), "Astra %dP", mdl);
dev = malloc (sizeof (Umax_PP_Descriptor) * (num_devices + 1));
@@ -319,12 +309,12 @@ umax_pp_attach (SANEI_Config * config, const char *devname)
num_devices++;
/* if there are user provided values, use them */
- val=(SANE_Char *) config->values[CFG_NAME];
+ val=(const SANE_Char *) config->values[CFG_NAME];
if(strlen(val)==0)
dev->sane.name = strdup (devname);
else
dev->sane.name = strdup (val);
- val=(SANE_Char *) config->values[CFG_VENDOR];
+ val=(const SANE_Char *) config->values[CFG_VENDOR];
if(strlen(val)==0)
dev->sane.vendor = strdup ("UMAX");
else
@@ -351,11 +341,11 @@ umax_pp_attach (SANEI_Config * config, const char *devname)
dev->max_h_size = 2550;
dev->max_v_size = 3500;
}
- val=(SANE_Char *) config->values[CFG_MODEL];
+ val=(const SANE_Char *) config->values[CFG_MODEL];
if(strlen(val)==0)
- dev->sane.model = strdup (model);
+ dev->sane.model = strdup (model);
else
- dev->sane.model = strdup (val);
+ dev->sane.model = strdup (val);
DBG (3, "umax_pp_attach: device %s attached\n", devname);
@@ -1462,6 +1452,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option,
if (info)
*info |= SANE_INFO_RELOAD_PARAMS;
+ // fall through
case OPT_GRAY_GAIN:
case OPT_GREEN_GAIN:
case OPT_RED_GAIN: