From 80c8fcfd5185272ab396c464c7fb1ead7d2c4d11 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Tue, 16 Jan 2024 02:50:23 +0900 Subject: [PATCH] lsfd: (refactor) make the steps for new_file consistent In parse_maps_line of the original code, we called readlink after stat for gathering arguments that were passed to new_file(). The order was different from that in collect_file_symlink. In parse_maps_line, we called stat after readlink. The difference of the order may make the way of handling errors of readlink and stat complicated. Signed-off-by: Masatake YAMATO --- misc-utils/lsfd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/misc-utils/lsfd.c b/misc-utils/lsfd.c index 63a59f200b..b4162159c1 100644 --- a/misc-utils/lsfd.c +++ b/misc-utils/lsfd.c @@ -926,10 +926,10 @@ static void parse_maps_line(struct path_cxt *pc, char *buf, struct proc *proc) try_map_files: snprintf(map_file, sizeof(map_file), "map_files/%"PRIx64"-%"PRIx64, start, end); - if (ul_path_stat(pc, &sb, 0, map_file) < 0) - return; if (ul_path_readlink(pc, sym, sizeof(sym), map_file) < 0) return; + if (ul_path_stat(pc, &sb, 0, map_file) < 0) + return; f = new_file(proc, stat2class(&sb), &sb, sym, -assoc); } -- 2.47.3