kopia lustrzana https://gitlab.com/sane-project/backends
fixed cppcheck warnings
rodzic
98700ee66a
commit
8fb3a366cd
|
@ -42,7 +42,7 @@
|
|||
whether to permit this exception to apply to your modifications.
|
||||
If you do not wish that, delete this exception notice.
|
||||
*/
|
||||
# include "../include/sane/config.h"
|
||||
#include "../include/sane/config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
@ -370,7 +370,7 @@ create_mode_list (pixma_sane_t * ss, SANE_Bool tpu)
|
|||
ss->mode_map[i] = PIXMA_SCAN_MODE_GRAY;
|
||||
i++;
|
||||
}
|
||||
if (tpu && cfg->cap & PIXMA_CAP_NEGATIVE)
|
||||
if (tpu && (cfg->cap & PIXMA_CAP_NEGATIVE))
|
||||
{
|
||||
ss->mode_list[i] = SANE_I18N ("Negative color");
|
||||
ss->mode_map[i] = PIXMA_SCAN_MODE_NEGATIVE_COLOR;
|
||||
|
@ -382,7 +382,7 @@ create_mode_list (pixma_sane_t * ss, SANE_Bool tpu)
|
|||
i++;
|
||||
}
|
||||
}
|
||||
if (!tpu && cfg->cap & PIXMA_CAP_48BIT)
|
||||
if (!tpu && (cfg->cap & PIXMA_CAP_48BIT))
|
||||
{
|
||||
ss->mode_list[i] = SANE_I18N ("48 bits color");
|
||||
ss->mode_map[i] = PIXMA_SCAN_MODE_COLOR_48;
|
||||
|
@ -394,7 +394,7 @@ create_mode_list (pixma_sane_t * ss, SANE_Bool tpu)
|
|||
i++;
|
||||
}
|
||||
}
|
||||
if (!tpu && cfg->cap & PIXMA_CAP_LINEART)
|
||||
if (!tpu && (cfg->cap & PIXMA_CAP_LINEART))
|
||||
{
|
||||
ss->mode_list[i] = SANE_VALUE_SCAN_MODE_LINEART;
|
||||
ss->mode_map[i] = PIXMA_SCAN_MODE_LINEART;
|
||||
|
@ -561,7 +561,6 @@ control_string_option (pixma_sane_t * ss, SANE_Int n, SANE_Action a, void *v,
|
|||
option_descriptor_t *opt = &(OPT_IN_CTX[n]);
|
||||
const SANE_String_Const *slist = opt->sod.constraint.string_list;
|
||||
SANE_String str = (SANE_String) v;
|
||||
int i;
|
||||
|
||||
if (opt->sod.constraint_type == SANE_CONSTRAINT_NONE)
|
||||
{
|
||||
|
@ -582,6 +581,8 @@ control_string_option (pixma_sane_t * ss, SANE_Int n, SANE_Action a, void *v,
|
|||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
|
||||
switch (a)
|
||||
{
|
||||
case SANE_ACTION_GET_VALUE:
|
||||
|
@ -712,7 +713,7 @@ control_option (pixma_sane_t * ss, SANE_Int n,
|
|||
}
|
||||
break;
|
||||
case opt_mode:
|
||||
if (cfg->cap & (PIXMA_CAP_LINEART)
|
||||
if ((cfg->cap & (PIXMA_CAP_LINEART))
|
||||
&& (a == SANE_ACTION_SET_VALUE || a == SANE_ACTION_SET_AUTO))
|
||||
{ /* new mode selected: Color, Gray, ... */
|
||||
/* PDBG (pixma_dbg (4, "*control_option***** mode = %u *\n",
|
||||
|
@ -738,7 +739,7 @@ control_option (pixma_sane_t * ss, SANE_Int n,
|
|||
}
|
||||
break;
|
||||
case opt_source:
|
||||
if (cfg->cap & (PIXMA_CAP_ADF|PIXMA_CAP_ADFDUP|PIXMA_CAP_TPU)
|
||||
if ((cfg->cap & (PIXMA_CAP_ADF|PIXMA_CAP_ADFDUP|PIXMA_CAP_TPU))
|
||||
&& (a == SANE_ACTION_SET_VALUE || a == SANE_ACTION_SET_AUTO))
|
||||
{ /* new source selected: flatbed, ADF, TPU, ... */
|
||||
/* recreate dynamic lists */
|
||||
|
|
|
@ -164,6 +164,7 @@ attach_bjnp (SANE_String_Const devname, SANE_String_Const makemodel,
|
|||
{
|
||||
scanner_info_t *si;
|
||||
const pixma_config_t *cfg;
|
||||
SANE_Status error;
|
||||
|
||||
si = (scanner_info_t *) calloc (1, sizeof (*si));
|
||||
if (!si)
|
||||
|
@ -172,14 +173,18 @@ attach_bjnp (SANE_String_Const devname, SANE_String_Const makemodel,
|
|||
if (!si->devname)
|
||||
return SANE_STATUS_NO_MEM;
|
||||
if ((cfg = lookup_scanner(makemodel, pixma_devices)) == (struct pixma_config_t *)NULL)
|
||||
return SANE_STATUS_INVAL;
|
||||
si->cfg = cfg;
|
||||
sprintf(si->serial, "%s_%s", cfg->model, serial);
|
||||
si -> interface = INT_BJNP;
|
||||
si->next = first_scanner;
|
||||
first_scanner = si;
|
||||
nscanners++;
|
||||
return SANE_STATUS_GOOD;
|
||||
error = SANE_STATUS_INVAL;
|
||||
else
|
||||
{
|
||||
si->cfg = cfg;
|
||||
sprintf(si->serial, "%s_%s", cfg->model, serial);
|
||||
si -> interface = INT_BJNP;
|
||||
si->next = first_scanner;
|
||||
first_scanner = si;
|
||||
nscanners++;
|
||||
error = SANE_STATUS_GOOD;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -232,9 +237,8 @@ read_serial_number (scanner_info_t * si)
|
|||
{
|
||||
uint8_t unicode[2 * (PIXMA_MAX_ID_LEN - 9) + 2];
|
||||
uint8_t ddesc[18];
|
||||
int i, len, iSerialNumber;
|
||||
int iSerialNumber;
|
||||
SANE_Int usb;
|
||||
SANE_Status status;
|
||||
char *serial = si->serial;
|
||||
|
||||
u16tohex (si->cfg->vid, serial);
|
||||
|
@ -248,6 +252,9 @@ read_serial_number (scanner_info_t * si)
|
|||
iSerialNumber = ddesc[16];
|
||||
if (iSerialNumber != 0)
|
||||
{
|
||||
int i, len;
|
||||
SANE_Status status;
|
||||
|
||||
/*int iSerialNumber = ddesc[16];*/
|
||||
/* Read the first language code. Assumed that there is at least one. */
|
||||
if (get_string_descriptor (usb, 0, 0, 4, unicode) != SANE_STATUS_GOOD)
|
||||
|
|
|
@ -1065,7 +1065,7 @@ static unsigned
|
|||
post_process_image_data (pixma_t * s, pixma_imagebuf_t * ib)
|
||||
{
|
||||
mp150_t *mp = (mp150_t *) s->subdriver;
|
||||
unsigned c, lines, i, line_size, n, m, cw, cx;
|
||||
unsigned c, lines, line_size, n, m, cw, cx;
|
||||
uint8_t *sptr, *dptr, *gptr, *cptr;
|
||||
|
||||
c = ((is_ccd_grayscale (s) || is_ccd_lineart (s)) ? 3 : s->param->channels)
|
||||
|
@ -1091,6 +1091,8 @@ post_process_image_data (pixma_t * s, pixma_imagebuf_t * ib)
|
|||
lines, 2 * mp->color_shift + mp->stripe_shift));*/
|
||||
if (lines > 2 * mp->color_shift + mp->stripe_shift)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
lines -= 2 * mp->color_shift + mp->stripe_shift;
|
||||
for (i = 0; i < lines; i++, sptr += line_size)
|
||||
{
|
||||
|
@ -1201,7 +1203,6 @@ static int
|
|||
mp150_check_param (pixma_t * s, pixma_scan_param_t * sp)
|
||||
{
|
||||
mp150_t *mp = (mp150_t *) s->subdriver;
|
||||
unsigned w_max;
|
||||
|
||||
/* PDBG (pixma_dbg (4, "*mp150_check_param***** Initially: channels=%u, depth=%u, x=%u, y=%u, w=%u, h=%u, xs=%u, wx=%u *****\n",
|
||||
sp->channels, sp->depth, sp->x, sp->y, sp->w, sp->h, sp->xs, sp->wx)); */
|
||||
|
@ -1229,6 +1230,8 @@ mp150_check_param (pixma_t * s, pixma_scan_param_t * sp)
|
|||
/* for software lineart w must be a multiple of 8 */
|
||||
if (sp->software_lineart == 1 && sp->w % 8)
|
||||
{
|
||||
unsigned w_max;
|
||||
|
||||
sp->w += 8 - (sp->w % 8);
|
||||
|
||||
/* do not exceed the scanner capability */
|
||||
|
@ -1313,7 +1316,7 @@ mp150_check_param (pixma_t * s, pixma_scan_param_t * sp)
|
|||
static int
|
||||
mp150_scan (pixma_t * s)
|
||||
{
|
||||
int error = 0, tmo, i;
|
||||
int error = 0, tmo;
|
||||
mp150_t *mp = (mp150_t *) s->subdriver;
|
||||
|
||||
if (mp->state != state_idle)
|
||||
|
@ -1409,8 +1412,12 @@ mp150_scan (pixma_t * s)
|
|||
if ((error >= 0) && (mp->generation >= 3) && has_ccd_sensor (s))
|
||||
error = init_ccd_lamp_3 (s);
|
||||
if ((error >= 0) && !is_scanning_from_tpu (s))
|
||||
for (i = (mp->generation >= 3) ? 3 : 1 ; i > 0 && error >= 0; i--)
|
||||
error = send_gamma_table (s);
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = (mp->generation >= 3) ? 3 : 1 ; i > 0 && error >= 0; i--)
|
||||
error = send_gamma_table (s);
|
||||
}
|
||||
else if (error >= 0) /* in TPU mode, for gen 1, 2, and 3 */
|
||||
error = send_set_tpu_info (s);
|
||||
}
|
||||
|
|
|
@ -401,7 +401,7 @@ read_error_info (pixma_t * s, void *buf, unsigned size)
|
|||
static int
|
||||
step1 (pixma_t * s)
|
||||
{
|
||||
int error, tmo;
|
||||
int error;
|
||||
|
||||
error = query_status (s);
|
||||
if (error < 0)
|
||||
|
@ -420,7 +420,7 @@ step1 (pixma_t * s)
|
|||
/* MF57x0: Wait 10 sec before starting for 1st page only */
|
||||
if (s->param->adf_pageid == 0)
|
||||
{
|
||||
tmo = 10; /* like Windows driver, 10 sec CCD calibration ? */
|
||||
int tmo = 10; /* like Windows driver, 10 sec CCD calibration ? */
|
||||
while (--tmo >= 0)
|
||||
{
|
||||
error = handle_interrupt (s, 1000); \
|
||||
|
|
|
@ -324,8 +324,8 @@ read_image_block (pixma_t * s, uint8_t * data)
|
|||
return count;
|
||||
if (count == IMAGE_BLOCK_SIZE)
|
||||
{
|
||||
int error;
|
||||
if ((error = pixma_read (s->io, &temp, 0)) < 0)
|
||||
int error = pixma_read (s->io, &temp, 0);
|
||||
if (error < 0)
|
||||
{
|
||||
PDBG (pixma_dbg
|
||||
(1, "WARNING: reading zero-length packet failed %d\n", error));
|
||||
|
@ -488,6 +488,7 @@ calc_component_shifting (pixma_t * s)
|
|||
return s->param->ydpi / 75;
|
||||
}
|
||||
/* never reached */
|
||||
break;
|
||||
|
||||
case MP750_PID:
|
||||
case MP780_PID:
|
||||
|
|
|
@ -1401,7 +1401,7 @@ pack_48_24_bpc (uint8_t * sptr, unsigned n)
|
|||
static unsigned post_process_image_data (pixma_t * s, pixma_imagebuf_t * ib)
|
||||
{
|
||||
mp810_t *mp = (mp810_t *) s->subdriver;
|
||||
unsigned c, lines, i, line_size, n, m, cw, cx, reducelines;
|
||||
unsigned c, lines, line_size, n, m, cw, cx, reducelines;
|
||||
uint8_t *sptr, *dptr, *gptr, *cptr;
|
||||
unsigned /*color_shift, stripe_shift, stripe_shift2,*/ jumplines /*, height*/;
|
||||
int test;
|
||||
|
@ -1493,6 +1493,8 @@ static unsigned post_process_image_data (pixma_t * s, pixma_imagebuf_t * ib)
|
|||
/* PDBG (pixma_dbg (4, "*post_process_image_data: lines %u, reducelines %u \n", lines, reducelines)); */
|
||||
if (lines > reducelines)
|
||||
{ /* (line - reducelines) of image lines can be converted */
|
||||
unsigned i;
|
||||
|
||||
lines -= reducelines;
|
||||
|
||||
for (i = 0; i < lines; i++, sptr += line_size)
|
||||
|
@ -1697,7 +1699,7 @@ static int mp810_check_param (pixma_t * s, pixma_scan_param_t * sp)
|
|||
case PIXMA_SCAN_MODE_GRAY:
|
||||
case PIXMA_SCAN_MODE_NEGATIVE_GRAY:
|
||||
sp->channels = 1;
|
||||
/* no break */
|
||||
/* fall through */
|
||||
case PIXMA_SCAN_MODE_COLOR:
|
||||
case PIXMA_SCAN_MODE_NEGATIVE_COLOR:
|
||||
sp->depth = 8;
|
||||
|
@ -1899,7 +1901,7 @@ static int mp810_check_param (pixma_t * s, pixma_scan_param_t * sp)
|
|||
|
||||
static int mp810_scan (pixma_t * s)
|
||||
{
|
||||
int error = 0, tmo, i;
|
||||
int error = 0, tmo;
|
||||
mp810_t *mp = (mp810_t *) s->subdriver;
|
||||
|
||||
if (mp->state != state_idle)
|
||||
|
@ -1942,7 +1944,7 @@ static int mp810_scan (pixma_t * s)
|
|||
case PIXMA_ECANCELED:
|
||||
case PIXMA_EBUSY:
|
||||
PDBG(pixma_dbg (2, "cmd e920 or d520 returned %s\n", pixma_strerror (error)));
|
||||
/* no break */
|
||||
/* fall through */
|
||||
case 0:
|
||||
query_status (s);
|
||||
break;
|
||||
|
@ -1992,6 +1994,7 @@ static int mp810_scan (pixma_t * s)
|
|||
error = init_ccd_lamp_3 (s);
|
||||
if ((error >= 0) && !is_scanning_from_tpu (s))
|
||||
{
|
||||
int i;
|
||||
/* FIXME: 48 bit flatbed scans don't need gamma tables
|
||||
* the code below doesn't run */
|
||||
/*if (is_color_48 (s) || is_gray_16 (s))
|
||||
|
@ -2118,7 +2121,7 @@ static void mp810_finish_scan (pixma_t * s)
|
|||
{
|
||||
case state_transfering:
|
||||
drain_bulk_in (s);
|
||||
/* no break */
|
||||
/* fall through */
|
||||
case state_scanning:
|
||||
case state_warmup:
|
||||
case state_finished:
|
||||
|
@ -2142,7 +2145,7 @@ static void mp810_finish_scan (pixma_t * s)
|
|||
}
|
||||
}
|
||||
mp->state = state_idle;
|
||||
/* no break */
|
||||
/* fall through */
|
||||
case state_idle:
|
||||
break;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue