Fixed various trivial cppcheck 1.80 warnings
[platform/upstream/libusb.git] / examples / dpfp.c
index 5127dde..77f9476 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * libusb example program to manipulate U.are.U 4000B fingerprint scanner.
- * Copyright (C) 2007 Daniel Drake <dsd@gentoo.org>
+ * Copyright © 2007 Daniel Drake <dsd@gentoo.org>
  *
  * Basic image capture program only, does not consider the powerup quirks or
  * the fact that image encryption may be enabled. Not expected to work
@@ -27,7 +27,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <libusb.h>
+#include "libusb.h"
 
 #define EP_INTR                        (1 | LIBUSB_ENDPOINT_IN)
 #define EP_DATA                        (2 | LIBUSB_ENDPOINT_IN)
@@ -164,7 +164,7 @@ static void LIBUSB_CALL cb_mode_changed(struct libusb_transfer *transfer)
 
 static int set_mode_async(unsigned char data)
 {
-       unsigned char *buf = malloc(LIBUSB_CONTROL_SETUP_SIZE + 1);
+       unsigned char *buf = (unsigned char*) malloc(LIBUSB_CONTROL_SETUP_SIZE + 1);
        struct libusb_transfer *transfer;
 
        if (!buf)
@@ -225,15 +225,14 @@ static int save_to_file(unsigned char *data)
 {
        FILE *fd;
        char filename[64];
-       size_t ignore;
 
-       sprintf(filename, "finger%d.pgm", img_idx++);
+       snprintf(filename, sizeof(filename), "finger%d.pgm", img_idx++);
        fd = fopen(filename, "w");
        if (!fd)
                return -1;
 
        fputs("P5 384 289 255 ", fd);
-       ignore = fwrite(data + 64, 1, 384*289, fd);
+       (void) fwrite(data + 64, 1, 384*289, fd);
        fclose(fd);
        printf("saved image to %s\n", filename);
        return 0;
@@ -412,13 +411,15 @@ static int alloc_transfers(void)
 
 static void sighandler(int signum)
 {
+       (void)signum;
+
        do_exit = 1;
 }
 
 int main(void)
 {
        struct sigaction sigact;
-       int r = 1;
+       int r;
 
        r = libusb_init(NULL);
        if (r < 0) {
@@ -505,4 +506,3 @@ out:
        libusb_exit(NULL);
        return r >= 0 ? r : -r;
 }
-