From: Masatake YAMATO Date: Tue, 21 Mar 2023 16:03:22 +0000 (+0900) Subject: lsfd: initialize pagesize in an earlier stage X-Git-Tag: v2.40-rc1~432^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c1cb27357c2c970e518d37418a5961fff9e48ee8;p=thirdparty%2Futil-linux.git lsfd: initialize pagesize in an earlier stage Signed-off-by: Masatake YAMATO --- diff --git a/misc-utils/lsfd-file.c b/misc-utils/lsfd-file.c index daf9cb3c5f..99cff5992c 100644 --- a/misc-utils/lsfd-file.c +++ b/misc-utils/lsfd-file.c @@ -45,6 +45,8 @@ static struct idcache *username_cache; +static size_t pagesize; + static const char *assocstr[N_ASSOCS] = { [ASSOC_CWD] = "cwd", [ASSOC_EXE] = "exe", @@ -102,14 +104,8 @@ static uint64_t get_map_length(struct file *file) { uint64_t res = 0; - if (is_association(file, SHM) || is_association(file, MEM)) { - static size_t pagesize = 0; - - if (!pagesize) - pagesize = getpagesize(); - + if (is_association(file, SHM) || is_association(file, MEM)) res = (file->map_end - file->map_start) / pagesize; - } return res; } @@ -306,6 +302,9 @@ static void file_free_content(struct file *file) static void file_class_initialize(void) { + if (!pagesize) + pagesize = getpagesize(); + username_cache = new_idcache(); if (!username_cache) err(EXIT_FAILURE, _("failed to allocate UID cache"));