]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: make a few structs const
authorThomas Weißschuh <thomas@t-8ch.de>
Sun, 22 Jan 2023 17:55:48 +0000 (17:55 +0000)
committerThomas Weißschuh <thomas@t-8ch.de>
Sun, 22 Jan 2023 18:01:27 +0000 (18:01 +0000)
misc-utils/lsfd-fifo.c
misc-utils/lsfd-sock-xinfo.c
misc-utils/lsfd-unkn.c
misc-utils/lsfd.c
misc-utils/lsfd.h

index 3799313cdb2f930b575e67abde7434edf0f9c274..484ffd6ebcbe1aa824e8521343413c4f6c7d1aee 100644 (file)
@@ -104,9 +104,9 @@ static bool fifo_is_suitable_ipc(struct ipc *ipc, struct file *file)
        return ((struct fifo_ipc *)ipc)->ino == file->stat.st_ino;
 }
 
-static struct ipc_class *fifo_get_ipc_class(struct file *file __attribute__((__unused__)))
+static const struct ipc_class *fifo_get_ipc_class(struct file *file __attribute__((__unused__)))
 {
-       static struct ipc_class fifo_ipc_class = {
+       static const struct ipc_class fifo_ipc_class = {
                .get_hash = fifo_get_hash,
                .is_suitable_ipc = fifo_is_suitable_ipc,
                .free = NULL,
index 3795d290d30eb59477c7c07c732cd0e2dd5ea009..955658bedbf5b85dfe6b57b64b5931185a81f17b 100644 (file)
@@ -335,7 +335,7 @@ static bool unix_fill_column(struct proc *proc __attribute__((__unused__)),
        return false;
 }
 
-static struct sock_xinfo_class unix_xinfo_class = {
+static const struct sock_xinfo_class unix_xinfo_class = {
        .class = "unix",
        .get_name = unix_get_name,
        .get_type = unix_get_type,
@@ -588,7 +588,7 @@ static bool tcp_get_listening(struct sock_xinfo *sock_xinfo,
        }
 
 define_fill_column_func(tcp, TCP)
-static struct sock_xinfo_class tcp_xinfo_class = {
+static const struct sock_xinfo_class tcp_xinfo_class = {
        .class = "tcp",
        .get_name = tcp_get_name,
        .get_type = tcp_get_type,
@@ -622,7 +622,7 @@ static uint32_t kernel32_to_cpu(enum sysfs_byteorder byteorder, uint32_t v)
 
 #define TCP_LINE_LEN 256
 static void load_xinfo_from_proc_inet_L3(ino_t netns_inode, const char *proc_file,
-                                        struct sock_xinfo_class *class)
+                                        const struct sock_xinfo_class *class)
 {
        char line[TCP_LINE_LEN];
        FILE *tcp_fp;
@@ -720,7 +720,7 @@ static char *udp_get_type(struct sock_xinfo *sock_xinfo __attribute__((__unused_
 }
 
 define_fill_column_func(udp, UDP)
-static struct sock_xinfo_class udp_xinfo_class = {
+static const struct sock_xinfo_class udp_xinfo_class = {
        .class = "udp",
        .get_name = udp_get_name,
        .get_type = udp_get_type,
index e1fd259410b3a1ecd96a8adbc3fe4d3204d8a868..f4bba88178bd0d981956dadbb0986626a25d32f5 100644 (file)
@@ -27,7 +27,7 @@
 
 struct unkn {
        struct file file;
-       struct anon_ops *anon_ops;
+       const struct anon_ops *anon_ops;
        void *anon_data;
 };
 
@@ -46,8 +46,8 @@ struct anon_ops {
        int (*handle_fdinfo)(struct unkn *, const char *, const char *);
 };
 
-static struct anon_ops anon_generic_ops;
-static struct anon_ops anon_pidfd_ops;
+static const struct anon_ops anon_generic_ops;
+static const struct anon_ops anon_pidfd_ops;
 
 static char * anon_get_class(struct unkn *unkn)
 {
@@ -251,7 +251,7 @@ static bool anon_pidfd_fill_column(struct proc *proc  __attribute__((__unused__)
        return false;
 }
 
-static struct anon_ops anon_pidfd_ops = {
+static const struct anon_ops anon_pidfd_ops = {
        .class = "pidfd",
        .get_name = anon_pidfd_get_name,
        .fill_column = anon_pidfd_fill_column,
@@ -263,7 +263,7 @@ static struct anon_ops anon_pidfd_ops = {
 /*
  * generic (fallback implementation)
  */
-static struct anon_ops anon_generic_ops = {
+static const struct anon_ops anon_generic_ops = {
        .class = NULL,
        .get_name = NULL,
        .fill_column = NULL,
index ef35f49e81e066ef7d25617d4d8db3b0681af16c..e6da1cb89733b255af64147456aa11e4fadfaa51 100644 (file)
@@ -119,7 +119,7 @@ struct colinfo {
 };
 
 /* columns descriptions */
-static struct colinfo infos[] = {
+static const struct colinfo infos[] = {
        [COL_AINODECLASS]
                      = { "AINODECLASS",0,SCOLS_FL_RIGHT,SCOLS_JSON_STRING,
                N_("class of anonymous inode") },
@@ -272,7 +272,7 @@ struct counter_spec {
        const char *expr;
 };
 
-static struct counter_spec default_counter_specs[] = {
+static const struct counter_spec default_counter_specs[] = {
        {
                .name = N_("processes"),
                .expr = "ASSOC == 'cwd'",
@@ -955,7 +955,7 @@ struct ipc *get_ipc(struct file *file)
 {
        int slot;
        struct list_head *e;
-       struct ipc_class *ipc_class;
+       const struct ipc_class *ipc_class;
 
        if (!file->class->get_ipc_class)
                return NULL;
@@ -1546,7 +1546,7 @@ static void free_counter_spec(struct counter_spec *counter_spec)
        free(counter_spec);
 }
 
-static struct lsfd_counter *new_counter(struct counter_spec *spec, struct lsfd_control *ctl)
+static struct lsfd_counter *new_counter(const struct counter_spec *spec, struct lsfd_control *ctl)
 {
        struct lsfd_filter *filter;
 
@@ -1581,7 +1581,7 @@ static struct lsfd_counter **new_default_counters(struct lsfd_control *ctl)
 
        counters = xcalloc(len + 1, sizeof(struct lsfd_counter *));
        for (i = 0; i < len; i++) {
-               struct counter_spec *spec = default_counter_specs + i;
+               const struct counter_spec *spec = default_counter_specs + i;
                counters[i] = new_counter(spec, ctl);
        }
        assert(counters[len] == NULL);
@@ -1596,7 +1596,7 @@ static void dump_default_counter_specs(void)
 
        puts("default counter specs:");
        for (i = 0; i < len; i++) {
-               struct counter_spec *spec = default_counter_specs + i;
+               const struct counter_spec *spec = default_counter_specs + i;
                printf("\t%s:%s\n", spec->name, spec->expr);
        }
 }
index c73a66298b5ccf1b3c56d59d83b7bf8991b27a20..484e9c27f7d590dc33c74f5aa44b250ca9a5eecd 100644 (file)
@@ -168,7 +168,7 @@ struct file_class {
        void (*attach_xinfo)(struct file *file);
        void (*initialize_content)(struct file *file);
        void (*free_content)(struct file *file);
-       struct ipc_class *(*get_ipc_class)(struct file *file);
+       const struct ipc_class *(*get_ipc_class)(struct file *file);
 };
 
 extern const struct file_class file_class, cdev_class, bdev_class, sock_class, unkn_class, fifo_class,