Silence a pile of 'cppcheck' warnings.
...And fix a legitimate bug in the process!master
parent
3eef2ba475
commit
1e8c0ae99a
3
Makefile
3
Makefile
|
@ -21,6 +21,9 @@ $(EXEC_NAME): $(SOURCES) $(DEPS)
|
|||
$(BACKENDS): $(EXEC_NAME)
|
||||
ln -sf $(EXEC_NAME) $@
|
||||
|
||||
cppcheck:
|
||||
cppcheck -q -v --std=c99 --enable=all -DURI_PREFIX=\"$(BACKEND_NAME)\" $(SOURCES)
|
||||
|
||||
install:
|
||||
install -o root -m 700 $(EXEC_NAME) $(CUPS_BACKEND_DIR)/$(BACKEND_NAME)
|
||||
mkdir -p $(CUPS_DATA_DIR)/usb
|
||||
|
|
|
@ -574,7 +574,7 @@ static int canonselphy_early_parse(void *vctx, int data_fd)
|
|||
|
||||
/* Figure out printer this file is intended for */
|
||||
i = read(data_fd, ctx->buffer, MAX_HEADER);
|
||||
if (i < 0 || i != MAX_HEADER) {
|
||||
if (i != MAX_HEADER) {
|
||||
if (i == 0)
|
||||
return -1;
|
||||
ERROR("Read failed (%d/%d/%d)\n",
|
||||
|
|
|
@ -97,7 +97,7 @@ int read_data(struct libusb_device_handle *dev, uint8_t endp,
|
|||
int ret;
|
||||
|
||||
/* Clear buffer */
|
||||
memset(buf, buflen, 0);
|
||||
memset(buf, 0, buflen);
|
||||
|
||||
ret = libusb_bulk_transfer(dev, endp,
|
||||
buf,
|
||||
|
@ -267,7 +267,7 @@ static int print_scan_output(struct libusb_device *device,
|
|||
/* XXX this is ... a cut-n-paste hack */
|
||||
|
||||
uint8_t endp_up, endp_down;
|
||||
int i, iface = 0;
|
||||
int iface = 0;
|
||||
struct libusb_config_descriptor *config;
|
||||
|
||||
if (libusb_kernel_driver_active(dev, iface))
|
||||
|
@ -276,6 +276,7 @@ static int print_scan_output(struct libusb_device *device,
|
|||
/* If we fail to claim the printer, it's already in use
|
||||
so we should just skip over it... */
|
||||
if (!libusb_claim_interface(dev, iface)) {
|
||||
int i;
|
||||
libusb_get_active_config_descriptor(device, &config);
|
||||
for (i = 0 ; i < config->interface[0].altsetting[0].bNumEndpoints ; i++) {
|
||||
if ((config->interface[0].altsetting[0].endpoint[i].bmAttributes & 3) == LIBUSB_TRANSFER_TYPE_BULK) {
|
||||
|
@ -429,13 +430,13 @@ static int find_and_enumerate(struct libusb_context *ctx,
|
|||
static struct dyesub_backend *find_backend(char *uri_prefix)
|
||||
{
|
||||
int i;
|
||||
struct dyesub_backend *backend;
|
||||
|
||||
|
||||
if (!uri_prefix)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; ; i++) {
|
||||
backend = backends[i];
|
||||
struct dyesub_backend *backend = backends[i];
|
||||
if (!backend)
|
||||
return NULL;
|
||||
if (!strcmp(uri_prefix, backend->uri_prefix))
|
||||
|
@ -471,7 +472,6 @@ static void print_help(char *argv0, struct dyesub_backend *backend)
|
|||
{
|
||||
struct libusb_context *ctx = NULL;
|
||||
struct libusb_device **list = NULL;
|
||||
int i;
|
||||
|
||||
char *ptr = strrchr(argv0, '/');
|
||||
if (ptr)
|
||||
|
@ -483,6 +483,7 @@ static void print_help(char *argv0, struct dyesub_backend *backend)
|
|||
backend = find_backend(ptr);
|
||||
|
||||
if (!backend) {
|
||||
int i;
|
||||
DEBUG("CUPS Usage:\n");
|
||||
DEBUG("\tDEVICE_URI=someuri %s job user title num-copies options [ filename ]\n", URI_PREFIX);
|
||||
DEBUG("\n");
|
||||
|
|
|
@ -86,13 +86,13 @@ struct dnpds40_cmd {
|
|||
|
||||
static void dnpds40_build_cmd(struct dnpds40_cmd *cmd, char *arg1, char *arg2, uint32_t arg3_len)
|
||||
{
|
||||
char buf[9];
|
||||
memset(cmd, 0x20, sizeof(*cmd));
|
||||
cmd->esc = 0x1b;
|
||||
cmd->p = 0x50;
|
||||
memcpy(cmd->arg1, arg1, min(strlen(arg1), sizeof(cmd->arg1)));
|
||||
memcpy(cmd->arg2, arg2, min(strlen(arg2), sizeof(cmd->arg2)));
|
||||
if (arg3_len) {
|
||||
char buf[9];
|
||||
snprintf(buf, sizeof(buf), "%08d", arg3_len);
|
||||
memcpy(cmd->arg3, buf, 8);
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ static void dnpds40_teardown(void *vctx) {
|
|||
|
||||
static int dnpds40_read_parse(void *vctx, int data_fd) {
|
||||
struct dnpds40_ctx *ctx = vctx;
|
||||
int i, j, run = 1;
|
||||
int run = 1;
|
||||
char buf[9] = { 0 };
|
||||
|
||||
uint32_t matte = 0, multicut = 0, dpi = 0;
|
||||
|
@ -348,7 +348,7 @@ static int dnpds40_read_parse(void *vctx, int data_fd) {
|
|||
}
|
||||
|
||||
while (run) {
|
||||
int remain;
|
||||
int remain, i, j;
|
||||
/* Read in command header */
|
||||
i = read(data_fd, ctx->databuf + ctx->datalen,
|
||||
sizeof(struct dnpds40_cmd));
|
||||
|
|
|
@ -326,7 +326,6 @@ static int mitsu70x_get_status(struct mitsu70x_ctx *ctx)
|
|||
uint8_t cmdbuf[CMDBUF_LEN];
|
||||
struct mitsu70x_status_resp resp;
|
||||
int num, ret;
|
||||
unsigned int i;
|
||||
|
||||
/* Send Printer Query */
|
||||
memset(cmdbuf, 0, CMDBUF_LEN);
|
||||
|
@ -349,6 +348,8 @@ static int mitsu70x_get_status(struct mitsu70x_ctx *ctx)
|
|||
}
|
||||
|
||||
if (dyesub_debug) {
|
||||
unsigned int i;
|
||||
|
||||
DEBUG("Status Dump:\n");
|
||||
for (i = 0 ; i < sizeof(resp.unk) ; i++) {
|
||||
DEBUG2("%02x ", resp.unk[i]);
|
||||
|
|
|
@ -82,7 +82,7 @@ static void updr150_teardown(void *vctx) {
|
|||
#define MAX_PRINTJOB_LEN 16736455
|
||||
static int updr150_read_parse(void *vctx, int data_fd) {
|
||||
struct updr150_ctx *ctx = vctx;
|
||||
int i, len, run = 1;
|
||||
int len, run = 1;
|
||||
|
||||
if (!ctx)
|
||||
return 1;
|
||||
|
@ -100,6 +100,7 @@ static int updr150_read_parse(void *vctx, int data_fd) {
|
|||
}
|
||||
|
||||
while(run) {
|
||||
int i;
|
||||
int keep = 0;
|
||||
i = read(data_fd, ctx->databuf + ctx->datalen, 4);
|
||||
if (i < 0)
|
||||
|
|
Loading…
Reference in New Issue