From: Masatake YAMATO Date: Mon, 15 Jan 2024 17:50:23 +0000 (+0900) Subject: lsfd: (refactor) make the steps for new_file consistent X-Git-Tag: v2.42-start~545^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=80c8fcfd5185272ab396c464c7fb1ead7d2c4d11;p=thirdparty%2Futil-linux.git 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 --- 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); }