From 0d7543ec659fc5f8f2750a8d8cc47e6cf939f029 Mon Sep 17 00:00:00 2001 From: Zdenek Dohnal Date: Wed, 21 Sep 2022 17:57:35 +0200 Subject: [PATCH] backend/canon.c: Use the common model name instead internal string --- backend/canon.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/backend/canon.c b/backend/canon.c index 4339d4d7c..d17cd01a4 100644 --- a/backend/canon.c +++ b/backend/canon.c @@ -823,7 +823,6 @@ attach (const char *devnam, CANON_Device ** devp) fd = -1; return (SANE_STATUS_NO_MEM); } - dev->sane.model = str; /* Register the fixed properties of the scanner below: - whether it is a film scanner or a flatbed scanner @@ -841,6 +840,7 @@ attach (const char *devnam, CANON_Device ** devp) if (!strncmp (str, "IX-27015", 8)) /* FS2700S */ { dev->info.model = CS2700; + dev->sane.model = strdup("FS2700S"); dev->sane.type = SANE_I18N("film scanner"); dev->adf.Status = ADF_STAT_NONE; dev->tpu.Status = TPU_STAT_NONE; @@ -856,6 +856,7 @@ attach (const char *devnam, CANON_Device ** devp) else if (!strncmp (str, "IX-27025E", 9)) /* FS2710S */ { dev->info.model = FS2710; + dev->sane.model = strdup("FS2710S"); dev->sane.type = SANE_I18N("film scanner"); dev->adf.Status = ADF_STAT_NONE; dev->tpu.Status = TPU_STAT_NONE; @@ -871,6 +872,7 @@ attach (const char *devnam, CANON_Device ** devp) else if (!strncmp (str, "IX-06035E", 9)) /* FB620S */ { dev->info.model = FB620; + dev->sane.model = strdup("FB620S"); dev->sane.type = SANE_I18N("flatbed scanner"); dev->adf.Status = ADF_STAT_NONE; dev->tpu.Status = TPU_STAT_NONE; @@ -886,6 +888,7 @@ attach (const char *devnam, CANON_Device ** devp) else if (!strncmp (str, "IX-12015E", 9)) /* FB1200S */ { dev->info.model = FB1200; + dev->sane.model = strdup("FB1200S"); dev->sane.type = SANE_I18N("flatbed scanner"); dev->adf.Status = ADF_STAT_INACTIVE; dev->tpu.Status = TPU_STAT_INACTIVE; @@ -929,6 +932,20 @@ attach (const char *devnam, CANON_Device ** devp) dev->info.has_fixed_resolutions = SANE_FALSE; } + /* + * Use the model from the device if we don't have more + * common model name for the device, otherwise free the + * string with internal model name. + * + * Please keep the memory allocation source consistent + * for model string - allocate on the heap via dynamic + * allocation. + */ + if (dev->sane.model == NULL) + dev->sane.model = str; + else + free(str); + DBG (5, "dev->sane.name = '%s'\n", dev->sane.name); DBG (5, "dev->sane.vendor = '%s'\n", dev->sane.vendor); DBG (5, "dev->sane.model = '%s'\n", dev->sane.model);