summaryrefslogtreecommitdiff
path: root/udev_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'udev_utils.c')
-rw-r--r--udev_utils.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/udev_utils.c b/udev_utils.c
index b6e5275a16..e892012132 100644
--- a/udev_utils.c
+++ b/udev_utils.c
@@ -126,7 +126,6 @@ int add_matching_files(struct list_head *name_list, const char *dirname, const c
{
struct dirent *ent;
DIR *dir;
- char *ext;
char filename[PATH_SIZE];
dbg("open directory '%s'", dirname);
@@ -145,14 +144,16 @@ int add_matching_files(struct list_head *name_list, const char *dirname, const c
continue;
/* look for file matching with specified suffix */
- ext = strrchr(ent->d_name, '.');
- if (ext == NULL)
- continue;
-
- if (strcmp(ext, suffix) != 0)
- continue;
-
- dbg("put file '%s/%s' in list", dirname, ent->d_name);
+ if (suffix != NULL) {
+ const char *ext;
+
+ ext = strrchr(ent->d_name, '.');
+ if (ext == NULL)
+ continue;
+ if (strcmp(ext, suffix) != 0)
+ continue;
+ }
+ dbg("put file '%s/%s' into list", dirname, ent->d_name);
snprintf(filename, sizeof(filename), "%s/%s", dirname, ent->d_name);
filename[sizeof(filename)-1] = '\0';