summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-01-22 11:25:06 -0500
committerSolomon Peachy <pizza@shaftnet.org>2020-01-22 11:25:06 -0500
commit4df8f97225311b4d668993fbee96274777fcaed7 (patch)
treea444db86476ed6bfbf2b5124717c1620ed43be77
parent10b02678e7f66f57ec1dececcd3ba7835588bc2a (diff)
downloadselphy_print-4df8f97225311b4d668993fbee96274777fcaed7.tar.gz
selphy_print-4df8f97225311b4d668993fbee96274777fcaed7.tar.bz2
selphy_print-4df8f97225311b4d668993fbee96274777fcaed7.zip
misc: Correct a small pile of cppcheck/scan-build warnings.
No actual bugs, thankfully.
-rw-r--r--backend_common.h2
-rw-r--r--backend_dnpds40.c12
-rw-r--r--backend_hiti.c23
-rw-r--r--backend_mitsu70x.c2
-rw-r--r--backend_shinkos2145.c16
-rw-r--r--backend_shinkos6145.c15
-rw-r--r--backend_shinkos6245.c15
7 files changed, 43 insertions, 42 deletions
diff --git a/backend_common.h b/backend_common.h
index efdb9e9..fff2a8f 100644
--- a/backend_common.h
+++ b/backend_common.h
@@ -1,7 +1,7 @@
/*
* CUPS Backend common code
*
- * (c) 2013-2019 Solomon Peachy <pizza@shaftnet.org>
+ * (c) 2013-2020 Solomon Peachy <pizza@shaftnet.org>
*
* The latest version of this program can be found at:
*
diff --git a/backend_dnpds40.c b/backend_dnpds40.c
index e4f9ee6..a2cf6e8 100644
--- a/backend_dnpds40.c
+++ b/backend_dnpds40.c
@@ -1,7 +1,7 @@
/*
* Citizen / DNP Photo Printer CUPS backend -- libusb-1.0 version
*
- * (c) 2013-2019 Solomon Peachy <pizza@shaftnet.org>
+ * (c) 2013-2020 Solomon Peachy <pizza@shaftnet.org>
*
* Development of this backend was sponsored by:
*
@@ -876,10 +876,10 @@ static int dnpds40_attach(void *vctx, struct libusb_device_handle *dev, int type
/* Figure out actual Manufacturer */
{
struct libusb_device_descriptor desc;
- struct libusb_device *dev;
+ struct libusb_device *udev;
- dev = libusb_get_device(ctx->dev);
- libusb_get_device_descriptor(dev, &desc);
+ udev = libusb_get_device(ctx->dev);
+ libusb_get_device_descriptor(udev, &desc);
char buf[256];
buf[0] = 0;
@@ -1537,9 +1537,7 @@ parsed:
}
/* Use the larger of the copy arguments */
- if (job->copies > copies)
- copies = job->copies;
- else
+ if (job->copies < copies)
job->copies = copies;
/* Sanity check matte mode */
diff --git a/backend_hiti.c b/backend_hiti.c
index caf07d6..616021c 100644
--- a/backend_hiti.c
+++ b/backend_hiti.c
@@ -1274,7 +1274,7 @@ static int hiti_read_parse(void *vctx, const void **vjob, int data_fd, int copie
{
struct hiti_ctx *ctx = vctx;
struct hiti_printjob *job = NULL;
- int i;
+ int ret;
if (!ctx)
return CUPS_BACKEND_FAILED;
@@ -1289,21 +1289,22 @@ static int hiti_read_parse(void *vctx, const void **vjob, int data_fd, int copie
job->copies = copies;
/* Read in header */
- i = read(data_fd, &job->hdr, sizeof(job->hdr));
- if (i < 0 || i != sizeof(job->hdr)) {
+ ret = read(data_fd, &job->hdr, sizeof(job->hdr));
+ if (ret < 0 || ret != sizeof(job->hdr)) {
hiti_cleanup_job(job);
- if (i == 0)
+ if (ret == 0)
return CUPS_BACKEND_CANCEL;
ERROR("Read failed (%d/%d)\n",
- i, (int)sizeof(job->hdr));
+ ret, (int)sizeof(job->hdr));
perror("ERROR: Read failed");
- return i;
+ return ret;
}
/* Byteswap everything */
{
uint32_t *ptr = (uint32_t*) &job->hdr;
+ int i;
for (i = 0 ; i < (int)(sizeof(job->hdr) / sizeof(uint32_t)) ; i++)
ptr[i] = le32_to_cpu(ptr[i]);
}
@@ -1358,16 +1359,16 @@ static int hiti_read_parse(void *vctx, const void **vjob, int data_fd, int copie
/* Read in data */
uint32_t remain = job->hdr.payload_len;
while (remain) {
- i = read(data_fd, job->databuf + job->datalen, remain);
- if (i < 0) {
+ ret = read(data_fd, job->databuf + job->datalen, remain);
+ if (ret < 0) {
ERROR("Read failed (%d/%u/%u)\n",
- i, remain, job->datalen);
+ ret, remain, job->datalen);
perror("ERROR: Read failed");
hiti_cleanup_job(job);
return CUPS_BACKEND_CANCEL;
}
- job->datalen += i;
- remain -= i;
+ job->datalen += ret;
+ remain -= ret;
}
/* Sanity check against paper */
diff --git a/backend_mitsu70x.c b/backend_mitsu70x.c
index 9d035b1..3ce112a 100644
--- a/backend_mitsu70x.c
+++ b/backend_mitsu70x.c
@@ -1,7 +1,7 @@
/*
* Mitsubishi CP-D70/D707 Photo Printer CUPS backend -- libusb-1.0 version
*
- * (c) 2013-2019 Solomon Peachy <pizza@shaftnet.org>
+ * (c) 2013-2020 Solomon Peachy <pizza@shaftnet.org>
*
* The latest version of this program can be found at:
*
diff --git a/backend_shinkos2145.c b/backend_shinkos2145.c
index 48e5ce3..476cca8 100644
--- a/backend_shinkos2145.c
+++ b/backend_shinkos2145.c
@@ -1,7 +1,7 @@
- /*
+/*
* Shinko/Sinfonia CHC-S2145 CUPS backend -- libusb-1.0 version
*
- * (c) 2013-2019 Solomon Peachy <pizza@shaftnet.org>
+ * (c) 2013-2020 Solomon Peachy <pizza@shaftnet.org>
*
* Development of this backend was sponsored by:
*
@@ -1191,15 +1191,15 @@ static int shinkos2145_query_stats(void *vctx, struct printerstats *stats)
stats->serial = ctx->serial;
{
- struct sinfonia_fwinfo_cmd cmd;
+ struct sinfonia_fwinfo_cmd fcmd;
struct sinfonia_fwinfo_resp resp;
- int num = 0;
- cmd.hdr.cmd = cpu_to_le16(SINFONIA_CMD_FWINFO);
- cmd.hdr.len = cpu_to_le16(1);
- cmd.target = FWINFO_TARGET_MAIN_APP;
+ fcmd.hdr.cmd = cpu_to_le16(SINFONIA_CMD_FWINFO);
+ fcmd.hdr.len = cpu_to_le16(1);
+ fcmd.target = FWINFO_TARGET_MAIN_APP;
+ num = 0;
if (sinfonia_docmd(&ctx->dev,
- (uint8_t*)&cmd, sizeof(cmd),
+ (uint8_t*)&fcmd, sizeof(fcmd),
(uint8_t*)&resp, sizeof(resp),
&num))
return CUPS_BACKEND_FAILED;
diff --git a/backend_shinkos6145.c b/backend_shinkos6145.c
index c193e5d..6a08d10 100644
--- a/backend_shinkos6145.c
+++ b/backend_shinkos6145.c
@@ -1,7 +1,7 @@
/*
* Shinko/Sinfonia CHC-S6145 CUPS backend -- libusb-1.0 version
*
- * (c) 2015-2019 Solomon Peachy <pizza@shaftnet.org>
+ * (c) 2015-2020 Solomon Peachy <pizza@shaftnet.org>
*
* Low-level documentation was provided by Sinfonia. Thank you!
*
@@ -1619,15 +1619,16 @@ static int shinkos6145_query_stats(void *vctx, struct printerstats *stats)
stats->serial = ctx->serial;
{
- struct sinfonia_fwinfo_cmd cmd;
+ struct sinfonia_fwinfo_cmd fcmd;
struct sinfonia_fwinfo_resp resp;
- int num = 0;
- cmd.hdr.cmd = cpu_to_le16(SINFONIA_CMD_FWINFO);
- cmd.hdr.len = cpu_to_le16(1);
- cmd.target = FWINFO_TARGET_MAIN_APP;
+
+ num = 0;
+ fcmd.hdr.cmd = cpu_to_le16(SINFONIA_CMD_FWINFO);
+ fcmd.hdr.len = cpu_to_le16(1);
+ fcmd.target = FWINFO_TARGET_MAIN_APP;
if (sinfonia_docmd(&ctx->dev,
- (uint8_t*)&cmd, sizeof(cmd),
+ (uint8_t*)&fcmd, sizeof(fcmd),
(uint8_t*)&resp, sizeof(resp),
&num))
return CUPS_BACKEND_FAILED;
diff --git a/backend_shinkos6245.c b/backend_shinkos6245.c
index 91427e8..6b07caf 100644
--- a/backend_shinkos6245.c
+++ b/backend_shinkos6245.c
@@ -1,7 +1,7 @@
/*
* Shinko/Sinfonia CHC-S6245 CUPS backend -- libusb-1.0 version
*
- * (c) 2015-2019 Solomon Peachy <pizza@shaftnet.org>
+ * (c) 2015-2020 Solomon Peachy <pizza@shaftnet.org>
*
* Low-level documentation was provided by Sinfonia, Inc. Thank you!
*
@@ -1464,15 +1464,16 @@ static int shinkos6245_query_stats(void *vctx, struct printerstats *stats)
stats->serial = ctx->serial;
{
- struct sinfonia_fwinfo_cmd cmd;
+ struct sinfonia_fwinfo_cmd fcmd;
struct sinfonia_fwinfo_resp resp;
- int num = 0;
- cmd.hdr.cmd = cpu_to_le16(SINFONIA_CMD_FWINFO);
- cmd.hdr.len = cpu_to_le16(1);
- cmd.target = FWINFO_TARGET_MAIN_APP;
+
+ num = 0;
+ fcmd.hdr.cmd = cpu_to_le16(SINFONIA_CMD_FWINFO);
+ fcmd.hdr.len = cpu_to_le16(1);
+ fcmd.target = FWINFO_TARGET_MAIN_APP;
if (sinfonia_docmd(&ctx->dev,
- (uint8_t*)&cmd, sizeof(cmd),
+ (uint8_t*)&fcmd, sizeof(fcmd),
(uint8_t*)&resp, sizeof(resp),
&num))
return CUPS_BACKEND_FAILED;