]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: assign a class to the file in new_file()
authorMasatake YAMATO <yamato@redhat.com>
Sun, 4 Jun 2023 21:39:26 +0000 (06:39 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Sun, 4 Jun 2023 21:41:08 +0000 (06:41 +0900)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
misc-utils/lsfd.c

index 05a5f3f4db7c43bc2b1f81874ccd22251647fc88..bf7b214f18608ce31a322dbd9a58892ca518d271 100644 (file)
@@ -612,7 +612,10 @@ static struct file *new_file(struct proc *proc, const struct file_class *class)
 {
        struct file *file;
 
+       assert(class);
        file = xcalloc(1, class->size);
+       file->class = class;
+
        file->proc = proc;
 
        INIT_LIST_HEAD(&file->files);
@@ -639,11 +642,6 @@ static struct file *copy_file(struct file *old)
 
 static void file_set_path(struct file *file, struct stat *sb, const char *name, int association)
 {
-       const struct file_class *class = stat2class(sb);
-
-       assert(class);
-
-       file->class = class;
        file->association = association;
        file->name = xstrdup(name);
        file->stat = *sb;