]> git.itanic.dy.fi Git - glucose/commitdiff
Replace strerror() with "%m" at printf
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Tue, 27 Mar 2012 18:15:13 +0000 (21:15 +0300)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Tue, 27 Mar 2012 18:15:13 +0000 (21:15 +0300)
The printf functions already support printing the errno value as a
string, there is no need to convert it manually.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
hiddev.c
main.c

index 048e3b14749524e8d8b2fc1e51d80a5f0819dea2..8cf4e5a9d1bbd3947e11a2cd4b02ddc4441d6b54 100644 (file)
--- a/hiddev.c
+++ b/hiddev.c
@@ -52,7 +52,7 @@ int hiddev_read(unsigned char *data, int bufsize, int fd)
 
 int hiddev_write(const unsigned char data[64], int fd , int usage_code)
 {
-       int rc = 0, uindex, error;
+       int rc = 0, uindex;
 
        struct hiddev_usage_ref uref;
        struct hiddev_report_info rinfo;
@@ -84,8 +84,7 @@ int hiddev_write(const unsigned char data[64], int fd , int usage_code)
 err2:
        printf("HIDIOCSREPORT\n");
 err:
-       error = errno;
-       printf("Error in IOCTL: %s\n", strerror(error));
+       printf("Error in IOCTL: %m\n");
 
        return rc;
 }
@@ -93,7 +92,7 @@ err:
 static int get_usagecode(int fd)
 {
        struct hiddev_usage_ref uref;
-       int rc, error;
+       int rc;
 
        uref.report_type = HID_REPORT_TYPE_OUTPUT;
        uref.report_id = 0x0;
@@ -102,8 +101,7 @@ static int get_usagecode(int fd)
 
        rc = ioctl(fd, HIDIOCGUCODE, &uref);
        if (rc < 0) {
-               error = errno;
-               printf("Error gettin usage code: %s\n", strerror(error));
+               printf("Error gettin usage code: %m\n");
                return rc;
        }
 
@@ -190,8 +188,8 @@ int hiddev_open_by_id(int vendor_id, int product_id, int *usage_code)
        dir = opendir(HIDDEV_PATH);
        if (dir == NULL) {
                error = errno;
-               trace(4, "Failed to open directory %s: %s\n", HIDDEV_PATH,
-                       strerror(error));
+               trace(4, "Failed to open directory %s: %m\n", HIDDEV_PATH);
+
                return -error;
        }
 
@@ -215,8 +213,8 @@ int hiddev_open_by_id(int vendor_id, int product_id, int *usage_code)
 
        if (errno) {
                error = errno;
-               trace(0, "Error reading directory %s: %s\n", HIDDEV_PATH,
-                       strerror(error));
+               trace(0, "Error reading directory %s: %m\n", HIDDEV_PATH);
+
                return -error;
        }
 
diff --git a/main.c b/main.c
index a78d6800583425f9709fbf9f5ca25217acea3e76..449fa157873fe3aed9e0856854a5661d650f3db1 100644 (file)
--- a/main.c
+++ b/main.c
@@ -138,7 +138,7 @@ static int dump_entries(struct user_options *opts, int fd, int usage_code)
 int main(int argc, char *argv[])
 {
        struct user_options opts;
-       int fd, usage_code, ret, error;
+       int fd, usage_code, ret;
 
        bzero(&opts, sizeof(opts));
        opts.output_format = CLEAN;
@@ -151,9 +151,8 @@ int main(int argc, char *argv[])
        if (opts.output_path) {
                opts.outf = fopen(opts.output_path, "w");
                if (opts.outf == NULL) {
-                       error = errno;
-                       trace(0, "Failed to open output file %s: %s\n",
-                               opts.output_path, strerror(error));
+                       trace(0, "Failed to open output file \"%s\": %m\n",
+                               opts.output_path);
                        return 1;
                }
        } else {