From: Thomas Weißschuh Date: Sun, 22 Jan 2023 17:55:48 +0000 (+0000) Subject: lsfd: make a few structs const X-Git-Tag: v2.39-rc1~128^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f18fc9dd6d1c646ccb101a62a512194ceb4b0d49;p=thirdparty%2Futil-linux.git lsfd: make a few structs const --- diff --git a/misc-utils/lsfd-fifo.c b/misc-utils/lsfd-fifo.c index 3799313cdb..484ffd6ebc 100644 --- a/misc-utils/lsfd-fifo.c +++ b/misc-utils/lsfd-fifo.c @@ -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, diff --git a/misc-utils/lsfd-sock-xinfo.c b/misc-utils/lsfd-sock-xinfo.c index 3795d290d3..955658bedb 100644 --- a/misc-utils/lsfd-sock-xinfo.c +++ b/misc-utils/lsfd-sock-xinfo.c @@ -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, diff --git a/misc-utils/lsfd-unkn.c b/misc-utils/lsfd-unkn.c index e1fd259410..f4bba88178 100644 --- a/misc-utils/lsfd-unkn.c +++ b/misc-utils/lsfd-unkn.c @@ -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, diff --git a/misc-utils/lsfd.c b/misc-utils/lsfd.c index ef35f49e81..e6da1cb897 100644 --- a/misc-utils/lsfd.c +++ b/misc-utils/lsfd.c @@ -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); } } diff --git a/misc-utils/lsfd.h b/misc-utils/lsfd.h index c73a66298b..484e9c27f7 100644 --- a/misc-utils/lsfd.h +++ b/misc-utils/lsfd.h @@ -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,