enable test backend to scan high res images

251-scanner-canon-mf110-910-series-is-not-supported
Christian Theis 2022-05-29 20:52:51 +01:00
rodzic 39f9083deb
commit 1aead16faf
3 zmienionych plików z 94 dodań i 90 usunięć

Wyświetl plik

@ -48,7 +48,8 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
size_t * buffer_size)
{
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 bpl = test_device->bytes_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)
{
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
&& test_device->params.depth == 1)
pattern = 0xff;
@ -93,7 +94,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
else
{
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
&& test_device->params.depth == 1)
pattern = 0x00;
@ -115,8 +116,8 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if (test_device->params.depth == 16)
increment *= 2;
lines = 2 * p_size + 0.5;
b_size = lines * bpl;
lines = (SANE_Word) (2 * p_size + 0.5);
b_size = (size_t) lines * (size_t) bpl;
if (buffer_size)
*buffer_size = b_size;
b = malloc (b_size);
@ -128,7 +129,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if (buffer)
*buffer = b;
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++)
{
@ -161,7 +162,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
}
else
color = (rand ()) & 0x01;
value |= (color << x1);
value |= (SANE_Byte) (color << x1);
}
b[line_count * bpl + x] = value;
}
@ -182,7 +183,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
}
else
color = (rand ()) & 0x01;
value |= (color << x1);
value |= (SANE_Byte) (color << x1);
}
for (x1 = 0; x1 < increment; x1++)
b[line_count * bpl + x + x1] = value;
@ -197,7 +198,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
else
color = 0xff;
else
color = (rand ()) & 0xff;
color = (SANE_Byte) ((rand ()) & 0xff);
for (x1 = 0; x1 < increment; x1++)
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_distance = 0;
lines = 2 * (pattern_size + pattern_distance);
b_size = lines * bpl;
b_size = (size_t) lines * (size_t) bpl;
if (buffer_size)
*buffer_size = b_size;
@ -228,7 +229,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if (buffer)
*buffer = b;
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);
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;
if (x + width >= bpl)
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;
}
}
@ -256,7 +257,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
pattern_size = 4;
pattern_distance = 1;
lines = 2 * (pattern_size + pattern_distance);
b_size = lines * bpl;
b_size = (size_t) lines * (size_t) bpl;
if (buffer_size)
*buffer_size = b_size;
@ -269,7 +270,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if (buffer)
*buffer = b;
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);
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;
if (line_count > (pattern_size + pattern_distance))
color =
0xff - ((x / (pattern_size + pattern_distance)) & 0xff);
(SANE_Byte) (0xff - ((x / (pattern_size + pattern_distance)) & 0xff));
else
color = (x / (pattern_size + pattern_distance)) & 0xff;
memset (b + line_count * bpl + x, color, width);
color = (SANE_Byte) ((x / (pattern_size + pattern_distance)) & 0xff);
memset (b + line_count * bpl + x, color, (size_t) width);
x += (pattern_size + pattern_distance);
}
}
@ -305,7 +306,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
pattern_size = 256;
pattern_distance = 4;
lines = 1 * (pattern_size + pattern_distance);
b_size = lines * bpl;
b_size = (size_t) lines * (size_t) bpl;
if (buffer_size)
*buffer_size = b_size;
@ -318,7 +319,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if (buffer)
*buffer = b;
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);
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)
width = bpl - x;
pattern_lo =
((line_count - pattern_distance)
% (pattern_size + pattern_distance)) & 0xff;
(SANE_Byte) (((line_count - pattern_distance)
% (pattern_size + pattern_distance)) & 0xff);
for (x1 = 0; x1 < width; x1 += 2)
{
pattern_hi = (x1 / 2) & 0xff;
pattern_hi = (SANE_Byte) ((x1 / 2) & 0xff);
if (is_little_endian)
{
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_distance = 0;
lines = 2 * (pattern_size + pattern_distance);
b_size = lines * bpl;
b_size = (size_t) lines * (size_t) bpl;
if (buffer_size)
*buffer_size = b_size;
@ -379,7 +380,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if (buffer)
*buffer = b;
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);
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_distance = 0;
lines = 2 * (pattern_size + pattern_distance);
b_size = lines * bpl;
b_size = (size_t) lines * (size_t) bpl;
if (buffer_size)
*buffer_size = b_size;
@ -446,7 +447,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if (buffer)
*buffer = b;
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);
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_distance = 1;
lines = 6 * (pattern_size + pattern_distance);
b_size = lines * bpl;
b_size = (size_t) lines * (size_t) bpl;
if (buffer_size)
*buffer_size = b_size;
@ -514,7 +515,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if (buffer)
*buffer = b;
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);
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)
color =
0xff - ((x / ((pattern_size + pattern_distance) * 3))
& 0xff);
(SANE_Byte) (0xff - ((x / ((pattern_size + pattern_distance) * 3))
& 0xff));
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)
{
@ -581,7 +582,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
pattern_size = 4;
pattern_distance = 1;
lines = 6 * (pattern_size + pattern_distance);
b_size = lines * bpl;
b_size = (size_t) lines * (size_t) bpl;
if (buffer_size)
*buffer_size = b_size;
@ -594,7 +595,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if (buffer)
*buffer = b;
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);
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;
if ((line_count / (pattern_size + pattern_distance)) & 1)
color =
0xff - (x / ((pattern_size + pattern_distance)) & 0xff);
color = (SANE_Byte)
(0xff - (x / ((pattern_size + pattern_distance)) & 0xff));
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)
{
@ -634,7 +635,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if (test_device->params.format != SANE_FRAME_BLUE)
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);
}
@ -647,7 +648,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
pattern_size = 256;
pattern_distance = 4;
lines = pattern_size + pattern_distance;
b_size = lines * bpl;
b_size = (size_t) lines * (size_t) bpl;
if (buffer_size)
*buffer_size = b_size;
@ -661,7 +662,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
*buffer = b;
DBG (3,
"(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);
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)
{
color_lo =
((line_count + pattern_size)
% (pattern_size + pattern_distance)) & 0xff;
color_hi = (x1 / 6) & 0xff;
color_lo = (SANE_Byte)
(((line_count + pattern_size)
% (pattern_size + pattern_distance)) & 0xff);
color_hi = (SANE_Byte) ((x1 / 6) & 0xff);
if (((x / ((pattern_size + pattern_distance) * 6)) % 3) ==
0)
{
@ -753,7 +754,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
pattern_size = 256;
pattern_distance = 4;
lines = pattern_size + pattern_distance;
b_size = lines * bpl;
b_size = (size_t) lines * (size_t) bpl;
if (buffer_size)
*buffer_size = b_size;
@ -766,7 +767,7 @@ init_picture_buffer (Test_Device * test_device, SANE_Byte ** buffer,
if (buffer)
*buffer = b;
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);
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)
{
color_lo =
((line_count + pattern_size)
% (pattern_size + pattern_distance)) & 0xff;
color_hi = (x1 / 2) & 0xff;
color_lo = (SANE_Byte)
(((line_count + pattern_size)
% (pattern_size + pattern_distance)) & 0xff);
color_hi = (SANE_Byte) ((x1 / 2) & 0xff);
if (((x / ((pattern_size + pattern_distance) * 2)) % 3) ==
0)
{

Wyświetl plik

@ -391,11 +391,11 @@ init_options (Test_Device * test_device)
od->desc = SANE_DESC_SCAN_MODE;
od->type = SANE_TYPE_STRING;
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->constraint_type = SANE_CONSTRAINT_STRING_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)
goto fail;
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->type = SANE_TYPE_STRING;
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;
if (strcmp (init_mode, SANE_VALUE_SCAN_MODE_COLOR) != 0)
od->cap |= SANE_CAP_INACTIVE;
@ -462,7 +462,7 @@ init_options (Test_Device * test_device)
od->cap |= SANE_CAP_INACTIVE;
od->constraint_type = SANE_CONSTRAINT_STRING_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)
goto fail;
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->type = SANE_TYPE_STRING;
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->constraint_type = SANE_CONSTRAINT_STRING_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)
goto fail;
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.");
od->type = SANE_TYPE_STRING;
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->constraint_type = SANE_CONSTRAINT_STRING_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)
goto fail;
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.");
od->type = SANE_TYPE_STRING;
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->constraint_type = SANE_CONSTRAINT_STRING_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)
goto fail;
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->type = SANE_TYPE_STRING;
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;
if (init_enable_test_options == SANE_FALSE)
od->cap |= SANE_CAP_INACTIVE;
od->constraint_type = SANE_CONSTRAINT_NONE;
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)
goto fail;
strcpy (test_device->val[opt_string].s, init_string);
@ -1186,13 +1186,13 @@ init_options (Test_Device * test_device)
"constraint.");
od->type = SANE_TYPE_STRING;
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;
if (init_enable_test_options == SANE_FALSE)
od->cap |= SANE_CAP_INACTIVE;
od->constraint_type = SANE_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)
goto fail;
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...");
od->type = SANE_TYPE_STRING;
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;
if (init_enable_test_options == SANE_FALSE)
od->cap |= SANE_CAP_INACTIVE;
od->constraint_type = SANE_CONSTRAINT_STRING_LIST;
od->constraint.string_list = string_constraint_long_string_list;
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)
goto fail;
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)
{
SANE_Status status;
SANE_Word byte_count = 0, bytes_total;
size_t byte_count = 0;
size_t bytes_total;
SANE_Byte *buffer = 0;
ssize_t bytes_written = 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",
(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);
if (status != SANE_STATUS_GOOD)
return status;
@ -1457,11 +1458,11 @@ reader_process (Test_Device * test_device, SANE_Int fd)
if (write_count == 0)
{
write_count = buffer_size;
if (byte_count + (SANE_Word) write_count > bytes_total)
write_count = bytes_total - byte_count;
if (byte_count + (size_t) write_count > bytes_total)
write_count = (size_t) bytes_total - (size_t) byte_count;
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);
if (bytes_written < 0)
@ -1470,17 +1471,17 @@ reader_process (Test_Device * test_device, SANE_Int fd)
strerror (errno));
return SANE_STATUS_IO_ERROR;
}
byte_count += bytes_written;
DBG (4, "(child) reader_process: wrote %ld bytes of %lu (%d total)\n",
(long) bytes_written, (u_long) write_count, byte_count);
write_count -= bytes_written;
byte_count += (size_t) bytes_written;
DBG (4, "(child) reader_process: wrote %ld bytes of %lu (%zu total)\n",
bytes_written, write_count, byte_count);
write_count -= (size_t) bytes_written;
}
free (buffer);
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);
while (SANE_TRUE)
sleep (10);
@ -1489,7 +1490,7 @@ reader_process (Test_Device * test_device, SANE_Int fd)
}
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);
}
return SANE_STATUS_GOOD;
@ -1841,7 +1842,7 @@ sane_init (SANE_Int * __sane_unused__ version_code, SANE_Auth_Callback __sane_un
/* create devices */
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)
goto fail;
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;
sane_device_list[num] = 0;
srand (time (NULL));
srand ((unsigned int) time (NULL));
random_factor = ((double) rand ()) / RAND_MAX + 0.5;
inited = SANE_TRUE;
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_int_array_constraint_word_list:
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",
option, test_device->opt[option].name, (void *) value);
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_int_array_constraint_word_list:
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",
option, test_device->opt[option].name, (void *) value);
break;
@ -2670,7 +2671,7 @@ sane_get_parameters (SANE_Handle handle, SANE_Parameters * params)
p->lines = test_device->lines;
if (test_device->val[opt_fuzzy_parameters].w == SANE_TRUE
&& test_device->scanning == SANE_FALSE)
p->lines *= random_factor;
p->lines *= (SANE_Int) random_factor;
}
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);
if (test_device->val[opt_fuzzy_parameters].w == SANE_TRUE
&& 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)
p->pixels_per_line = 1;
@ -2873,7 +2874,7 @@ sane_read (SANE_Handle handle, SANE_Byte * data,
SANE_Int max_scan_length;
ssize_t bytes_read;
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",
@ -2958,11 +2959,11 @@ sane_read (SANE_Handle handle, SANE_Byte * data,
DBG (1, "sane_read: not scanning (call sane_start first)\n");
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);
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;
DBG (2, "sane_read: EOF reached\n");
@ -2997,11 +2998,11 @@ sane_read (SANE_Handle handle, SANE_Byte * data,
return SANE_STATUS_IO_ERROR;
}
}
*length = bytes_read;
test_device->bytes_total += bytes_read;
*length = (SANE_Int) 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,
max_scan_length, test_device->bytes_total);
DBG (2, "sane_read: read %zu bytes of %zu, total %zu\n", (size_t) bytes_read,
(size_t) max_scan_length, (size_t) test_device->bytes_total);
return SANE_STATUS_GOOD;
}
@ -3082,6 +3083,7 @@ sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking)
}
else
{
DBG (1, "sane_set_io_mode: unsupported\n");
if (non_blocking)
return SANE_STATUS_UNSUPPORTED;
}
@ -3120,5 +3122,6 @@ sane_get_select_fd (SANE_Handle handle, SANE_Int * fd)
*fd = test_device->pipe;
return SANE_STATUS_GOOD;
}
DBG(1,"sane_get_select_fd: unsupported\n");
return SANE_STATUS_UNSUPPORTED;
}

Wyświetl plik

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