misc: misc fixes to make cppcheck & clang-analyze happier

Most of these are CONSTifying arguments, but there are some memory leaks too
This commit is contained in:
Solomon Peachy 2023-11-01 14:11:58 -04:00
parent c3fba776c4
commit f1c2004666
19 changed files with 107 additions and 103 deletions

View file

@ -48,11 +48,11 @@ struct printer_data {
int8_t pgcode_offset; /* Offset into printjob for paper type */
int8_t paper_code_offset; /* Offset in readback for paper type */
int8_t paper_code_offset2; /* Offset in readback for paper type (2nd) */
uint8_t (*error_detect)(uint8_t *rdbuf);
const char *(*pgcode_names)(uint8_t *rdbuf, struct printer_data *printer, int *numtype);
uint8_t (*error_detect)(const uint8_t *rdbuf);
const char *(*pgcode_names)(const uint8_t *rdbuf, const struct printer_data *printer, int *numtype);
};
static const char *generic_pgcode_names(uint8_t *rdbuf, struct printer_data *printer, int *numtype)
static const char *generic_pgcode_names(const uint8_t *rdbuf, const struct printer_data *printer, int *numtype)
{
uint8_t pgcode = 0, pgcode2 = 0;
@ -73,7 +73,7 @@ static const char *generic_pgcode_names(uint8_t *rdbuf, struct printer_data *pri
}
}
static uint8_t es1_error_detect(uint8_t *rdbuf)
static uint8_t es1_error_detect(const uint8_t *rdbuf)
{
if (rdbuf[1] == 0x01) {
if (rdbuf[9] == 0x00)
@ -93,7 +93,7 @@ static uint8_t es1_error_detect(uint8_t *rdbuf)
return CUPS_BACKEND_OK;
}
static uint8_t es2_error_detect(uint8_t *rdbuf)
static uint8_t es2_error_detect(const uint8_t *rdbuf)
{
if (rdbuf[0] == 0x16 &&
rdbuf[1] == 0x01) {
@ -117,7 +117,7 @@ static uint8_t es2_error_detect(uint8_t *rdbuf)
return CUPS_BACKEND_OK;
}
static uint8_t es3_error_detect(uint8_t *rdbuf)
static uint8_t es3_error_detect(const uint8_t *rdbuf)
{
if (rdbuf[8] == 0x01) {
if (rdbuf[10] == 0x0f)
@ -151,7 +151,7 @@ static uint8_t es3_error_detect(uint8_t *rdbuf)
return CUPS_BACKEND_OK;
}
static uint8_t es40_error_detect(uint8_t *rdbuf)
static uint8_t es40_error_detect(const uint8_t *rdbuf)
{
/* ES40 */
if (!rdbuf[3])
@ -167,7 +167,7 @@ static uint8_t es40_error_detect(uint8_t *rdbuf)
return 1;
}
static const char *cp790_pgcode_names(uint8_t *rdbuf, struct printer_data *printer, int *numtype)
static const char *cp790_pgcode_names(const uint8_t *rdbuf, const struct printer_data *printer, int *numtype)
{
UNUSED(printer);
UNUSED(numtype);
@ -182,7 +182,7 @@ static const char *cp790_pgcode_names(uint8_t *rdbuf, struct printer_data *print
}
}
static uint8_t cp790_error_detect(uint8_t *rdbuf)
static uint8_t cp790_error_detect(const uint8_t *rdbuf)
{
/* CP790 */
if (rdbuf[5] == 0xff) {
@ -208,7 +208,7 @@ static uint8_t cp790_error_detect(uint8_t *rdbuf)
return CUPS_BACKEND_OK;
}
static const char *cp10_pgcode_names(uint8_t *rdbuf, struct printer_data *printer, int *numtype)
static const char *cp10_pgcode_names(const uint8_t *rdbuf, const struct printer_data *printer, int *numtype)
{
UNUSED(rdbuf);
UNUSED(printer);
@ -217,7 +217,7 @@ static const char *cp10_pgcode_names(uint8_t *rdbuf, struct printer_data *printe
return "C"; /* Printer only supports one media type */
}
static uint8_t cp10_error_detect(uint8_t *rdbuf)
static uint8_t cp10_error_detect(const uint8_t *rdbuf)
{
if (!rdbuf[2])
return CUPS_BACKEND_OK;
@ -233,7 +233,7 @@ static uint8_t cp10_error_detect(uint8_t *rdbuf)
return 1;
}
static uint8_t cpxxx_error_detect(uint8_t *rdbuf)
static uint8_t cpxxx_error_detect(const uint8_t *rdbuf)
{
if (!rdbuf[2])
return CUPS_BACKEND_OK;

View file

@ -1096,7 +1096,7 @@ void print_help(const char *argv0, const struct dyesub_backend *backend)
libusb_free_device_list(list, 1);
}
static int parse_cmdstream(struct dyesub_backend *backend, void *backend_ctx, int fd)
static int parse_cmdstream(const struct dyesub_backend *backend, void *backend_ctx, int fd)
{
FILE *fp = stdin;
char line[128];
@ -1137,7 +1137,7 @@ static int parse_cmdstream(struct dyesub_backend *backend, void *backend_ctx, in
}
static int handle_input(struct dyesub_backend *backend, void *backend_ctx,
const char *fname, char *uri, char *type)
const char *fname, const char *uri, const char *type)
{
int ret = CUPS_BACKEND_OK;
int i;

View file

@ -694,8 +694,8 @@ static const char *dnpds40_statuses(int status)
}
static int dnpds40_do_cmd(struct dnpds40_ctx *ctx,
struct dnpds40_cmd *cmd,
uint8_t *data, int len)
const struct dnpds40_cmd *cmd,
const uint8_t *data, int len)
{
int ret;
@ -1576,6 +1576,7 @@ static int dnpds40_read_parse(void *vctx, const void **vjob, int data_fd, int co
if (job->datalen + sizeof(struct dnpds40_cmd) > MAX_PRINTJOB_LEN) {
ERROR("Buffer overflow when parsing printjob! (%d+%lu)\n",
job->datalen, sizeof(struct dnpds40_cmd));
dnpds40_cleanup_job(job);
return CUPS_BACKEND_CANCEL;
}
@ -3322,7 +3323,7 @@ static int dnpds620_iserial_mode(struct dnpds40_ctx *ctx, int enable)
return CUPS_BACKEND_OK;
}
static int dnpds40_set_counter_p(struct dnpds40_ctx *ctx, char *arg)
static int dnpds40_set_counter_p(struct dnpds40_ctx *ctx, const char *arg)
{
struct dnpds40_cmd cmd;
char msg[9];

View file

@ -633,7 +633,7 @@ static int hiti_query_serno(struct dyesub_connection *conn, char *buf, int buf_l
static int hiti_read_heattable_v2(struct hiti_ctx *ctx, const char* fname);
static void *hiti_find_heattable_v2_entry(struct hiti_ctx *ctx, int id, size_t *len);
static int hiti_docmd(struct hiti_ctx *ctx, uint16_t cmdid, uint8_t *buf, uint16_t buf_len, uint16_t *rsplen)
static int hiti_docmd(struct hiti_ctx *ctx, uint16_t cmdid, const uint8_t *buf, uint16_t buf_len, uint16_t *rsplen)
{
uint8_t cmdbuf[2048];
struct hiti_cmd *cmd = (struct hiti_cmd *)cmdbuf;
@ -725,7 +725,7 @@ static int hiti_docmd_resp(struct hiti_ctx *ctx, uint16_t cmdid,
return CUPS_BACKEND_OK;
}
static int hiti_shptc(struct hiti_ctx *ctx, uint8_t *buf, uint16_t buf_len)
static int hiti_shptc(struct hiti_ctx *ctx, const uint8_t *buf, uint16_t buf_len)
{
uint8_t cmdbuf[sizeof(struct hiti_cmd)];
struct hiti_cmd *cmd = (struct hiti_cmd *)cmdbuf;
@ -807,7 +807,7 @@ static int hiti_sepd(struct hiti_ctx *ctx, uint32_t buf_len,
#define STATUS2_DEVSERVICE 0x04
#define STATUS2_OPERATOR 0x08
static const char *hiti_status(uint8_t *sts)
static const char *hiti_status(const uint8_t *sts)
{
if (sts[2] & STATUS2_WARNING)
return "Warning";
@ -1769,7 +1769,7 @@ static int hiti_seht2(struct hiti_ctx *ctx, uint8_t plane,
// XXX check resp length?
/* Send payload, if any */
if (buf_len && !ret) {
if (buf_len) {
ret = send_data(ctx->conn, buf, buf_len);
}
@ -1778,7 +1778,7 @@ static int hiti_seht2(struct hiti_ctx *ctx, uint8_t plane,
return ret;
}
static int hiti_cvd(struct hiti_ctx *ctx, uint8_t *buf, uint32_t buf_len)
static int hiti_cvd(struct hiti_ctx *ctx, const uint8_t *buf, uint32_t buf_len)
{
uint8_t cmdbuf[sizeof(struct hiti_cmd)];
struct hiti_cmd *cmd = (struct hiti_cmd *)cmdbuf;
@ -1804,7 +1804,7 @@ static int hiti_cvd(struct hiti_ctx *ctx, uint8_t *buf, uint32_t buf_len)
// XXX check resp length?
/* Send payload, if any */
if (buf_len && !ret) {
if (buf_len) {
ret = send_data(ctx->conn, buf, buf_len);
}
@ -2193,7 +2193,7 @@ static void hiti_interp_init(void)
}
/* src and dst are RGB tuples */
static void hiti_interp33_256(uint8_t *dst, uint8_t *src, const uint8_t *pTable)
static void hiti_interp33_256(uint8_t *dst, const uint8_t *src, const uint8_t *pTable)
{
struct rgb p1_pos, p2_pos, p3_pos, p4_pos;
struct rgb p1_val, p2_val, p3_val, p4_val;
@ -2782,25 +2782,23 @@ static int hiti_main_loop(void *vctx, const void *vjob, int wait_for_return)
if (ret)
return CUPS_BACKEND_FAILED;
if (fname) {
uint32_t ver_maj = -1;
uint32_t ver_min = -1;
uint32_t ver_maj = -1;
uint32_t ver_min = -1;
void *dat;
size_t len;
void *dat;
size_t len;
dat = hiti_find_heattable_v2_entry(ctx, HEATTABLE_V2_ID_VER_MAJOR, &len);
if (dat) {
memcpy(&ver_maj, dat, sizeof(ver_maj));
ver_maj = le32_to_cpu(ver_maj);
}
dat = hiti_find_heattable_v2_entry(ctx, HEATTABLE_V2_ID_VER_MINOR, &len);
if (dat) {
memcpy(&ver_min, dat, sizeof(ver_min));
ver_min = le32_to_cpu(ver_min);
}
INFO("Heattable file '%s' version %08x.%08x\n", fname, ver_maj, ver_min);
dat = hiti_find_heattable_v2_entry(ctx, HEATTABLE_V2_ID_VER_MAJOR, &len);
if (dat) {
memcpy(&ver_maj, dat, sizeof(ver_maj));
ver_maj = le32_to_cpu(ver_maj);
}
dat = hiti_find_heattable_v2_entry(ctx, HEATTABLE_V2_ID_VER_MINOR, &len);
if (dat) {
memcpy(&ver_min, dat, sizeof(ver_min));
ver_min = le32_to_cpu(ver_min);
}
INFO("Heattable file '%s' version %08x.%08x\n", fname, ver_maj, ver_min);
// XXX send CMD_ESD_SHPTC (Heating Parameters & Tone Curve, ~7KB payload) instead?
}
}

View file

@ -107,7 +107,7 @@ struct kodak6800_ctx {
/* Baseline commands */
static int kodak6800_do_cmd(struct kodak6800_ctx *ctx,
void *cmd, int cmd_len,
const void *cmd, int cmd_len,
void *resp, int resp_len,
int *actual_len)
{

View file

@ -723,6 +723,7 @@ static int magicard_read_parse(void *vctx, const void **vjob, int data_fd, int c
if (job->datalen + remain > MAX_PRINTJOB_LEN) {
ERROR("Buffer overflow when parsing printjob! (%d+%d)\n",
job->datalen, remain);
magicard_cleanup_job(job);
return CUPS_BACKEND_CANCEL;
}

View file

@ -339,7 +339,7 @@ static int mitsu70x_main_loop(void *vctx, const void *vjob, int wait_for_return)
/* Error dumps, etc */
static const char *mitsu70x_mechastatus(uint8_t *sts)
static const char *mitsu70x_mechastatus(const uint8_t *sts)
{
switch(sts[0]) {
case MECHA_STATUS_INIT:
@ -359,7 +359,7 @@ static const char *mitsu70x_mechastatus(uint8_t *sts)
return "Unknown Mechanical Status";
}
static const char *mitsu70x_jobstatuses(uint8_t *sts)
static const char *mitsu70x_jobstatuses(const uint8_t *sts)
{
switch(sts[0]) {
case JOB_STATUS0_NONE:
@ -446,7 +446,7 @@ static const char *mitsu70x_jobstatuses(uint8_t *sts)
return "Unknown status0";
}
static const char *mitsu70x_errorclass(uint8_t *err)
static const char *mitsu70x_errorclass(const uint8_t *err)
{
switch(err[1]) {
case ERROR_STATUS1_PAPER:
@ -477,7 +477,7 @@ static const char *mitsu70x_errorclass(uint8_t *err)
return "Unknown error class";
}
static const char *mitsu70x_errorrecovery(uint8_t *err)
static const char *mitsu70x_errorrecovery(const uint8_t *err)
{
switch(err[1]) {
case ERROR_STATUS2_AUTO:
@ -508,7 +508,7 @@ static const char *mitsu70x_errorrecovery(uint8_t *err)
return "Unknown recovery";
}
static const char *mitsu70x_errors(uint8_t *err)
static const char *mitsu70x_errors(const uint8_t *err)
{
switch(err[0]) {
case ERROR_STATUS0_NOSTRIPBIN:
@ -1552,7 +1552,7 @@ static int mitsu70x_test_dump(struct mitsu70x_ctx *ctx)
/* response is struct mitsu70x_calinfo_resp */
{
struct mitsu70x_calinfo_resp *calinfo = (struct mitsu70x_calinfo_resp*) resp;
const struct mitsu70x_calinfo_resp *calinfo = (struct mitsu70x_calinfo_resp*) resp;
char buf[5];
float f;

View file

@ -227,9 +227,9 @@ static const char *cp30_media_types(uint16_t remain)
#define READBACK_LEN 128
#define QUERY_STATUS_I \
struct mitsu9550_status *sts = (struct mitsu9550_status*) rdbuf; \
struct mitsucp30_status *sts30 = (struct mitsucp30_status*) rdbuf; \
struct mitsu9550_media *media = (struct mitsu9550_media *) rdbuf; \
const struct mitsu9550_status *sts = (struct mitsu9550_status*) rdbuf; \
const struct mitsucp30_status *sts30 = (struct mitsucp30_status*) rdbuf; \
const struct mitsu9550_media *media = (struct mitsu9550_media *) rdbuf; \
uint16_t donor; \
/* media */ \
ret = mitsu9550_get_status(ctx, rdbuf, CP9XXX_STS_MEDIA); \
@ -484,6 +484,7 @@ top:
if (buf[0] != 0x1b) {
ERROR("Unrecognized cmd sequence (%02x %02x)!\n",
buf[0], buf[1]);
mitsu9550_cleanup_job(job);
return CUPS_BACKEND_CANCEL;
}
switch (buf[1]) {
@ -496,6 +497,7 @@ top:
default:
ERROR("Unrecognized cmd sequence (%02x %02x)!\n",
buf[0], buf[1]);
mitsu9550_cleanup_job(job);
return CUPS_BACKEND_CANCEL;
}
@ -692,11 +694,11 @@ hdr_done:
if (ctx->lut_fname && !job->is_raw && job->hdr2.unkc[9]) {
int ret;
if (ctx->conn->type == P_MITSU_CP30D) {
uint32_t planelen = job->rows * job->cols + sizeof(struct mitsu9550_plane);
uint32_t plen = job->rows * job->cols + sizeof(struct mitsu9550_plane);
ret = mitsu_apply3dlut_plane(&ctx->lib, ctx->lut_fname,
job->databuf + sizeof(struct mitsu9550_plane),
job->databuf + (planelen + sizeof(struct mitsu9550_plane)),
job->databuf + (planelen * 2 + sizeof(struct mitsu9550_plane)),
job->databuf + (plen + sizeof(struct mitsu9550_plane)),
job->databuf + (plen * 2 + sizeof(struct mitsu9550_plane)),
job->cols, job->rows);
} else {
ret = mitsu_apply3dlut_packed(&ctx->lib, ctx->lut_fname,
@ -1491,10 +1493,14 @@ static int mitsu9550_query_statusX(struct mitsu9550_ctx *ctx)
}
#else
ret = mitsu9550_get_status(ctx, (uint8_t*) &resp, CP9XXX_STS_x20);
ret = mitsu9550_get_status(ctx, (uint8_t*) &resp, CP9XXX_STS_FWVER);
ret = mitsu9550_get_status(ctx, (uint8_t*) &resp, CP9XXX_STS_x22);
ret = mitsu9550_get_status(ctx, (uint8_t*) &resp, CP9XXX_STS_x26);
ret = mitsu9550_get_status(ctx, (uint8_t*) &resp, CP9XXX_STS_x32);
if (!ret)
ret = mitsu9550_get_status(ctx, (uint8_t*) &resp, CP9XXX_STS_FWVER);
if (!ret)
ret = mitsu9550_get_status(ctx, (uint8_t*) &resp, CP9XXX_STS_x22);
if (!ret)
ret = mitsu9550_get_status(ctx, (uint8_t*) &resp, CP9XXX_STS_x26);
if (!ret)
ret = mitsu9550_get_status(ctx, (uint8_t*) &resp, CP9XXX_STS_x32);
#endif
return ret;
}

View file

@ -719,8 +719,7 @@ static int mitsud90_query_fwver(struct mitsud90_ctx *ctx)
memcpy(ctx->fwver, resp.fw_ver.version, 6);
ctx->fwver[6] = 0;
return CUPS_BACKEND_OK;
return ret;
}
static int mitsuw5k_get_serno(struct mitsud90_ctx *ctx)
@ -748,7 +747,7 @@ static int mitsuw5k_get_serno(struct mitsud90_ctx *ctx)
memcpy(ctx->serno, cmdbuf + 4, sizeof(cmdbuf)-4);
ctx->serno[sizeof(cmdbuf)-4-1] = 0;
return CUPS_BACKEND_OK;
return ret;
}
@ -870,11 +869,12 @@ static int mitsud90_attach(void *vctx, struct dyesub_connection *conn, uint8_t j
static void mitsud90_teardown(void *vctx) {
struct mitsud90_ctx *ctx = vctx;
if (!ctx)
return;
if (ctx->pano_page) {
WARNING("Panorama state left dangling!\n");
}
if (!ctx)
return;
if (ctx->conn->type == P_MITSU_M1 ||
ctx->conn->type == P_FUJI_ASK500) {

View file

@ -1,7 +1,7 @@
/*
* Shinko/Sinfonia CHC-S1245 CUPS backend -- libusb-1.0 version
*
* (c) 2015-2021 Solomon Peachy <pizza@shaftnet.org>
* (c) 2015-2023 Solomon Peachy <pizza@shaftnet.org>
*
* Low-level documentation was provided by Sinfonia, Inc. Thank you!
*
@ -257,7 +257,7 @@ static void shinkos1245_fill_hdr(struct shinkos1245_cmd_hdr *hdr)
}
static int shinkos1245_do_cmd(struct shinkos1245_ctx *ctx,
void *cmd, int cmd_len,
const void *cmd, int cmd_len,
void *resp, int resp_len,
int *actual_len)
{

View file

@ -1,7 +1,7 @@
/*
* Shinko/Sinfonia CHC-S2145 CUPS backend -- libusb-1.0 version
*
* (c) 2013-2022 Solomon Peachy <pizza@shaftnet.org>
* (c) 2013-2023 Solomon Peachy <pizza@shaftnet.org>
*
* Development of this backend was sponsored by:
*
@ -536,7 +536,7 @@ static int get_user_string(struct shinkos2145_ctx *ctx)
return CUPS_BACKEND_OK;
}
static int set_user_string(struct shinkos2145_ctx *ctx, char *str)
static int set_user_string(struct shinkos2145_ctx *ctx, const char *str)
{
struct s2145_setunique_cmd cmd;
struct sinfonia_status_hdr resp;

View file

@ -1,7 +1,7 @@
/*
* Shinko/Sinfonia CHC-S6145 CUPS backend -- libusb-1.0 version
*
* (c) 2015-2021 Solomon Peachy <pizza@shaftnet.org>
* (c) 2015-2023 Solomon Peachy <pizza@shaftnet.org>
*
* Low-level documentation was provided by Sinfonia. Thank you!
*
@ -765,8 +765,6 @@ static int get_status(struct shinkos6145_ctx *ctx)
val = 60;
else if (val == 4)
val = 120;
else if (val >= 5)
val = 240;
else
val = 240; // default?
@ -793,7 +791,7 @@ static void dump_mediainfo(struct sinfonia_6x45_mediainfo_resp *resp, int is_car
}
}
static int shinkos6145_dump_corrdata(struct shinkos6145_ctx *ctx, char *fname)
static int shinkos6145_dump_corrdata(struct shinkos6145_ctx *ctx, const char *fname)
{
int ret;
@ -827,7 +825,7 @@ static int shinkos6145_dump_corrdata(struct shinkos6145_ctx *ctx, char *fname)
return ret;
}
static int shinkos6145_dump_eeprom(struct shinkos6145_ctx *ctx, char *fname)
static int shinkos6145_dump_eeprom(struct shinkos6145_ctx *ctx, const char *fname)
{
int ret;
@ -1533,7 +1531,7 @@ static int shinkos6145_main_loop(void *vctx, const void *vjob, int wait_for_retu
if (ctx->is_2245) {
struct sinfonia_settime_cmd settime;
time_t now = time(NULL);
struct tm *cur = localtime(&now);
const struct tm *cur = localtime(&now);
memset(&settime, 0, sizeof(settime));
settime.hdr.cmd = cpu_to_le16(SINFONIA_CMD_SETTIME);

View file

@ -1173,7 +1173,7 @@ static int shinkos6245_main_loop(void *vctx, const void *vjob, int wait_for_retu
if (ctx->dev.conn->type != P_KODAK_8810) {
struct sinfonia_settime_cmd *settime = (struct sinfonia_settime_cmd *)cmdbuf;
time_t now = time(NULL);
struct tm *cur = localtime(&now);
const struct tm *cur = localtime(&now);
memset(cmdbuf, 0, CMDBUF_LEN);
cmd->cmd = cpu_to_le16(SINFONIA_CMD_SETTIME);

View file

@ -1,7 +1,7 @@
/*
* Shinko/Sinfonia Common Code
*
* (c) 2019-2021 Solomon Peachy <pizza@shaftnet.org>
* (c) 2019-2023 Solomon Peachy <pizza@shaftnet.org>
*
* The latest version of this program can be found at:
*
@ -460,13 +460,13 @@ void sinfonia_cleanup_job(const void *vjob)
}
int sinfonia_docmd(struct sinfonia_usbdev *usbh,
uint8_t *cmd, int cmdlen,
const uint8_t *cmd, int cmdlen,
uint8_t *resp, int resplen,
int *num)
{
int ret;
struct sinfonia_cmd_hdr *cmdhdr = (struct sinfonia_cmd_hdr *) cmd;
const struct sinfonia_cmd_hdr *cmdhdr = (struct sinfonia_cmd_hdr *) cmd;
struct sinfonia_status_hdr *resphdr = (struct sinfonia_status_hdr *)resp;
if ((ret = send_data(usbh->conn,

View file

@ -1,7 +1,7 @@
/*
* Shinko/Sinfonia Common Code
*
* (c) 2019-2021 Solomon Peachy <pizza@shaftnet.org>
* (c) 2019-2023 Solomon Peachy <pizza@shaftnet.org>
*
* The latest version of this program can be found at:
*
@ -228,7 +228,7 @@ struct sinfonia_usbdev {
char const *(*error_codes)(uint8_t major, uint8_t minor);
};
int sinfonia_docmd(struct sinfonia_usbdev *usbh,
uint8_t *cmd, int cmdlen,
const uint8_t *cmd, int cmdlen,
uint8_t *resp, int resplen,
int *num);
int sinfonia_flashled(struct sinfonia_usbdev *usbh);

View file

@ -405,12 +405,12 @@ static int ndc_read_parse(struct upd_ctx *ctx, struct upd_printjob *job, int dat
switch (job->databuf[job->datalen + 1]) {
case 0xea: { // Data transfer
uint32_t len;
memcpy(&len, job->databuf + job->datalen + 6, sizeof(len));
len = be32_to_cpu(len);
remain = len;
uint32_t datalen;
memcpy(&datalen, job->databuf + job->datalen + 6, sizeof(len));
datalen = be32_to_cpu(datalen);
remain = datalen;
job->datalen += 11;
job->imglen = len;
job->imglen = datalen;
break;
}
default: { // everything else
@ -933,7 +933,7 @@ static int upd_query_markers(void *vctx, struct marker **markers, int *count)
return CUPS_BACKEND_FAILED;
if (ctx->native_bpp != 1 && (ret = sony_get_prints(ctx, &ctx->printbuf))) {
return CUPS_BACKEND_FAILED;
return ret;
}
if (ctx->conn->type == P_SONY_UPD711) {

View file

@ -257,7 +257,7 @@ static int updneo_read_parse(void *vctx, const void **vjob, int data_fd, int cop
}
/* Payload length */
char *tokl = strtok(NULL, "\r\n,");
const char *tokl = strtok(NULL, "\r\n,");
if (!tokl) {
updneo_cleanup_job(job);
ERROR("Invalid spool format (block length missing)!\n");
@ -423,9 +423,9 @@ static int updneo_get_status(struct updneo_ctx *ctx)
strncpy(ctx->sts.scsno, dict[i].val, sizeof(ctx->sts.scsno) - 1);
/* Trim trailing '-'s off of serial number (UP-D898, UP-9x1)*/
for (int i = 0; i < (int) sizeof(ctx->sts.scsno); i++) {
if (ctx->sts.scsno[i] == '-') {
ctx->sts.scsno[i] = 0;
for (int j = 0; j < (int) sizeof(ctx->sts.scsno); j++) {
if (ctx->sts.scsno[j] == '-') {
ctx->sts.scsno[j] = 0;
break;
}
}
@ -698,7 +698,7 @@ static const char *sonyupdneo_prefixes[] = {
const struct dyesub_backend sonyupdneo_backend = {
.name = "Sony UP-D Neo",
.version = "0.18",
.version = "0.19",
.flags = BACKEND_FLAG_BADISERIAL, /* UP-D898MD at least */
.uri_prefixes = sonyupdneo_prefixes,
.cmdline_arg = updneo_cmdline_arg,

View file

@ -2,7 +2,7 @@
libS6145ImageReProcess -- Re-implemented Image Processing library for
the Sinfonia CHC-S6145 printer family
Copyright (c) 2015-2020 Solomon Peachy <pizza@shaftnet.org>
Copyright (c) 2015-2023 Solomon Peachy <pizza@shaftnet.org>
** ** ** ** Do NOT contact Sinfonia about this library! ** ** ** **
@ -41,7 +41,7 @@
//#define S6145_UNUSED
#define LIB_VERSION "0.5.1"
#define LIB_VERSION "0.5.2"
#include <string.h>
#include <stdint.h>
@ -453,8 +453,6 @@ int ImageProcessing(unsigned char *in, unsigned short *out, void *corrdata)
uint8_t i;
struct lib6145_ctx *ctx;
if (!in)
return 1;
if (!out)
@ -473,8 +471,10 @@ int ImageProcessing(unsigned char *in, unsigned short *out, void *corrdata)
ctx->pSPrintParam = (struct imageCorrParam *) corrdata;
i = CheckPrintParam(corrdata);
if (i)
if (i) {
free(ctx);
return i;
}
Global_Init(ctx);
#ifdef S6145_UNUSED

View file

@ -606,8 +606,8 @@ static void CImageEffect70_Sharp_CopyLine(struct CImageEffect70 *data,
memcpy(dst, row -(rownum * data->pixel_count), sizeof(uint16_t) * data->band_pixels);
memcpy(dst - 3, dst, 6); /* Fill in dst row head */
memcpy(end, end - 3, 6); /* Fill in dst row tail */
memcpy(dst - 3, dst, sizeof(*dst)*3); /* Fill in dst row head */
memcpy(end, end - 3, sizeof(*end)*3); /* Fill in dst row tail */
}
static void CImageEffect70_Sharp_PrepareLine(struct CImageEffect70 *data,
@ -792,12 +792,12 @@ static void CImageEffect70_CalcHTD(struct CImageEffect70 *data, const double *in
#endif
/* Fill in shoulders of the row */
memcpy(first - 9, first, 0x18); // Copy first pixel to pre-buffer
memcpy(first - 6, first, 0x18);
memcpy(first - 3, first, 0x18);
memcpy(last + 3, last, 0x18); // Copy last pixel to post-buffer
memcpy(last + 6, last, 0x18);
memcpy(last + 9, last, 0x18);
memcpy(first - 9, first, sizeof(*first)*3); // Copy first pixel to pre-buffer
memcpy(first - 6, first, sizeof(*first)*3);
memcpy(first - 3, first, sizeof(*first)*3);
memcpy(last + 3, last, sizeof(*last)*3); // Copy last pixel to post-buffer
memcpy(last + 6, last, sizeof(*last)*3);
memcpy(last + 9, last, sizeof(*last)*3);
/* Work out the compensation factors for each pixel in the row */
offset = 0;
@ -991,7 +991,7 @@ static void CImageEffect70_CalcSA(struct BandImage *img,
/* Returns 1 for OK, 0 for do NOT rewind! */
static int CImageEffect70_JudgeReverseSkipRibbon_int(struct BandImage *img,
int32_t *REV,
const int32_t *REV,
int invert)
{
int32_t rows, cols;