Merge branch 'test-high-res' into 'master'

Test backend - scanning high resolution images

See merge request sane-project/backends!737
251-scanner-canon-mf110-910-series-is-not-supported
Ralph Little 2022-06-01 20:34:20 +00:00
commit ba2c1f92f1
5 zmienionych plików z 306 dodań i 301 usunięć

Plik diff jest za duży Load Diff

Wyświetl plik

@ -794,17 +794,17 @@ typedef struct acceleration_info
/* set/get SCSI highended (big-endian) variables. Declare them as an array /* set/get SCSI highended (big-endian) variables. Declare them as an array
* of chars endianness-safe, int-size safe ... */ * of chars endianness-safe, int-size safe ... */
#define set_double(var,val) var[0] = ((val) >> 8) & 0xff; \ #define set_double(var,val) var[0] = (uint8_t) (((val) >> 8) & 0xff); \
var[1] = ((val) ) & 0xff var[1] = (uint8_t) (((val) ) & 0xff)
#define set_triple(var,val) var[0] = ((val) >> 16) & 0xff; \ #define set_triple(var,val) var[0] = (uint8_t) (((val) >> 16) & 0xff); \
var[1] = ((val) >> 8 ) & 0xff; \ var[1] = (uint8_t) (((val) >> 8 ) & 0xff); \
var[2] = ((val) ) & 0xff var[2] = (uint8_t) (((val) ) & 0xff)
#define set_quad(var,val) var[0] = ((val) >> 24) & 0xff; \ #define set_quad(var,val) var[0] = (uint8_t) (((val) >> 24) & 0xff); \
var[1] = ((val) >> 16) & 0xff; \ var[1] = (uint8_t) (((val) >> 16) & 0xff); \
var[2] = ((val) >> 8 ) & 0xff; \ var[2] = (uint8_t) (((val) >> 8 ) & 0xff); \
var[3] = ((val) ) & 0xff var[3] = (uint8_t) (((val) ) & 0xff)
#define get_double(var) ((*var << 8) + *(var + 1)) #define get_double(var) ((*var << 8) + *(var + 1))
@ -816,10 +816,10 @@ typedef struct acceleration_info
(*(var + 2) << 8) + *(var + 3)) (*(var + 2) << 8) + *(var + 3))
/* set/get Avision lowended (little-endian) shading data */ /* set/get Avision lowended (little-endian) shading data */
#define set_double_le(var,val) var[0] = ((val) ) & 0xff; \ #define set_double_le(var,val) var[0] = (uint8_t) (((val) ) & 0xff); \
var[1] = ((val) >> 8) & 0xff var[1] = (uint8_t) (((val) >> 8) & 0xff)
#define get_double_le(var) ((*(var + 1) << 8) + *var) #define get_double_le(var) ((uint16_t) ((*(var + 1) << 8) + *(var)))
#define BIT(n, p) ((n & (1 << p)) ? 1 : 0) #define BIT(n, p) ((n & (1 << p)) ? 1 : 0)

Wyświetl plik

@ -48,7 +48,8 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
size_t * buffer_size) size_t * buffer_size)
{ {
SANE_Word pattern_size = 0, pattern_distance = 0; SANE_Word pattern_size = 0, pattern_distance = 0;
SANE_Word line_count, b_size; SANE_Word line_count;
size_t b_size;
SANE_Word lines = 0; SANE_Word lines = 0;
SANE_Word bpl = test_device->bytes_per_line; SANE_Word bpl = test_device->bytes_per_line;
SANE_Word ppl = test_device->pixels_per_line; SANE_Word ppl = test_device->pixels_per_line;
@ -83,7 +84,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if (strcmp (test_device->val[opt_test_picture].s, "Solid black") == 0) if (strcmp (test_device->val[opt_test_picture].s, "Solid black") == 0)
{ {
DBG (3, "(child) init_picture_buffer: drawing solid black test " DBG (3, "(child) init_picture_buffer: drawing solid black test "
"picture %d bytes\n", b_size); "picture %zu bytes\n", b_size);
if (test_device->params.format == SANE_FRAME_GRAY if (test_device->params.format == SANE_FRAME_GRAY
&& test_device->params.depth == 1) && test_device->params.depth == 1)
pattern = 0xff; pattern = 0xff;
@ -93,7 +94,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
else else
{ {
DBG (3, "(child) init_picture_buffer: drawing solid white test " DBG (3, "(child) init_picture_buffer: drawing solid white test "
"picture %d bytes\n", b_size); "picture %zu bytes\n", b_size);
if (test_device->params.format == SANE_FRAME_GRAY if (test_device->params.format == SANE_FRAME_GRAY
&& test_device->params.depth == 1) && test_device->params.depth == 1)
pattern = 0x00; pattern = 0x00;
@ -115,8 +116,8 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if (test_device->params.depth == 16) if (test_device->params.depth == 16)
increment *= 2; increment *= 2;
lines = 2 * p_size + 0.5; lines = (SANE_Word) (2 * p_size + 0.5);
b_size = lines * bpl; b_size = (size_t) lines * (size_t) bpl;
if (buffer_size) if (buffer_size)
*buffer_size = b_size; *buffer_size = b_size;
b = malloc (b_size); b = malloc (b_size);
@ -128,7 +129,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if (buffer) if (buffer)
*buffer = b; *buffer = b;
DBG (3, "(child) init_picture_buffer: drawing grid test picture " DBG (3, "(child) init_picture_buffer: drawing grid test picture "
"%d bytes, %d bpl, %d ppl, %d lines\n", b_size, bpl, ppl, lines); "%zu bytes, %d bpl, %d ppl, %d lines\n", b_size, bpl, ppl, lines);
for (line_count = 0; line_count < lines; line_count++) for (line_count = 0; line_count < lines; line_count++)
{ {
@ -161,7 +162,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
} }
else else
color = (rand ()) & 0x01; color = (rand ()) & 0x01;
value |= (color << x1); value |= (SANE_Byte) (color << x1);
} }
b[line_count * bpl + x] = value; b[line_count * bpl + x] = value;
} }
@ -182,7 +183,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
} }
else else
color = (rand ()) & 0x01; color = (rand ()) & 0x01;
value |= (color << x1); value |= (SANE_Byte) (color << x1);
} }
for (x1 = 0; x1 < increment; x1++) for (x1 = 0; x1 < increment; x1++)
b[line_count * bpl + x + x1] = value; b[line_count * bpl + x + x1] = value;
@ -197,7 +198,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
else else
color = 0xff; color = 0xff;
else else
color = (rand ()) & 0xff; color = (SANE_Byte) ((rand ()) & 0xff);
for (x1 = 0; x1 < increment; x1++) for (x1 = 0; x1 < increment; x1++)
b[line_count * bpl + x + x1] = color; b[line_count * bpl + x + x1] = color;
@ -215,7 +216,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
pattern_size = 16; pattern_size = 16;
pattern_distance = 0; pattern_distance = 0;
lines = 2 * (pattern_size + pattern_distance); lines = 2 * (pattern_size + pattern_distance);
b_size = lines * bpl; b_size = (size_t) lines * (size_t) bpl;
if (buffer_size) if (buffer_size)
*buffer_size = b_size; *buffer_size = b_size;
@ -228,7 +229,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if (buffer) if (buffer)
*buffer = b; *buffer = b;
DBG (3, "(child) init_picture_buffer: drawing b/w test picture " DBG (3, "(child) init_picture_buffer: drawing b/w test picture "
"%d bytes, %d bpl, %d lines\n", b_size, bpl, lines); "%zu bytes, %d bpl, %d lines\n", b_size, bpl, lines);
memset (b, 255, b_size); memset (b, 255, b_size);
for (line_count = 0; line_count < lines; line_count++) for (line_count = 0; line_count < lines; line_count++)
{ {
@ -244,7 +245,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
width = pattern_size / 8; width = pattern_size / 8;
if (x + width >= bpl) if (x + width >= bpl)
width = bpl - x; width = bpl - x;
memset (b + line_count * bpl + x, 0x00, width); memset (b + line_count * bpl + x, 0x00, (size_t) width);
x += (pattern_size + pattern_distance) * 2 / 8; x += (pattern_size + pattern_distance) * 2 / 8;
} }
} }
@ -256,7 +257,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
pattern_size = 4; pattern_size = 4;
pattern_distance = 1; pattern_distance = 1;
lines = 2 * (pattern_size + pattern_distance); lines = 2 * (pattern_size + pattern_distance);
b_size = lines * bpl; b_size = (size_t) lines * (size_t) bpl;
if (buffer_size) if (buffer_size)
*buffer_size = b_size; *buffer_size = b_size;
@ -269,7 +270,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if (buffer) if (buffer)
*buffer = b; *buffer = b;
DBG (3, "(child) init_picture_buffer: drawing 8 bit gray test picture " DBG (3, "(child) init_picture_buffer: drawing 8 bit gray test picture "
"%d bytes, %d bpl, %d lines\n", b_size, bpl, lines); "%zu bytes, %d bpl, %d lines\n", b_size, bpl, lines);
memset (b, 0x55, b_size); memset (b, 0x55, b_size);
for (line_count = 0; line_count < lines; line_count++) for (line_count = 0; line_count < lines; line_count++)
{ {
@ -289,10 +290,10 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
width = bpl - x; width = bpl - x;
if (line_count > (pattern_size + pattern_distance)) if (line_count > (pattern_size + pattern_distance))
color = color =
0xff - ((x / (pattern_size + pattern_distance)) & 0xff); (SANE_Byte) (0xff - ((x / (pattern_size + pattern_distance)) & 0xff));
else else
color = (x / (pattern_size + pattern_distance)) & 0xff; color = (SANE_Byte) ((x / (pattern_size + pattern_distance)) & 0xff);
memset (b + line_count * bpl + x, color, width); memset (b + line_count * bpl + x, color, (size_t) width);
x += (pattern_size + pattern_distance); x += (pattern_size + pattern_distance);
} }
} }
@ -305,7 +306,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
pattern_size = 256; pattern_size = 256;
pattern_distance = 4; pattern_distance = 4;
lines = 1 * (pattern_size + pattern_distance); lines = 1 * (pattern_size + pattern_distance);
b_size = lines * bpl; b_size = (size_t) lines * (size_t) bpl;
if (buffer_size) if (buffer_size)
*buffer_size = b_size; *buffer_size = b_size;
@ -318,7 +319,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if (buffer) if (buffer)
*buffer = b; *buffer = b;
DBG (3, "(child) init_picture_buffer: drawing 16 bit gray test picture " DBG (3, "(child) init_picture_buffer: drawing 16 bit gray test picture "
"%d bytes, %d bpl, %d lines\n", b_size, bpl, lines); "%zu bytes, %d bpl, %d lines\n", b_size, bpl, lines);
memset (b, 0x55, b_size); memset (b, 0x55, b_size);
for (line_count = 0; line_count < lines; line_count++) for (line_count = 0; line_count < lines; line_count++)
{ {
@ -338,11 +339,11 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if (x + width >= bpl) if (x + width >= bpl)
width = bpl - x; width = bpl - x;
pattern_lo = pattern_lo =
((line_count - pattern_distance) (SANE_Byte) (((line_count - pattern_distance)
% (pattern_size + pattern_distance)) & 0xff; % (pattern_size + pattern_distance)) & 0xff);
for (x1 = 0; x1 < width; x1 += 2) for (x1 = 0; x1 < width; x1 += 2)
{ {
pattern_hi = (x1 / 2) & 0xff; pattern_hi = (SANE_Byte) ((x1 / 2) & 0xff);
if (is_little_endian) if (is_little_endian)
{ {
b[line_count * bpl + x + x1 + 0] = pattern_lo; b[line_count * bpl + x + x1 + 0] = pattern_lo;
@ -366,7 +367,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
pattern_size = 16; pattern_size = 16;
pattern_distance = 0; pattern_distance = 0;
lines = 2 * (pattern_size + pattern_distance); lines = 2 * (pattern_size + pattern_distance);
b_size = lines * bpl; b_size = (size_t) lines * (size_t) bpl;
if (buffer_size) if (buffer_size)
*buffer_size = b_size; *buffer_size = b_size;
@ -379,7 +380,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if (buffer) if (buffer)
*buffer = b; *buffer = b;
DBG (3, "(child) init_picture_buffer: drawing color lineart test " DBG (3, "(child) init_picture_buffer: drawing color lineart test "
"picture %d bytes, %d bpl, %d lines\n", b_size, bpl, lines); "picture %zu bytes, %d bpl, %d lines\n", b_size, bpl, lines);
memset (b, 0x55, b_size); memset (b, 0x55, b_size);
for (line_count = 0; line_count < lines; line_count++) for (line_count = 0; line_count < lines; line_count++)
@ -433,7 +434,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
pattern_size = 16; pattern_size = 16;
pattern_distance = 0; pattern_distance = 0;
lines = 2 * (pattern_size + pattern_distance); lines = 2 * (pattern_size + pattern_distance);
b_size = lines * bpl; b_size = (size_t) lines * (size_t) bpl;
if (buffer_size) if (buffer_size)
*buffer_size = b_size; *buffer_size = b_size;
@ -446,7 +447,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if (buffer) if (buffer)
*buffer = b; *buffer = b;
DBG (3, "(child) init_picture_buffer: drawing color lineart three-pass " DBG (3, "(child) init_picture_buffer: drawing color lineart three-pass "
"test picture %d bytes, %d bpl, %d lines\n", b_size, bpl, lines); "test picture %zu bytes, %d bpl, %d lines\n", b_size, bpl, lines);
memset (b, 0x55, b_size); memset (b, 0x55, b_size);
for (line_count = 0; line_count < lines; line_count++) for (line_count = 0; line_count < lines; line_count++)
@ -501,7 +502,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
pattern_size = 4; pattern_size = 4;
pattern_distance = 1; pattern_distance = 1;
lines = 6 * (pattern_size + pattern_distance); lines = 6 * (pattern_size + pattern_distance);
b_size = lines * bpl; b_size = (size_t) lines * (size_t) bpl;
if (buffer_size) if (buffer_size)
*buffer_size = b_size; *buffer_size = b_size;
@ -514,7 +515,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if (buffer) if (buffer)
*buffer = b; *buffer = b;
DBG (3, "(child) init_picture_buffer: drawing 8 bit color test picture " DBG (3, "(child) init_picture_buffer: drawing 8 bit color test picture "
"%d bytes, %d bpl, %d lines\n", b_size, bpl, lines); "%zu bytes, %d bpl, %d lines\n", b_size, bpl, lines);
memset (b, 0x55, b_size); memset (b, 0x55, b_size);
for (line_count = 0; line_count < lines; line_count++) for (line_count = 0; line_count < lines; line_count++)
{ {
@ -536,10 +537,10 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if ((line_count / (pattern_size + pattern_distance)) & 1) if ((line_count / (pattern_size + pattern_distance)) & 1)
color = color =
0xff - ((x / ((pattern_size + pattern_distance) * 3)) (SANE_Byte) (0xff - ((x / ((pattern_size + pattern_distance) * 3))
& 0xff); & 0xff));
else else
color = (x / ((pattern_size + pattern_distance) * 3)) & 0xff; color = (SANE_Byte) ((x / ((pattern_size + pattern_distance) * 3)) & 0xff);
if (line_count / (pattern_size + pattern_distance) < 2) if (line_count / (pattern_size + pattern_distance) < 2)
{ {
@ -581,7 +582,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
pattern_size = 4; pattern_size = 4;
pattern_distance = 1; pattern_distance = 1;
lines = 6 * (pattern_size + pattern_distance); lines = 6 * (pattern_size + pattern_distance);
b_size = lines * bpl; b_size = (size_t) lines * (size_t) bpl;
if (buffer_size) if (buffer_size)
*buffer_size = b_size; *buffer_size = b_size;
@ -594,7 +595,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if (buffer) if (buffer)
*buffer = b; *buffer = b;
DBG (3, "(child) init_picture_buffer: drawing 8 bit color three-pass " DBG (3, "(child) init_picture_buffer: drawing 8 bit color three-pass "
"test picture %d bytes, %d bpl, %d lines\n", b_size, bpl, lines); "test picture %zu bytes, %d bpl, %d lines\n", b_size, bpl, lines);
memset (b, 0x55, b_size); memset (b, 0x55, b_size);
for (line_count = 0; line_count < lines; line_count++) for (line_count = 0; line_count < lines; line_count++)
{ {
@ -614,10 +615,10 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
width = bpl - x; width = bpl - x;
if ((line_count / (pattern_size + pattern_distance)) & 1) if ((line_count / (pattern_size + pattern_distance)) & 1)
color = color = (SANE_Byte)
0xff - (x / ((pattern_size + pattern_distance)) & 0xff); (0xff - (x / ((pattern_size + pattern_distance)) & 0xff));
else else
color = (x / (pattern_size + pattern_distance)) & 0xff; color = (SANE_Byte) ((x / (pattern_size + pattern_distance)) & 0xff);
if (line_count / (pattern_size + pattern_distance) < 2) if (line_count / (pattern_size + pattern_distance) < 2)
{ {
@ -634,7 +635,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if (test_device->params.format != SANE_FRAME_BLUE) if (test_device->params.format != SANE_FRAME_BLUE)
color = 0x00; color = 0x00;
} }
memset (b + line_count * bpl + x, color, width); memset (b + line_count * bpl + x, color, (size_t) width);
x += (pattern_size + pattern_distance); x += (pattern_size + pattern_distance);
} }
@ -647,7 +648,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
pattern_size = 256; pattern_size = 256;
pattern_distance = 4; pattern_distance = 4;
lines = pattern_size + pattern_distance; lines = pattern_size + pattern_distance;
b_size = lines * bpl; b_size = (size_t) lines * (size_t) bpl;
if (buffer_size) if (buffer_size)
*buffer_size = b_size; *buffer_size = b_size;
@ -661,7 +662,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
*buffer = b; *buffer = b;
DBG (3, DBG (3,
"(child) init_picture_buffer: drawing 16 bit color test picture " "(child) init_picture_buffer: drawing 16 bit color test picture "
"%d bytes, %d bpl, %d lines\n", b_size, bpl, lines); "%zu bytes, %d bpl, %d lines\n", b_size, bpl, lines);
memset (b, 0x55, b_size); memset (b, 0x55, b_size);
for (line_count = 0; line_count < lines; line_count++) for (line_count = 0; line_count < lines; line_count++)
{ {
@ -687,10 +688,10 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
for (x1 = 0; x1 < width; x1 += 6) for (x1 = 0; x1 < width; x1 += 6)
{ {
color_lo = color_lo = (SANE_Byte)
((line_count + pattern_size) (((line_count + pattern_size)
% (pattern_size + pattern_distance)) & 0xff; % (pattern_size + pattern_distance)) & 0xff);
color_hi = (x1 / 6) & 0xff; color_hi = (SANE_Byte) ((x1 / 6) & 0xff);
if (((x / ((pattern_size + pattern_distance) * 6)) % 3) == if (((x / ((pattern_size + pattern_distance) * 6)) % 3) ==
0) 0)
{ {
@ -753,7 +754,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
pattern_size = 256; pattern_size = 256;
pattern_distance = 4; pattern_distance = 4;
lines = pattern_size + pattern_distance; lines = pattern_size + pattern_distance;
b_size = lines * bpl; b_size = (size_t) lines * (size_t) bpl;
if (buffer_size) if (buffer_size)
*buffer_size = b_size; *buffer_size = b_size;
@ -766,7 +767,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if (buffer) if (buffer)
*buffer = b; *buffer = b;
DBG (3, "(child) init_picture_buffer: drawing 16 bit color three-pass " DBG (3, "(child) init_picture_buffer: drawing 16 bit color three-pass "
"test picture %d bytes, %d bpl, %d lines\n", b_size, bpl, lines); "test picture %zu bytes, %d bpl, %d lines\n", b_size, bpl, lines);
memset (b, 0x55, b_size); memset (b, 0x55, b_size);
for (line_count = 0; line_count < lines; line_count++) for (line_count = 0; line_count < lines; line_count++)
{ {
@ -789,10 +790,10 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
for (x1 = 0; x1 < width; x1 += 2) for (x1 = 0; x1 < width; x1 += 2)
{ {
color_lo = color_lo = (SANE_Byte)
((line_count + pattern_size) (((line_count + pattern_size)
% (pattern_size + pattern_distance)) & 0xff; % (pattern_size + pattern_distance)) & 0xff);
color_hi = (x1 / 2) & 0xff; color_hi = (SANE_Byte) ((x1 / 2) & 0xff);
if (((x / ((pattern_size + pattern_distance) * 2)) % 3) == if (((x / ((pattern_size + pattern_distance) * 2)) % 3) ==
0) 0)
{ {

Wyświetl plik

@ -391,11 +391,11 @@ init_options (Test_Device * test_device)
od->desc = SANE_DESC_SCAN_MODE; od->desc = SANE_DESC_SCAN_MODE;
od->type = SANE_TYPE_STRING; od->type = SANE_TYPE_STRING;
od->unit = SANE_UNIT_NONE; od->unit = SANE_UNIT_NONE;
od->size = max_string_size (mode_list); od->size = (SANE_Int) max_string_size (mode_list);
od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
od->constraint_type = SANE_CONSTRAINT_STRING_LIST; od->constraint_type = SANE_CONSTRAINT_STRING_LIST;
od->constraint.string_list = mode_list; od->constraint.string_list = mode_list;
test_device->val[opt_mode].s = malloc (od->size); test_device->val[opt_mode].s = malloc ((size_t) od->size);
if (!test_device->val[opt_mode].s) if (!test_device->val[opt_mode].s)
goto fail; goto fail;
strcpy (test_device->val[opt_mode].s, init_mode); strcpy (test_device->val[opt_mode].s, init_mode);
@ -454,7 +454,7 @@ init_options (Test_Device * test_device)
od->desc = SANE_I18N ("Set the order of frames in three-pass color mode."); od->desc = SANE_I18N ("Set the order of frames in three-pass color mode.");
od->type = SANE_TYPE_STRING; od->type = SANE_TYPE_STRING;
od->unit = SANE_UNIT_NONE; od->unit = SANE_UNIT_NONE;
od->size = max_string_size (order_list); od->size = (SANE_Int) max_string_size (order_list);
od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
if (strcmp (init_mode, SANE_VALUE_SCAN_MODE_COLOR) != 0) if (strcmp (init_mode, SANE_VALUE_SCAN_MODE_COLOR) != 0)
od->cap |= SANE_CAP_INACTIVE; od->cap |= SANE_CAP_INACTIVE;
@ -462,7 +462,7 @@ init_options (Test_Device * test_device)
od->cap |= SANE_CAP_INACTIVE; od->cap |= SANE_CAP_INACTIVE;
od->constraint_type = SANE_CONSTRAINT_STRING_LIST; od->constraint_type = SANE_CONSTRAINT_STRING_LIST;
od->constraint.string_list = order_list; od->constraint.string_list = order_list;
test_device->val[opt_three_pass_order].s = malloc (od->size); test_device->val[opt_three_pass_order].s = malloc ((size_t) od->size);
if (!test_device->val[opt_three_pass_order].s) if (!test_device->val[opt_three_pass_order].s)
goto fail; goto fail;
strcpy (test_device->val[opt_three_pass_order].s, init_three_pass_order); strcpy (test_device->val[opt_three_pass_order].s, init_three_pass_order);
@ -487,11 +487,11 @@ init_options (Test_Device * test_device)
od->desc = SANE_I18N("If Automatic Document Feeder is selected, the feeder will be 'empty' after 10 scans."); od->desc = SANE_I18N("If Automatic Document Feeder is selected, the feeder will be 'empty' after 10 scans.");
od->type = SANE_TYPE_STRING; od->type = SANE_TYPE_STRING;
od->unit = SANE_UNIT_NONE; od->unit = SANE_UNIT_NONE;
od->size = max_string_size (source_list); od->size = (SANE_Int) max_string_size (source_list);
od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
od->constraint_type = SANE_CONSTRAINT_STRING_LIST; od->constraint_type = SANE_CONSTRAINT_STRING_LIST;
od->constraint.string_list = source_list; od->constraint.string_list = source_list;
test_device->val[opt_scan_source].s = malloc (od->size); test_device->val[opt_scan_source].s = malloc ((size_t) od->size);
if (!test_device->val[opt_scan_source].s) if (!test_device->val[opt_scan_source].s)
goto fail; goto fail;
strcpy (test_device->val[opt_scan_source].s, init_scan_source); strcpy (test_device->val[opt_scan_source].s, init_scan_source);
@ -523,11 +523,11 @@ init_options (Test_Device * test_device)
"height of 10 mm per square."); "height of 10 mm per square.");
od->type = SANE_TYPE_STRING; od->type = SANE_TYPE_STRING;
od->unit = SANE_UNIT_NONE; od->unit = SANE_UNIT_NONE;
od->size = max_string_size (test_picture_list); od->size = (SANE_Int) max_string_size (test_picture_list);
od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
od->constraint_type = SANE_CONSTRAINT_STRING_LIST; od->constraint_type = SANE_CONSTRAINT_STRING_LIST;
od->constraint.string_list = test_picture_list; od->constraint.string_list = test_picture_list;
test_device->val[opt_test_picture].s = malloc (od->size); test_device->val[opt_test_picture].s = malloc ((size_t) od->size);
if (!test_device->val[opt_test_picture].s) if (!test_device->val[opt_test_picture].s)
goto fail; goto fail;
strcpy (test_device->val[opt_test_picture].s, init_test_picture); strcpy (test_device->val[opt_test_picture].s, init_test_picture);
@ -618,11 +618,11 @@ init_options (Test_Device * test_device)
"codes are for testing how the frontend handles them."); "codes are for testing how the frontend handles them.");
od->type = SANE_TYPE_STRING; od->type = SANE_TYPE_STRING;
od->unit = SANE_UNIT_NONE; od->unit = SANE_UNIT_NONE;
od->size = max_string_size (read_status_code_list); od->size = (SANE_Int) max_string_size (read_status_code_list);
od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
od->constraint_type = SANE_CONSTRAINT_STRING_LIST; od->constraint_type = SANE_CONSTRAINT_STRING_LIST;
od->constraint.string_list = read_status_code_list; od->constraint.string_list = read_status_code_list;
test_device->val[opt_read_status_code].s = malloc (od->size); test_device->val[opt_read_status_code].s = malloc ((size_t) od->size);
if (!test_device->val[opt_read_status_code].s) if (!test_device->val[opt_read_status_code].s)
goto fail; goto fail;
strcpy (test_device->val[opt_read_status_code].s, init_read_status_code); strcpy (test_device->val[opt_read_status_code].s, init_read_status_code);
@ -1167,13 +1167,13 @@ init_options (Test_Device * test_device)
od->desc = SANE_I18N ("(1/3) String test option without constraint."); od->desc = SANE_I18N ("(1/3) String test option without constraint.");
od->type = SANE_TYPE_STRING; od->type = SANE_TYPE_STRING;
od->unit = SANE_UNIT_NONE; od->unit = SANE_UNIT_NONE;
od->size = strlen (init_string) + 1; od->size = (SANE_Int) strlen (init_string) + 1;
od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
if (init_enable_test_options == SANE_FALSE) if (init_enable_test_options == SANE_FALSE)
od->cap |= SANE_CAP_INACTIVE; od->cap |= SANE_CAP_INACTIVE;
od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint_type = SANE_CONSTRAINT_NONE;
od->constraint.string_list = 0; od->constraint.string_list = 0;
test_device->val[opt_string].s = malloc (od->size); test_device->val[opt_string].s = malloc ((size_t) od->size);
if (!test_device->val[opt_string].s) if (!test_device->val[opt_string].s)
goto fail; goto fail;
strcpy (test_device->val[opt_string].s, init_string); strcpy (test_device->val[opt_string].s, init_string);
@ -1186,13 +1186,13 @@ init_options (Test_Device * test_device)
"constraint."); "constraint.");
od->type = SANE_TYPE_STRING; od->type = SANE_TYPE_STRING;
od->unit = SANE_UNIT_NONE; od->unit = SANE_UNIT_NONE;
od->size = max_string_size (string_constraint_string_list); od->size = (SANE_Int) max_string_size (string_constraint_string_list);
od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
if (init_enable_test_options == SANE_FALSE) if (init_enable_test_options == SANE_FALSE)
od->cap |= SANE_CAP_INACTIVE; od->cap |= SANE_CAP_INACTIVE;
od->constraint_type = SANE_CONSTRAINT_STRING_LIST; od->constraint_type = SANE_CONSTRAINT_STRING_LIST;
od->constraint.string_list = string_constraint_string_list; od->constraint.string_list = string_constraint_string_list;
test_device->val[opt_string_constraint_string_list].s = malloc (od->size); test_device->val[opt_string_constraint_string_list].s = malloc ((size_t) od->size);
if (!test_device->val[opt_string_constraint_string_list].s) if (!test_device->val[opt_string_constraint_string_list].s)
goto fail; goto fail;
strcpy (test_device->val[opt_string_constraint_string_list].s, strcpy (test_device->val[opt_string_constraint_string_list].s,
@ -1206,14 +1206,14 @@ init_options (Test_Device * test_device)
"constraint. Contains some more entries..."); "constraint. Contains some more entries...");
od->type = SANE_TYPE_STRING; od->type = SANE_TYPE_STRING;
od->unit = SANE_UNIT_NONE; od->unit = SANE_UNIT_NONE;
od->size = max_string_size (string_constraint_long_string_list); od->size = (SANE_Int) max_string_size (string_constraint_long_string_list);
od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT;
if (init_enable_test_options == SANE_FALSE) if (init_enable_test_options == SANE_FALSE)
od->cap |= SANE_CAP_INACTIVE; od->cap |= SANE_CAP_INACTIVE;
od->constraint_type = SANE_CONSTRAINT_STRING_LIST; od->constraint_type = SANE_CONSTRAINT_STRING_LIST;
od->constraint.string_list = string_constraint_long_string_list; od->constraint.string_list = string_constraint_long_string_list;
test_device->val[opt_string_constraint_long_string_list].s = test_device->val[opt_string_constraint_long_string_list].s =
malloc (od->size); malloc ((size_t) od->size);
if (!test_device->val[opt_string_constraint_long_string_list].s) if (!test_device->val[opt_string_constraint_long_string_list].s)
goto fail; goto fail;
strcpy (test_device->val[opt_string_constraint_long_string_list].s, strcpy (test_device->val[opt_string_constraint_long_string_list].s,
@ -1436,7 +1436,8 @@ static SANE_Status
reader_process (Test_Device * test_device, SANE_Int fd) reader_process (Test_Device * test_device, SANE_Int fd)
{ {
SANE_Status status; SANE_Status status;
SANE_Word byte_count = 0, bytes_total; size_t byte_count = 0;
size_t bytes_total;
SANE_Byte *buffer = 0; SANE_Byte *buffer = 0;
ssize_t bytes_written = 0; ssize_t bytes_written = 0;
size_t buffer_size = 0, write_count = 0; size_t buffer_size = 0, write_count = 0;
@ -1444,7 +1445,7 @@ reader_process (Test_Device * test_device, SANE_Int fd)
DBG (2, "(child) reader_process: test_device=%p, fd=%d\n", DBG (2, "(child) reader_process: test_device=%p, fd=%d\n",
(void *) test_device, fd); (void *) test_device, fd);
bytes_total = test_device->lines * test_device->bytes_per_line; bytes_total = (size_t) test_device->lines * (size_t) test_device->bytes_per_line;
status = init_picture_buffer (test_device, &buffer, &buffer_size); status = init_picture_buffer (test_device, &buffer, &buffer_size);
if (status != SANE_STATUS_GOOD) if (status != SANE_STATUS_GOOD)
return status; return status;
@ -1457,11 +1458,11 @@ reader_process (Test_Device * test_device, SANE_Int fd)
if (write_count == 0) if (write_count == 0)
{ {
write_count = buffer_size; write_count = buffer_size;
if (byte_count + (SANE_Word) write_count > bytes_total) if (byte_count + (size_t) write_count > bytes_total)
write_count = bytes_total - byte_count; write_count = (size_t) bytes_total - (size_t) byte_count;
if (test_device->val[opt_read_delay].w == SANE_TRUE) if (test_device->val[opt_read_delay].w == SANE_TRUE)
usleep (test_device->val[opt_read_delay_duration].w); usleep ((__useconds_t) test_device->val[opt_read_delay_duration].w);
} }
bytes_written = write (fd, buffer, write_count); bytes_written = write (fd, buffer, write_count);
if (bytes_written < 0) if (bytes_written < 0)
@ -1470,17 +1471,17 @@ reader_process (Test_Device * test_device, SANE_Int fd)
strerror (errno)); strerror (errno));
return SANE_STATUS_IO_ERROR; return SANE_STATUS_IO_ERROR;
} }
byte_count += bytes_written; byte_count += (size_t) bytes_written;
DBG (4, "(child) reader_process: wrote %ld bytes of %lu (%d total)\n", DBG (4, "(child) reader_process: wrote %ld bytes of %lu (%zu total)\n",
(long) bytes_written, (u_long) write_count, byte_count); bytes_written, write_count, byte_count);
write_count -= bytes_written; write_count -= (size_t) bytes_written;
} }
free (buffer); free (buffer);
if (sanei_thread_is_forked ()) if (sanei_thread_is_forked ())
{ {
DBG (4, "(child) reader_process: finished, wrote %d bytes, expected %d " DBG (4, "(child) reader_process: finished, wrote %zu bytes, expected %zu "
"bytes, now waiting\n", byte_count, bytes_total); "bytes, now waiting\n", byte_count, bytes_total);
while (SANE_TRUE) while (SANE_TRUE)
sleep (10); sleep (10);
@ -1489,7 +1490,7 @@ reader_process (Test_Device * test_device, SANE_Int fd)
} }
else else
{ {
DBG (4, "(child) reader_process: finished, wrote %d bytes, expected %d " DBG (4, "(child) reader_process: finished, wrote %zu bytes, expected %zu "
"bytes\n", byte_count, bytes_total); "bytes\n", byte_count, bytes_total);
} }
return SANE_STATUS_GOOD; return SANE_STATUS_GOOD;
@ -1841,7 +1842,7 @@ sane_init (SANE_Int * __sane_unused__ version_code, SANE_Auth_Callback __sane_un
/* create devices */ /* create devices */
sane_device_list = sane_device_list =
malloc ((init_number_of_devices + 1) * sizeof (sane_device)); malloc ((size_t) (init_number_of_devices + 1) * sizeof (sane_device));
if (!sane_device_list) if (!sane_device_list)
goto fail; goto fail;
for (num = 0; num < init_number_of_devices; num++) for (num = 0; num < init_number_of_devices; num++)
@ -1879,7 +1880,7 @@ sane_init (SANE_Int * __sane_unused__ version_code, SANE_Auth_Callback __sane_un
} }
test_device->next = 0; test_device->next = 0;
sane_device_list[num] = 0; sane_device_list[num] = 0;
srand (time (NULL)); srand ((unsigned int) time (NULL));
random_factor = ((double) rand ()) / RAND_MAX + 0.5; random_factor = ((double) rand ()) / RAND_MAX + 0.5;
inited = SANE_TRUE; inited = SANE_TRUE;
return SANE_STATUS_GOOD; return SANE_STATUS_GOOD;
@ -2342,7 +2343,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action,
case opt_gamma_all: case opt_gamma_all:
case opt_int_array_constraint_word_list: case opt_int_array_constraint_word_list:
memcpy (test_device->val[option].wa, value, memcpy (test_device->val[option].wa, value,
test_device->opt[option].size); (size_t) test_device->opt[option].size);
DBG (4, "sane_control_option: set option %d (%s) to %p\n", DBG (4, "sane_control_option: set option %d (%s) to %p\n",
option, test_device->opt[option].name, (void *) value); option, test_device->opt[option].name, (void *) value);
if (option == opt_gamma_all) { if (option == opt_gamma_all) {
@ -2580,7 +2581,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action,
case opt_gamma_all: case opt_gamma_all:
case opt_int_array_constraint_word_list: case opt_int_array_constraint_word_list:
memcpy (value, test_device->val[option].wa, memcpy (value, test_device->val[option].wa,
test_device->opt[option].size); (size_t) test_device->opt[option].size);
DBG (4, "sane_control_option: get option %d (%s), value=%p\n", DBG (4, "sane_control_option: get option %d (%s), value=%p\n",
option, test_device->opt[option].name, (void *) value); option, test_device->opt[option].name, (void *) value);
break; break;
@ -2670,7 +2671,7 @@ sane_get_parameters (SANE_Handle handle, SANE_Parameters * params)
p->lines = test_device->lines; p->lines = test_device->lines;
if (test_device->val[opt_fuzzy_parameters].w == SANE_TRUE if (test_device->val[opt_fuzzy_parameters].w == SANE_TRUE
&& test_device->scanning == SANE_FALSE) && test_device->scanning == SANE_FALSE)
p->lines *= random_factor; p->lines *= (SANE_Int) random_factor;
} }
if (strcmp (mode, SANE_VALUE_SCAN_MODE_GRAY) == 0) if (strcmp (mode, SANE_VALUE_SCAN_MODE_GRAY) == 0)
@ -2705,7 +2706,7 @@ sane_get_parameters (SANE_Handle handle, SANE_Parameters * params)
p->pixels_per_line = (SANE_Int) (res * (br_x - tl_x) / MM_PER_INCH); p->pixels_per_line = (SANE_Int) (res * (br_x - tl_x) / MM_PER_INCH);
if (test_device->val[opt_fuzzy_parameters].w == SANE_TRUE if (test_device->val[opt_fuzzy_parameters].w == SANE_TRUE
&& test_device->scanning == SANE_FALSE) && test_device->scanning == SANE_FALSE)
p->pixels_per_line *= random_factor; p->pixels_per_line *= (SANE_Int) random_factor;
if (p->pixels_per_line < 1) if (p->pixels_per_line < 1)
p->pixels_per_line = 1; p->pixels_per_line = 1;
@ -2873,7 +2874,7 @@ sane_read (SANE_Handle handle, SANE_Byte * data,
SANE_Int max_scan_length; SANE_Int max_scan_length;
ssize_t bytes_read; ssize_t bytes_read;
size_t read_count; size_t read_count;
SANE_Int bytes_total = test_device->lines * test_device->bytes_per_line; size_t bytes_total = (size_t) test_device->lines * (size_t) test_device->bytes_per_line;
DBG (4, "sane_read: handle=%p, data=%p, max_length = %d, length=%p\n", DBG (4, "sane_read: handle=%p, data=%p, max_length = %d, length=%p\n",
@ -2958,11 +2959,11 @@ sane_read (SANE_Handle handle, SANE_Byte * data,
DBG (1, "sane_read: not scanning (call sane_start first)\n"); DBG (1, "sane_read: not scanning (call sane_start first)\n");
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
read_count = max_scan_length; read_count = (size_t) max_scan_length;
bytes_read = read (test_device->pipe, data, read_count); bytes_read = read (test_device->pipe, data, read_count);
if (bytes_read == 0 if (bytes_read == 0
|| (bytes_read + test_device->bytes_total >= bytes_total)) || ((size_t) bytes_read + (size_t) test_device->bytes_total >= bytes_total))
{ {
SANE_Status status; SANE_Status status;
DBG (2, "sane_read: EOF reached\n"); DBG (2, "sane_read: EOF reached\n");
@ -2997,11 +2998,11 @@ sane_read (SANE_Handle handle, SANE_Byte * data,
return SANE_STATUS_IO_ERROR; return SANE_STATUS_IO_ERROR;
} }
} }
*length = bytes_read; *length = (SANE_Int) bytes_read;
test_device->bytes_total += bytes_read; test_device->bytes_total += (size_t) bytes_read;
DBG (2, "sane_read: read %ld bytes of %d, total %d\n", (long) bytes_read, DBG (2, "sane_read: read %zu bytes of %zu, total %zu\n", (size_t) bytes_read,
max_scan_length, test_device->bytes_total); (size_t) max_scan_length, (size_t) test_device->bytes_total);
return SANE_STATUS_GOOD; return SANE_STATUS_GOOD;
} }
@ -3082,6 +3083,7 @@ sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking)
} }
else else
{ {
DBG (1, "sane_set_io_mode: unsupported\n");
if (non_blocking) if (non_blocking)
return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_UNSUPPORTED;
} }
@ -3120,5 +3122,6 @@ sane_get_select_fd (SANE_Handle handle, SANE_Int * fd)
*fd = test_device->pipe; *fd = test_device->pipe;
return SANE_STATUS_GOOD; return SANE_STATUS_GOOD;
} }
DBG(1,"sane_get_select_fd: unsupported\n");
return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_UNSUPPORTED;
} }

Wyświetl plik

@ -137,7 +137,7 @@ typedef struct Test_Device
SANE_Word bytes_per_line; SANE_Word bytes_per_line;
SANE_Word pixels_per_line; SANE_Word pixels_per_line;
SANE_Word lines; SANE_Word lines;
SANE_Int bytes_total; size_t bytes_total;
SANE_Bool open; SANE_Bool open;
SANE_Bool scanning; SANE_Bool scanning;
SANE_Bool cancelled; SANE_Bool cancelled;