From 3d82efedeb28e4b1cddd2b428a26f60ad6d2a95a Mon Sep 17 00:00:00 2001 From: Peter Rajnoha Date: Fri, 24 May 2024 12:35:49 +0200 Subject: [PATCH] res: ubr: simplify code after scandir in _update_disk_deps_from_sysfs --- src/resource/ubridge.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/resource/ubridge.c b/src/resource/ubridge.c index d85aa115..61cdb852 100644 --- a/src/resource/ubridge.c +++ b/src/resource/ubridge.c @@ -4427,7 +4427,10 @@ static int _update_disk_deps_from_sysfs(sid_res_t *cmd_res) goto out; } - if ((count = scandir(s, &dirent, NULL, NULL)) < 0) { + count = scandir(s, &dirent, NULL, NULL); + sid_buf_mem_rewind(ucmd_ctx->common->gen_buf, s); + + if (count < 0) { /* * FIXME: Add code to deal with/warn about: (errno == ENOENT) && (ucmd_ctx->req_env.dev.udev.action != * UDEV_ACTION_REMOVE). That means we don't have REMOVE uevent, but at the same time, we don't have sysfs @@ -4435,11 +4438,8 @@ static int _update_disk_deps_from_sysfs(sid_res_t *cmd_res) * after this uevent was triggered. For now, error out even in this case. */ sid_res_log_sys_error(cmd_res, "scandir", s); - sid_buf_mem_rewind(ucmd_ctx->common->gen_buf, s); goto out; } - - sid_buf_mem_rewind(ucmd_ctx->common->gen_buf, s); } /*