From: Colin Watson Date: Wed, 24 Nov 2010 19:43:32 +0000 (+0000) Subject: * util/deviceiter.c (grub_util_iterate_devices): Save a bit of X-Git-Tag: 1.99~305^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=74f72a6415a450219afe51fa0f2c17ffdb085e61;p=thirdparty%2Fgrub.git * util/deviceiter.c (grub_util_iterate_devices): Save a bit of effort by skipping "." and ".." entries up-front. Suggested by: Michael Lazarev. --- diff --git a/ChangeLog b/ChangeLog index f29ade31c..6bc7f1b9e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-11-24 Colin Watson + + * util/deviceiter.c (grub_util_iterate_devices): Save a bit of + effort by skipping "." and ".." entries up-front. + Suggested by: Michael Lazarev. + 2010-11-24 Colin Watson * grub-core/Makefile.core.def (xz_decompress): Move -lgcc from diff --git a/util/deviceiter.c b/util/deviceiter.c index 1de8e54df..30c18beea 100644 --- a/util/deviceiter.c +++ b/util/deviceiter.c @@ -536,6 +536,10 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int), necessary. */ for (entry = readdir (dir); entry; entry = readdir (dir)) { + /* Skip current and parent directory entries. */ + if (strcmp (entry->d_name, ".") == 0 || + strcmp (entry->d_name, "..") == 0) + continue; /* Skip partition entries. */ if (strstr (entry->d_name, "-part")) continue;