X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=src%2Fudev%2Fudev-watch.c;h=9d3e69bc9382fef13ec74c346e99b3f08b40e669;hb=50d1760d2690db8636d8800b5777b03334f6afba;hp=c0f4973f93899b4604e405088573804a0c6133a9;hpb=e77435f2b09f4e9e7f2b12cc89273ef53910f3e7;p=thirdparty%2Fsystemd.git diff --git a/src/udev/udev-watch.c b/src/udev/udev-watch.c index c0f4973f938..9d3e69bc938 100644 --- a/src/udev/udev-watch.c +++ b/src/udev/udev-watch.c @@ -1,31 +1,18 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - +/* SPDX-License-Identifier: GPL-2.0+ */ /* - * Copyright (C) 2004-2012 Kay Sievers - * Copyright (C) 2009 Canonical Ltd. - * Copyright (C) 2009 Scott James Remnant - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * Copyright © 2004-2012 Kay Sievers + * Copyright © 2009 Canonical Ltd. + * Copyright © 2009 Scott James Remnant * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . */ -#include #include #include #include #include #include +#include "dirent-util.h" #include "stdio-util.h" #include "udev.h" @@ -59,7 +46,7 @@ void udev_watch_restore(struct udev *udev) { return; } - for (ent = readdir(dir); ent != NULL; ent = readdir(dir)) { + FOREACH_DIRENT_ALL(ent, dir, break) { char device[UTIL_PATH_SIZE]; ssize_t len; struct udev_device *dev; @@ -80,7 +67,7 @@ void udev_watch_restore(struct udev *udev) { udev_watch_begin(udev, dev); udev_device_unref(dev); unlink: - unlinkat(dirfd(dir), ent->d_name, 0); + (void) unlinkat(dirfd(dir), ent->d_name, 0); } closedir(dir); @@ -91,7 +78,7 @@ unlink: } void udev_watch_begin(struct udev *udev, struct udev_device *dev) { - char filename[UTIL_PATH_SIZE]; + char filename[sizeof("/run/udev/watch/") + DECIMAL_STR_MAX(int)]; int wd; int r; @@ -118,7 +105,7 @@ void udev_watch_begin(struct udev *udev, struct udev_device *dev) { void udev_watch_end(struct udev *udev, struct udev_device *dev) { int wd; - char filename[UTIL_PATH_SIZE]; + char filename[sizeof("/run/udev/watch/") + DECIMAL_STR_MAX(int)]; if (inotify_fd < 0) return; @@ -137,7 +124,7 @@ void udev_watch_end(struct udev *udev, struct udev_device *dev) { } struct udev_device *udev_watch_lookup(struct udev *udev, int wd) { - char filename[UTIL_PATH_SIZE]; + char filename[sizeof("/run/udev/watch/") + DECIMAL_STR_MAX(int)]; char device[UTIL_NAME_SIZE]; ssize_t len;