From e48e2912023b5600d291904b0f7b0017387e8cb2 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Wed, 13 Apr 2011 01:47:56 +0200 Subject: [PATCH] trivial cleanups --- extras/ata_id/ata_id.c | 2 -- extras/firmware/firmware.c | 4 +--- extras/hid2hci/hid2hci.c | 4 +--- extras/path_id/path_id.c | 2 -- extras/udev-acl/udev-acl.c | 1 - extras/usb_id/usb_id.c | 2 -- libudev/libudev-util-private.c | 4 ++-- udev/udevadm-monitor.c | 1 - udev/udevd.c | 8 +++++--- 9 files changed, 9 insertions(+), 19 deletions(-) diff --git a/extras/ata_id/ata_id.c b/extras/ata_id/ata_id.c index 594cfb20..cb4a1a1f 100644 --- a/extras/ata_id/ata_id.c +++ b/extras/ata_id/ata_id.c @@ -486,8 +486,6 @@ int main(int argc, char *argv[]) printf("Usage: ata_id [--export] [--help] \n" " --export print values as environment keys\n" " --help print this help text\n\n"); - default: - rc = 1; goto exit; } } diff --git a/extras/firmware/firmware.c b/extras/firmware/firmware.c index f2df76c8..36ce7905 100644 --- a/extras/firmware/firmware.c +++ b/extras/firmware/firmware.c @@ -43,7 +43,7 @@ static bool set_loading(struct udev *udev, char *loadpath, const char *state) static bool copy_firmware(struct udev *udev, const char *source, const char *target, size_t size) { char *buf; - FILE *fsource, *ftarget; + FILE *fsource = NULL, *ftarget = NULL; bool ret = false; buf = malloc(size); @@ -112,8 +112,6 @@ int main(int argc, char **argv) break; case 'h': printf("Usage: firmware --firmware= --devpath= [--help]\n\n"); - default: - rc = 1; goto exit; } } diff --git a/extras/hid2hci/hid2hci.c b/extras/hid2hci/hid2hci.c index 839c4fbc..98e60d9a 100644 --- a/extras/hid2hci/hid2hci.c +++ b/extras/hid2hci/hid2hci.c @@ -243,7 +243,7 @@ int main(int argc, char *argv[]) for (;;) { int option; - option = getopt_long(argc, argv, "m:p:M:qh", options, NULL); + option = getopt_long(argc, argv, "m:p:M:h", options, NULL); if (option == -1) break; @@ -277,8 +277,6 @@ int main(int argc, char *argv[]) break; case 'h': usage(NULL); - default: - exit(1); } } diff --git a/extras/path_id/path_id.c b/extras/path_id/path_id.c index c19bfd0f..db13eeba 100644 --- a/extras/path_id/path_id.c +++ b/extras/path_id/path_id.c @@ -388,8 +388,6 @@ int main(int argc, char **argv) printf("Usage: path_id [--debug] [--help] \n" " --debug print debug information\n" " --help print this help text\n\n"); - default: - rc = 1; goto exit; } } diff --git a/extras/udev-acl/udev-acl.c b/extras/udev-acl/udev-acl.c index 31e9991a..2dd3e6ca 100644 --- a/extras/udev-acl/udev-acl.c +++ b/extras/udev-acl/udev-acl.c @@ -364,7 +364,6 @@ int main (int argc, char* argv[]) break; case 'h': printf("Usage: udev-acl --action=ACTION [--device=DEVICEFILE] [--user=UID]\n\n"); - default: goto out; } } diff --git a/extras/usb_id/usb_id.c b/extras/usb_id/usb_id.c index fabd0928..3a7a0ffd 100644 --- a/extras/usb_id/usb_id.c +++ b/extras/usb_id/usb_id.c @@ -503,8 +503,6 @@ int main(int argc, char **argv) " --num-info use numerical values\n" " --export print values as environment keys\n" " --help print this help text\n\n"); - default: - retval = 1; goto exit; } } diff --git a/libudev/libudev-util-private.c b/libudev/libudev-util-private.c index 19f979ee..073f7e2d 100644 --- a/libudev/libudev-util-private.c +++ b/libudev/libudev-util-private.c @@ -134,7 +134,7 @@ int util_unlink_secure(struct udev *udev, const char *filename) uid_t util_lookup_user(struct udev *udev, const char *user) { char *endptr; - int buflen = sysconf(_SC_GETPW_R_SIZE_MAX); + size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX); char buf[buflen]; struct passwd pwbuf; struct passwd *pw; @@ -159,7 +159,7 @@ uid_t util_lookup_user(struct udev *udev, const char *user) gid_t util_lookup_group(struct udev *udev, const char *group) { char *endptr; - int buflen = sysconf(_SC_GETGR_R_SIZE_MAX); + size_t buflen = sysconf(_SC_GETGR_R_SIZE_MAX); char *buf; struct group grbuf; struct group *gr; diff --git a/udev/udevadm-monitor.c b/udev/udevadm-monitor.c index 85252bb7..a587e8cc 100644 --- a/udev/udevadm-monitor.c +++ b/udev/udevadm-monitor.c @@ -133,7 +133,6 @@ int udevadm_monitor(struct udev *udev, int argc, char *argv[]) " --subsystem-match= filter events by subsystem\n" " --tag-match= filter events by tag\n" " --help\n\n"); - default: goto out; } } diff --git a/udev/udevd.c b/udev/udevd.c index c785b207..8610c6c0 100644 --- a/udev/udevd.c +++ b/udev/udevd.c @@ -744,9 +744,11 @@ static int handle_inotify(struct udev *udev) info(udev, "device %s closed, synthesising 'change'\n", udev_device_get_devnode(dev)); util_strscpyl(filename, sizeof(filename), udev_device_get_syspath(dev), "/uevent", NULL); fd = open(filename, O_WRONLY); - if (fd < 0 || write(fd, "change", 6) < 0) - info(udev, "error writing uevent: %m\n"); - close(fd); + if (fd >= 0) { + if (write(fd, "change", 6) < 0) + info(udev, "error writing uevent: %m\n"); + close(fd); + } } if (ev->mask & IN_IGNORED) udev_watch_end(udev, dev); -- 2.39.5