Skip to content

Commit

Permalink
use 'const' and 'static' where it is required
Browse files Browse the repository at this point in the history
protect variables from programmer's point of view and hide several by 
'static' variables

Signed-off-by: Denis Pronin <dannftk@yandex.ru>
  • Loading branch information
dpronin committed Jul 28, 2023
1 parent 696abd9 commit 35b3040
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
12 changes: 6 additions & 6 deletions client.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static void handle_start(struct fio_client *client, struct fio_net_cmd *cmd);
static void convert_text(struct fio_net_cmd *cmd);
static void client_display_thread_status(struct jobs_eta *je);

struct client_ops fio_client_ops = {
struct client_ops const fio_client_ops = {
.text = handle_text,
.disk_util = handle_du,
.thread_status = handle_ts,
Expand All @@ -54,9 +54,9 @@ static FLIST_HEAD(eta_list);

static FLIST_HEAD(arg_list);

struct thread_stat client_ts;
struct group_run_stats client_gs;
int sum_stat_clients;
static struct thread_stat client_ts;
static struct group_run_stats client_gs;
static int sum_stat_clients;

static int sum_stat_nr;
static struct buf_output allclients;
Expand Down Expand Up @@ -446,7 +446,7 @@ int fio_client_add_ini_file(void *cookie, const char *ini_file, bool remote)
return 0;
}

int fio_client_add(struct client_ops *ops, const char *hostname, void **cookie)
int fio_client_add(struct client_ops const *ops, const char *hostname, void **cookie)
{
struct fio_client *existing = *cookie;
struct fio_client *client;
Expand Down Expand Up @@ -1772,7 +1772,7 @@ static int fio_send_file(struct fio_client *client, struct cmd_sendfile *pdu,

int fio_handle_client(struct fio_client *client)
{
struct client_ops *ops = client->ops;
struct client_ops const *ops = client->ops;
struct fio_net_cmd *cmd;

dprint(FD_NET, "client: handle %s\n", client->hostname);
Expand Down
10 changes: 3 additions & 7 deletions client.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct fio_client {
uint16_t argc;
char **argv;

struct client_ops *ops;
struct client_ops const *ops;
void *client_data;

struct client_file *files;
Expand All @@ -84,7 +84,7 @@ typedef void (client_eta_op)(struct jobs_eta *je);
typedef void (client_timed_out_op)(struct fio_client *);
typedef void (client_jobs_eta_op)(struct fio_client *client, struct jobs_eta *je);

extern struct client_ops fio_client_ops;
extern struct client_ops const fio_client_ops;

struct client_ops {
client_cmd_op *text;
Expand Down Expand Up @@ -129,7 +129,7 @@ extern int fio_start_all_clients(void);
extern int fio_clients_send_ini(const char *);
extern int fio_client_send_ini(struct fio_client *, const char *, bool);
extern int fio_handle_clients(struct client_ops *);
extern int fio_client_add(struct client_ops *, const char *, void **);
extern int fio_client_add(struct client_ops const*, const char *, void **);
extern struct fio_client *fio_client_add_explicit(struct client_ops *, const char *, int, int);
extern void fio_client_add_cmd_option(void *, const char *);
extern int fio_client_add_ini_file(void *, const char *, bool);
Expand All @@ -147,9 +147,5 @@ enum {
FIO_CLIENT_TYPE_GUI = 2,
};

extern int sum_stat_clients;
extern struct thread_stat client_ts;
extern struct group_run_stats client_gs;

#endif

0 comments on commit 35b3040

Please sign in to comment.