diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-02-13 22:02:40 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-02-13 22:02:40 +0100 |
commit | 9db11a99beaf25f6eb948348202a4c783e1d31a6 (patch) | |
tree | 85096e1a6a0a99320b9557217348b51b13f9669c /src/shared/util.h | |
parent | 61cc634bc208b264bd2fbe6af241b345a2002509 (diff) |
efi: efi_get_boot_options() should already sort the entries, the random order in the efivars fs is probably not useful
This also introduces a new FOREACH_DIRENT macro and makes use of it.
Diffstat (limited to 'src/shared/util.h')
-rw-r--r-- | src/shared/util.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/shared/util.h b/src/shared/util.h index 3ad90ddce4..fcb0d9af17 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -573,11 +573,22 @@ int on_ac_power(void); int search_and_fopen(const char *path, const char *mode, const char **search, FILE **_f); int search_and_fopen_nulstr(const char *path, const char *mode, const char *search, FILE **_f); -#define FOREACH_LINE(f, line, on_error) \ - for (char line[LINE_MAX]; !feof(f); ) \ +#define FOREACH_LINE(line, f, on_error) \ + for (;;) \ if (!fgets(line, sizeof(line), f)) { \ if (ferror(f)) { \ on_error; \ } \ break; \ } else + +#define FOREACH_DIRENT(de, d, on_error) \ + for (errno = 0, de = readdir(d);; errno = 0, de = readdir(d)) \ + if (!de) { \ + if (errno != 0) { \ + on_error; \ + } \ + break; \ + } else if (ignore_file((de)->d_name)) \ + continue; \ + else |