backend/canon.c: Use the common model name instead internal string

merge-requests/756/head
Zdenek Dohnal 2022-09-21 17:57:35 +02:00
rodzic b5e7e78312
commit 0d7543ec65
1 zmienionych plików z 18 dodań i 1 usunięć

Wyświetl plik

@ -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);