More fixes for sonarcloud findings
This commit is contained in:
@@ -110,7 +110,6 @@ png_write_gray(char *fn, int inv, uint8_t *pix, int16_t w, int16_t h)
|
||||
png_structp png = NULL;
|
||||
png_infop info = NULL;
|
||||
png_bytep row;
|
||||
int16_t x, y;
|
||||
FILE *fp;
|
||||
|
||||
/* Create the image file. */
|
||||
@@ -127,7 +126,7 @@ error:
|
||||
(&png, &info);
|
||||
if (fp != NULL)
|
||||
(void) fclose(fp);
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Initialize PNG stuff. */
|
||||
@@ -159,8 +158,8 @@ error:
|
||||
row = (png_bytep) malloc(PNGFUNC(get_rowbytes)(png, info));
|
||||
|
||||
/* Process all scanlines in the image. */
|
||||
for (y = 0; y < h; y++) {
|
||||
for (x = 0; x < w; x++) {
|
||||
for (int16_t y = 0; y < h; y++) {
|
||||
for (int16_t x = 0; x < w; x++) {
|
||||
/* Copy the pixel data. */
|
||||
if (inv)
|
||||
row[x] = 255 - pix[(y * w) + x];
|
||||
@@ -185,7 +184,7 @@ error:
|
||||
/* Clean up. */
|
||||
(void) fclose(fp);
|
||||
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Write the given BITMAP-format image as an 8-bit RGBA PNG image file. */
|
||||
|
||||
@@ -442,7 +442,6 @@ static void
|
||||
fill_palette(uint8_t redmax, uint8_t greenmax, uint8_t bluemax, uint8_t colorID, escp_t *dev)
|
||||
{
|
||||
uint8_t colormask;
|
||||
int i;
|
||||
|
||||
double red = (double) redmax / (double) 30.9;
|
||||
double green = (double) greenmax / (double) 30.9;
|
||||
@@ -450,7 +449,7 @@ fill_palette(uint8_t redmax, uint8_t greenmax, uint8_t bluemax, uint8_t colorID,
|
||||
|
||||
colormask = colorID <<= 5;
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
for (uint8_t i = 0; i < 32; i++) {
|
||||
dev->palcol[i + colormask].r = 255 - (uint8_t) floor(red * (double) i);
|
||||
dev->palcol[i + colormask].g = 255 - (uint8_t) floor(green * (double) i);
|
||||
dev->palcol[i + colormask].b = 255 - (uint8_t) floor(blue * (double) i);
|
||||
@@ -460,8 +459,6 @@ fill_palette(uint8_t redmax, uint8_t greenmax, uint8_t bluemax, uint8_t colorID,
|
||||
static void
|
||||
reset_printer(escp_t *dev)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* TODO: these should be configurable. */
|
||||
dev->color = COLOR_BLACK;
|
||||
dev->curr_x = dev->curr_y = 0.0;
|
||||
@@ -501,7 +498,7 @@ reset_printer(escp_t *dev)
|
||||
|
||||
new_page(dev, 0, 1);
|
||||
|
||||
for (i = 0; i < 32; i++)
|
||||
for (uint8_t i = 0; i < 32; i++)
|
||||
dev->horizontal_tabs[i] = i * 8.0 * (1.0 / dev->cpi);
|
||||
dev->num_horizontal_tabs = 32;
|
||||
dev->num_vertical_tabs = -1;
|
||||
@@ -646,11 +643,13 @@ update_font(escp_t *dev)
|
||||
static int
|
||||
process_char(escp_t *dev, uint8_t ch)
|
||||
{
|
||||
double new_x, new_y;
|
||||
double new_x;
|
||||
double new_y;
|
||||
double move_to;
|
||||
double unit_size;
|
||||
double reverse;
|
||||
double new_top, new_bottom;
|
||||
double new_top;
|
||||
double new_bottom;
|
||||
uint16_t rel_move;
|
||||
int16_t i;
|
||||
|
||||
@@ -1573,8 +1572,10 @@ static void
|
||||
handle_char(escp_t *dev, uint8_t ch)
|
||||
{
|
||||
FT_UInt char_index;
|
||||
uint16_t pen_x, pen_y;
|
||||
uint16_t line_start, line_y;
|
||||
uint16_t pen_x;
|
||||
uint16_t pen_y;
|
||||
uint16_t line_start;
|
||||
uint16_t line_y;
|
||||
double x_advance;
|
||||
|
||||
if (dev->page == NULL)
|
||||
@@ -1689,15 +1690,15 @@ static void
|
||||
blit_glyph(escp_t *dev, unsigned destx, unsigned desty, int8_t add)
|
||||
{
|
||||
FT_Bitmap *bitmap = &dev->fontface->glyph->bitmap;
|
||||
unsigned x, y;
|
||||
uint8_t src, *dst;
|
||||
uint8_t src;
|
||||
uint8_t *dst;
|
||||
|
||||
/* check if freetype is available */
|
||||
if (ft_lib == NULL)
|
||||
return;
|
||||
|
||||
for (y = 0; y < bitmap->rows; y++) {
|
||||
for (x = 0; x < bitmap->width; x++) {
|
||||
for (unsigned int y = 0; y < bitmap->rows; y++) {
|
||||
for (unsigned int x = 0; x < bitmap->width; x++) {
|
||||
src = *(bitmap->buffer + x + y * bitmap->pitch);
|
||||
/* ignore background, and respect page size */
|
||||
if (src > 0 && (destx + x < (unsigned) dev->page->w) && (desty + y < (unsigned) dev->page->h)) {
|
||||
@@ -1724,9 +1725,8 @@ draw_hline(escp_t *dev, unsigned from_x, unsigned to_x, unsigned y, int8_t broke
|
||||
{
|
||||
unsigned breakmod = dev->dpi / 15;
|
||||
unsigned gapstart = (breakmod * 4) / 5;
|
||||
unsigned x;
|
||||
|
||||
for (x = from_x; x <= to_x; x++) {
|
||||
for (unsigned int x = from_x; x <= to_x; x++) {
|
||||
/* Skip parts if broken line or going over the border. */
|
||||
if ((!broken || (x % breakmod <= gapstart)) && (x < dev->page->w)) {
|
||||
if (y > 0 && (y - 1) < dev->page->h)
|
||||
@@ -1856,7 +1856,6 @@ print_bit_graph(escp_t *dev, uint8_t ch)
|
||||
{
|
||||
uint8_t pixel_w; /* width of the "pixel" */
|
||||
uint8_t pixel_h; /* height of the "pixel" */
|
||||
unsigned i, j, xx, yy;
|
||||
double old_y;
|
||||
|
||||
dev->bg_column[dev->bg_bytes_read++] = ch;
|
||||
@@ -1877,14 +1876,14 @@ print_bit_graph(escp_t *dev, uint8_t ch)
|
||||
pixel_h = dev->dpi / dev->bg_v_density > 0 ? dev->dpi / dev->bg_v_density : 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < dev->bg_bytes_per_column; i++) {
|
||||
for (uint8_t i = 0; i < dev->bg_bytes_per_column; i++) {
|
||||
/* for each byte */
|
||||
for (j = 128; j != 0; j >>= 1) {
|
||||
for (uint8_t j = 128; j != 0; j >>= 1) {
|
||||
/* for each bit */
|
||||
if (dev->bg_column[i] & j) {
|
||||
/* draw a "pixel" */
|
||||
for (xx = 0; xx < pixel_w; xx++) {
|
||||
for (yy = 0; yy < pixel_h; yy++) {
|
||||
for (uint8_t xx = 0; xx < pixel_w; xx++) {
|
||||
for (uint8_t yy = 0; yy < pixel_h; yy++) {
|
||||
if (((PIXX + xx) < (unsigned) dev->page->w) && ((PIXY + yy) < (unsigned) dev->page->h))
|
||||
*((uint8_t *) dev->page->pixels + (PIXX + xx) + (PIXY + yy) * dev->page->pitch) |= (dev->color | 0x1f);
|
||||
}
|
||||
@@ -1983,7 +1982,7 @@ read_status(void *priv)
|
||||
if (!dev->ack)
|
||||
ret |= 0x40;
|
||||
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void *
|
||||
@@ -1991,7 +1990,6 @@ escp_init(void *lpt)
|
||||
{
|
||||
const char *fn = PATH_FREETYPE_DLL;
|
||||
escp_t *dev;
|
||||
int i;
|
||||
|
||||
/* Dynamically load FreeType. */
|
||||
if (ft_handle == NULL) {
|
||||
@@ -2047,7 +2045,7 @@ escp_init(void *lpt)
|
||||
memset(dev->page->pixels, 0x00, (size_t) dev->page->pitch * dev->page->h);
|
||||
|
||||
/* Initialize parameters. */
|
||||
for (i = 0; i < 32; i++) {
|
||||
for (uint8_t i = 0; i < 32; i++) {
|
||||
dev->palcol[i].r = 255;
|
||||
dev->palcol[i].g = 255;
|
||||
dev->palcol[i].b = 255;
|
||||
@@ -2082,7 +2080,7 @@ escp_init(void *lpt)
|
||||
timer_add(&dev->pulse_timer, pulse_timer, dev, 0);
|
||||
timer_add(&dev->timeout_timer, timeout_timer, dev, 0);
|
||||
|
||||
return (dev);
|
||||
return dev;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -143,7 +143,9 @@ convert_to_pdf(ps_t *dev)
|
||||
{
|
||||
volatile int code;
|
||||
void *instance = NULL;
|
||||
char input_fn[1024], output_fn[1024], *gsargv[9];
|
||||
char input_fn[1024];
|
||||
char output_fn[1024];
|
||||
char *gsargv[9];
|
||||
|
||||
strcpy(input_fn, dev->printer_path);
|
||||
path_slash(input_fn);
|
||||
@@ -323,7 +325,7 @@ ps_read_status(void *p)
|
||||
if (!dev->ack)
|
||||
ret |= 0x40;
|
||||
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void *
|
||||
@@ -362,7 +364,7 @@ ps_init(void *lpt)
|
||||
|
||||
reset_ps(dev);
|
||||
|
||||
return (dev);
|
||||
return dev;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -138,7 +138,6 @@ static void
|
||||
dump_page(prnt_t *dev)
|
||||
{
|
||||
char path[1024];
|
||||
uint16_t x, y;
|
||||
uint8_t ch;
|
||||
FILE *fp;
|
||||
|
||||
@@ -162,8 +161,8 @@ dump_page(prnt_t *dev)
|
||||
if (ftell(fp) != 0)
|
||||
fputc('\014', fp);
|
||||
|
||||
for (y = 0; y < dev->curr_y; y++) {
|
||||
for (x = 0; x < dev->page->w; x++) {
|
||||
for (uint16_t y = 0; y < dev->curr_y; y++) {
|
||||
for (uint16_t x = 0; x < dev->page->w; x++) {
|
||||
ch = dev->page->chars[(y * dev->page->w) + x];
|
||||
if (ch == 0x00) {
|
||||
/* End of line marker. */
|
||||
@@ -329,7 +328,7 @@ process_char(prnt_t *dev, uint8_t ch)
|
||||
}
|
||||
|
||||
/* Just a printable character. */
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -416,7 +415,7 @@ read_status(void *priv)
|
||||
if (!dev->ack)
|
||||
ret |= 0x40;
|
||||
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void *
|
||||
@@ -443,7 +442,7 @@ prnt_init(void *lpt)
|
||||
timer_add(&dev->pulse_timer, pulse_timer, dev, 0);
|
||||
timer_add(&dev->timeout_timer, timeout_timer, dev, 0);
|
||||
|
||||
return (dev);
|
||||
return dev;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user