diff options
author | Julian Smith <jules@op59.net> | 2020-01-08 13:02:35 +0000 |
---|---|---|
committer | Julian Smith <jules@op59.net> | 2020-01-08 16:10:07 +0000 |
commit | 3b727b709f40d6b93e874680ab307aa124de5422 (patch) | |
tree | 0ed749452fcce30896f5a41c620af2f234f8cb5d /contrib | |
parent | 4e4edd2161b4b7f3ccb23a90a8ca90dccffd078c (diff) | |
download | ghostpdl-3b727b709f40d6b93e874680ab307aa124de5422.tar.gz |
Coverity 94729: oki4w_print_page()'s compress_code is always 2.
Simplified code accordingly, and removed static fn oki_compress() as no longer
referenced.
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/gdevop4w.c | 86 |
1 files changed, 3 insertions, 83 deletions
diff --git a/contrib/gdevop4w.c b/contrib/gdevop4w.c index 1167c7c73..a92f6e63b 100644 --- a/contrib/gdevop4w.c +++ b/contrib/gdevop4w.c @@ -154,79 +154,6 @@ oki4w_close(gx_device *pdev) /* ------ Internal routines ------ */ -static int -oki_compress(byte *src, byte *dst, int count) -{ - int dcnt = 0; - byte lastval = *src; - int run = 1; - src++; - count--; - while (count-- > 0) { - byte newval = *src++; - if (newval == lastval) { - run++; - } else { - /* end of run, flush data */ - if (run == 1) { - byte *backptr = dst++; - *dst++ = lastval; - dcnt++; - lastval = newval; - while (run < 128 && count > 0) { - run++; - newval = *src++; - *dst++ = newval; - dcnt++; - count--; - if (newval == lastval) { - break; - } - } - if (newval == lastval) { - run--; - dst--; - dcnt--; - } - *backptr = dst - backptr - 2; - if (newval == lastval) { - run = 2; - } else { - run = 1; - } - continue; - } - while (run > 128) { - *dst++ = 0x81; - *dst++ = lastval; - run -= 128; - dcnt += 2; - } - if (run > 0) { - *dst++ = (0x101 - run) & 0xff; - *dst++ = lastval; - dcnt += 2; - } - lastval = newval; - run = 1; - } - } - /* end of run, flush data */ - while (run > 128) { - *dst++ = 0x81; - *dst++ = lastval; - run -= 128; - dcnt += 2; - } - if (run > 0) { - *dst++ = (0x101 - run) & 0xff; - *dst++ = lastval; - dcnt += 2; - } - - return dcnt; -} - /* Send the page to the printer. For speed, compress each scan line, */ /* since computer-to-printer communication time is often a bottleneck. */ static int @@ -266,14 +193,12 @@ oki4w_print_page(gx_device_printer *pdev, gp_file *prn_stream) if (y_dpi == 150) { dpi_code = 3; - compress_code = 2; } else if (y_dpi == 300) { dpi_code = 5; - compress_code = 2; } else { dpi_code = 7; - compress_code = 2; } + compress_code = 2; /* Initialize printer. */ /* if ( pdev->PageCount == 0 ) { */ @@ -334,13 +259,8 @@ oki4w_print_page(gx_device_printer *pdev, gp_file *prn_stream) num_blank_lines = 0; /* Compress the data */ - if (compress_code == 6) { - out_count = oki_compress(data, out_data, - (end_data - data_words) * W); - } else { - out_count = gdev_pcl_mode2compress(data_words, - end_data, out_data); - } + out_count = gdev_pcl_mode2compress(data_words, + end_data, out_data); /* Transfer the data */ for (i = 0; i < y_dots_per_pixel; ++i) { |