const-ify command and option tables ok stsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
diff --git a/got/got.c b/got/got.c
index d845182..2c02ca3 100644
--- a/got/got.c
+++ b/got/got.c
@@ -145,7 +145,7 @@ static const struct got_error* cmd_unstage(int, char *[]);
static const struct got_error* cmd_cat(int, char *[]);
static const struct got_error* cmd_info(int, char *[]);
-static struct got_cmd got_commands[] = {
+static const struct got_cmd got_commands[] = {
{ "init", cmd_init, usage_init, "" },
{ "import", cmd_import, usage_import, "im" },
{ "clone", cmd_clone, usage_clone, "cl" },
@@ -184,7 +184,7 @@ list_commands(FILE *fp)
fprintf(fp, "commands:");
for (i = 0; i < nitems(got_commands); i++) {
- struct got_cmd *cmd = &got_commands[i];
+ const struct got_cmd *cmd = &got_commands[i];
fprintf(fp, " %s", cmd->cmd_name);
}
fputc('\n', fp);
@@ -199,11 +199,11 @@ option_conflict(char a, char b)
int
main(int argc, char *argv[])
{
- struct got_cmd *cmd;
+ const struct got_cmd *cmd;
size_t i;
int ch;
int hflag = 0, Vflag = 0;
- static struct option longopts[] = {
+ static const struct option longopts[] = {
{ "version", no_argument, NULL, 'V' },
{ NULL, 0, NULL, 0 }
};
@@ -250,9 +250,9 @@ main(int argc, char *argv[])
continue;
if (hflag)
- got_commands[i].cmd_usage();
+ cmd->cmd_usage();
- error = got_commands[i].cmd_main(argc, argv);
+ error = cmd->cmd_main(argc, argv);
if (error && error->code != GOT_ERR_CANCELLED &&
error->code != GOT_ERR_PRIVSEP_EXIT &&
!(sigpipe_received &&
@@ -9374,7 +9374,7 @@ usage_histedit(void)
#define GOT_HISTEDIT_DROP 'd'
#define GOT_HISTEDIT_MESG 'm'
-static struct got_histedit_cmd {
+static const struct got_histedit_cmd {
unsigned char code;
const char *name;
const char *desc;
@@ -9493,7 +9493,7 @@ write_cmd_list(FILE *f, const char *branch_name,
}
for (i = 0; i < nitems(got_histedit_cmds); i++) {
- struct got_histedit_cmd *cmd = &got_histedit_cmds[i];
+ const struct got_histedit_cmd *cmd = &got_histedit_cmds[i];
n = fprintf(f, "# %s (%c): %s\n", cmd->name, cmd->code,
cmd->desc);
if (n < 0) {
diff --git a/gotadmin/gotadmin.c b/gotadmin/gotadmin.c
index 9bf9bdb..bd7343d 100644
--- a/gotadmin/gotadmin.c
+++ b/gotadmin/gotadmin.c
@@ -91,7 +91,7 @@ static const struct got_error* cmd_indexpack(int, char *[]);
static const struct got_error* cmd_listpack(int, char *[]);
static const struct got_error* cmd_cleanup(int, char *[]);
-static struct gotadmin_cmd gotadmin_commands[] = {
+static const struct gotadmin_cmd gotadmin_commands[] = {
{ "info", cmd_info, usage_info, "" },
{ "pack", cmd_pack, usage_pack, "" },
{ "indexpack", cmd_indexpack, usage_indexpack,"ix" },
@@ -106,7 +106,7 @@ list_commands(FILE *fp)
fprintf(fp, "commands:");
for (i = 0; i < nitems(gotadmin_commands); i++) {
- struct gotadmin_cmd *cmd = &gotadmin_commands[i];
+ const struct gotadmin_cmd *cmd = &gotadmin_commands[i];
fprintf(fp, " %s", cmd->cmd_name);
}
fputc('\n', fp);
@@ -115,11 +115,11 @@ list_commands(FILE *fp)
int
main(int argc, char *argv[])
{
- struct gotadmin_cmd *cmd;
+ const struct gotadmin_cmd *cmd;
size_t i;
int ch;
int hflag = 0, Vflag = 0;
- static struct option longopts[] = {
+ static const struct option longopts[] = {
{ "version", no_argument, NULL, 'V' },
{ NULL, 0, NULL, 0 }
};
@@ -166,9 +166,9 @@ main(int argc, char *argv[])
continue;
if (hflag)
- gotadmin_commands[i].cmd_usage();
+ cmd->cmd_usage();
- error = gotadmin_commands[i].cmd_main(argc, argv);
+ error = cmd->cmd_main(argc, argv);
if (error && error->code != GOT_ERR_CANCELLED &&
error->code != GOT_ERR_PRIVSEP_EXIT &&
!(sigpipe_received &&
diff --git a/tog/tog.c b/tog/tog.c
index 280413b..162cb7c 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -88,7 +88,7 @@ static const struct got_error* cmd_blame(int, char *[]);
static const struct got_error* cmd_tree(int, char *[]);
static const struct got_error* cmd_ref(int, char *[]);
-static struct tog_cmd tog_commands[] = {
+static const struct tog_cmd tog_commands[] = {
{ "log", cmd_log, usage_log },
{ "diff", cmd_diff, usage_diff },
{ "blame", cmd_blame, usage_blame },
@@ -6502,7 +6502,7 @@ list_commands(FILE *fp)
fprintf(fp, "commands:");
for (i = 0; i < nitems(tog_commands); i++) {
- struct tog_cmd *cmd = &tog_commands[i];
+ const struct tog_cmd *cmd = &tog_commands[i];
fprintf(fp, " %s", cmd->name);
}
fputc('\n', fp);
@@ -6555,7 +6555,7 @@ static const struct got_error *
tog_log_with_path(int argc, char *argv[])
{
const struct got_error *error = NULL, *close_err;
- struct tog_cmd *cmd = NULL;
+ const struct tog_cmd *cmd = NULL;
struct got_repository *repo = NULL;
struct got_worktree *worktree = NULL;
struct got_object_id *commit_id = NULL, *id = NULL;
@@ -6653,10 +6653,10 @@ int
main(int argc, char *argv[])
{
const struct got_error *error = NULL;
- struct tog_cmd *cmd = NULL;
+ const struct tog_cmd *cmd = NULL;
int ch, hflag = 0, Vflag = 0;
char **cmd_argv = NULL;
- static struct option longopts[] = {
+ static const struct option longopts[] = {
{ "version", no_argument, NULL, 'V' },
{ NULL, 0, NULL, 0}
};