]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: use 'new_' prefix when we allocate something
authorKarel Zak <kzak@redhat.com>
Wed, 1 Sep 2021 15:50:51 +0000 (17:50 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 6 Oct 2021 09:01:54 +0000 (11:01 +0200)
It's more readable than rather than 'make_'.

Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/lsfd-bdev.c
misc-utils/lsfd-cdev.c
misc-utils/lsfd-fifo.c
misc-utils/lsfd-file.c
misc-utils/lsfd-sock.c
misc-utils/lsfd-unkn.c
misc-utils/lsfd.c
misc-utils/lsfd.h

index 2bfca240c741ba3b629f43aefa7f233253abc79c..24ef05596b2a99b3aefe741b4cd7363c5ff4f86c 100644 (file)
@@ -71,16 +71,16 @@ static bool bdev_fill_column(struct proc *proc __attribute__((__unused__)),
        return true;
 }
 
-struct file *make_bdev(const struct file_class *class,
+struct file *new_bdev(const struct file_class *class,
                       struct stat *sb, const char *name,
                       struct map_file_data *map_file_data,
                       int fd)
 {
-       return make_file(class? class: &bdev_class,
+       return new_file(class? class: &bdev_class,
                         sb, name, map_file_data, fd);
 }
 
-static struct partition *make_partition(dev_t dev, const char *name)
+static struct partition *new_partition(dev_t dev, const char *name)
 {
        struct partition *partition = xcalloc(1, sizeof(*partition));
 
@@ -109,7 +109,7 @@ static void read_partitions(struct list_head *partitions_list, FILE *part_fp)
 
                if (sscanf(line, "%u %u %*u %s", &major, &minor, name) != 3)
                        continue;
-               partition = make_partition(makedev(major, minor), name);
+               partition = new_partition(makedev(major, minor), name);
                list_add_tail(&partition->partitions, partitions_list);
        }
 }
index e83fe6db438e330173a6028315bc0c4c73dd1e7c..f697a5bf7a3f734c9f45cb37cc63c83b6521f2e1 100644 (file)
@@ -106,16 +106,16 @@ static bool cdev_fill_column(struct proc *proc __attribute__((__unused__)),
        return true;
 }
 
-struct file *make_cdev(const struct file_class *class,
+struct file *new_cdev(const struct file_class *class,
                       struct stat *sb, const char *name,
                       struct map_file_data *map_file_data,
                       int fd)
 {
-       return make_file(class? class: &cdev_class,
+       return new_file(class? class: &cdev_class,
                         sb, name, map_file_data, fd);
 }
 
-static struct chrdrv *make_chrdrv(unsigned long major, const char *name)
+static struct chrdrv *new_chrdrv(unsigned long major, const char *name)
 {
        struct chrdrv *chrdrv = xcalloc(1, sizeof(*chrdrv));
 
@@ -149,12 +149,12 @@ static void read_devices(struct list_head *chrdrvs_list, FILE *devices_fp)
 
                if (sscanf(line, "%lu %s", &major, name) != 2)
                        continue;
-               chrdrv = make_chrdrv(major, name);
+               chrdrv = new_chrdrv(major, name);
                list_add_tail(&chrdrv->chrdrvs, chrdrvs_list);
        }
 }
 
-static struct miscdev *make_miscdev(unsigned long minor, const char *name)
+static struct miscdev *new_miscdev(unsigned long minor, const char *name)
 {
        struct miscdev *miscdev = xcalloc(1, sizeof(*miscdev));
 
@@ -184,7 +184,7 @@ static void read_misc(struct list_head *miscdevs_list, FILE *misc_fp)
                if (sscanf(line, "%lu %s", &minor, name) != 2)
                        continue;
 
-               miscdev = make_miscdev(minor, name);
+               miscdev = new_miscdev(minor, name);
                list_add_tail(&miscdev->miscdevs, miscdevs_list);
        }
 }
index e745fd55473e796f7d43ffe7b840fca251d6e1b0..bae969d821734ebf0085ab3575d30b775d27b7a2 100644 (file)
@@ -56,12 +56,12 @@ static bool fifo_fill_column(struct proc *proc __attribute__((__unused__)),
        return true;
 }
 
-struct file *make_fifo(const struct file_class *class,
+struct file *new_fifo(const struct file_class *class,
                       struct stat *sb, const char *name,
                       struct map_file_data *map_file_data,
                       int fd)
 {
-       return make_file(class? class: &fifo_class,
+       return new_file(class? class: &fifo_class,
                         sb, name, map_file_data, fd);
 }
 
index 762d759f1ea4ff894ecd2cc0fcae380c078f96f7..b496e214d0cb5737ef13a81075617f660a94bc26 100644 (file)
@@ -340,7 +340,7 @@ static void file_free_content(struct file *file)
        free(file->name);
 }
 
-struct file *make_file(const struct file_class *class,
+struct file *new_file(const struct file_class *class,
                       struct stat *sb, const char *name,
                       struct map_file_data *map_file_data,
                       int association)
index da1aa59dfa5a4bf981d0e1f352157844fc149e1d..d5bf88b79df633069608c15ceb02500b1edb04a6 100644 (file)
@@ -76,13 +76,13 @@ static bool sock_fill_column(struct proc *proc __attribute__((__unused__)),
        return true;
 }
 
-struct file *make_sock(const struct file_class *class,
+struct file *new_sock(const struct file_class *class,
                       struct stat *sb, const char *name,
                       struct map_file_data *map_file_data,
                       int fd,
                       struct proc *proc)
 {
-       struct file *file = make_file(class? class: &sock_class,
+       struct file *file = new_file(class? class: &sock_class,
                                      sb, name, map_file_data, fd);
        if (fd >= 0 || fd == -ASSOC_MEM || fd == -ASSOC_SHM) {
                struct sock *sock = (struct sock *)file;
index 64613a281695fea0c7f3a626961abb5c36185c5a..302f312ca159fbbfd355d79b45cfe096968ad95c 100644 (file)
@@ -56,12 +56,12 @@ static bool unkn_fill_column(struct proc *proc __attribute__((__unused__)),
        return true;
 }
 
-struct file *make_unkn(const struct file_class *class,
+struct file *new_unkn(const struct file_class *class,
                       struct stat *sb, const char *name,
                       struct map_file_data *map_file_data,
                       int fd)
 {
-       return make_file(class? class: &unkn_class,
+       return new_file(class? class: &unkn_class,
                         sb, name, map_file_data, fd);
 }
 
index 1d4be15d8fa07e92cab3d44a84f144775f942fbc..5daa920e946fd14a683107d7386d453fe9a32daa 100644 (file)
@@ -219,7 +219,7 @@ static const struct colinfo *get_column_info(int num)
        return &infos[ get_column_id(num) ];
 }
 
-static struct proc *make_proc(pid_t pid, struct proc * leader)
+static struct proc *new_prococess(pid_t pid, struct proc * leader)
 {
        struct proc *proc = xcalloc(1, sizeof(*proc));
 
@@ -242,7 +242,7 @@ static void free_file(struct file *file)
        free(file);
 }
 
-static struct nodev* make_nodev(unsigned long minor, const char *filesystem)
+static struct nodev* new_nodev(unsigned long minor, const char *filesystem)
 {
        struct nodev *nodev = xcalloc(1, sizeof(*nodev));
 
@@ -305,7 +305,7 @@ static void collect_tasks(struct proc *leader,
                        continue;
                }
 
-               proc = make_proc((pid_t)num, leader);
+               proc = new_prococess((pid_t)num, leader);
                enqueue_proc(procs, proc);
        }
 }
@@ -336,7 +336,7 @@ static void collect(struct list_head *procs, struct lsfd_control *ctl)
                if (!(num = strtol(dp->d_name, NULL, 10)))
                        continue;
 
-               proc = make_proc((pid_t)num, NULL);
+               proc = new_prococess((pid_t)num, NULL);
                enqueue_proc(procs, proc);
 
                if (ctl->threads) {
@@ -364,19 +364,19 @@ static struct file *collect_file(struct proc *proc,
 {
        switch (sb->st_mode & S_IFMT) {
        case S_IFCHR:
-               return make_cdev(NULL, sb, name, map_file_data, assoc);
+               return new_cdev(NULL, sb, name, map_file_data, assoc);
        case S_IFBLK:
-               return make_bdev(NULL, sb, name, map_file_data, assoc);
+               return new_bdev(NULL, sb, name, map_file_data, assoc);
        case S_IFSOCK:
-               return make_sock(NULL, sb, name, map_file_data, assoc, proc);
+               return new_sock(NULL, sb, name, map_file_data, assoc, proc);
        case S_IFIFO:
-               return make_fifo(NULL, sb, name, map_file_data, assoc);
+               return new_fifo(NULL, sb, name, map_file_data, assoc);
        case S_IFLNK:
        case S_IFREG:
        case S_IFDIR:
-               return make_file(NULL, sb, name, map_file_data, assoc);
+               return new_file(NULL, sb, name, map_file_data, assoc);
        default:
-               return make_unkn(NULL, sb, name, map_file_data, assoc);
+               return new_unkn(NULL, sb, name, map_file_data, assoc);
        }
 }
 
@@ -543,7 +543,7 @@ static void collect_fd_files(struct proc *proc)
                closedir(dirp);
 }
 
-static struct map* make_map(unsigned long mem_addr_start, unsigned long long file_offset,
+static struct map* new_map(unsigned long mem_addr_start, unsigned long long file_offset,
                            int r, int w, int x, int s)
 {
        struct map *map = xcalloc(1, sizeof(*map));
@@ -588,7 +588,7 @@ static void read_maps(struct list_head *maps_list, FILE *maps_fp)
                           &start, &end, &r, &w, &x, &s, &file_offset,
                           &major, &minor, &inode) != 10)
                        continue;
-               map = make_map(start, file_offset, r == 'r', w == 'w', x == 'x', s == 's');
+               map = new_map(start, file_offset, r == 'r', w == 'w', x == 'x', s == 's');
                list_add_tail(&map->maps, maps_list);
        }
 }
@@ -1143,11 +1143,15 @@ FILE *fopenf(const char *mode, const char *format, ...)
 
 static void add_nodev(unsigned long minor, const char *filesystem)
 {
+       struct nodev *nodev;
+       int slot;
+
        if (get_nodev_filesystem(minor))
                return;
 
-       struct nodev *nodev = make_nodev(minor, filesystem);
-       int slot = minor % NODEV_TABLE_SIZE;
+       nodev = new_nodev(minor, filesystem);
+       slot = minor % NODEV_TABLE_SIZE;
+
        list_add_tail(&nodev->nodevs, &nodev_table.tables[slot]);
 }
 
@@ -1155,6 +1159,7 @@ const char *get_nodev_filesystem(unsigned long minor)
 {
        struct list_head *n;
        int slot = minor % NODEV_TABLE_SIZE;
+
        list_for_each (n, &nodev_table.tables[slot]) {
                struct nodev *nodev = list_entry(n, struct nodev, nodevs);
                if (nodev->minor == minor)
index 149808b3c60dcf97df0b02eeb44b8085cdf29a46..089cff4ca0236126c309470ca6ab72de6cc34d2f 100644 (file)
@@ -152,28 +152,28 @@ struct file_class {
 
 extern const struct file_class file_class, cdev_class, bdev_class, sock_class, unkn_class, fifo_class;
 
-struct file *make_file(const struct file_class *class,
+struct file *new_file(const struct file_class *class,
                       struct stat *sb, const char *name,
                       struct map_file_data *map_file_data,
                       int association);
-struct file *make_cdev(const struct file_class *class,
+struct file *new_cdev(const struct file_class *class,
                       struct stat *sb, const char *name,
                       struct map_file_data *map_file_data,
                       int fd);
-struct file *make_bdev(const struct file_class *class,
+struct file *new_bdev(const struct file_class *class,
                       struct stat *sb, const char *name,
                       struct map_file_data *map_file_data,
                       int fd);
-struct file *make_sock(const struct file_class *class,
+struct file *new_sock(const struct file_class *class,
                       struct stat *sb, const char *name,
                       struct map_file_data *map_file_data,
                       int fd,
                       struct proc *proc);
-struct file *make_unkn(const struct file_class *class,
+struct file *new_unkn(const struct file_class *class,
                       struct stat *sb, const char *name,
                       struct map_file_data *map_file_data,
                       int fd);
-struct file *make_fifo(const struct file_class *class,
+struct file *new_fifo(const struct file_class *class,
                       struct stat *sb, const char *name,
                       struct map_file_data *map_file_data,
                       int fd);