Skip to content

Commit

Permalink
kdb: Rename struct defcmd_set to struct kdb_macro
Browse files Browse the repository at this point in the history
Rename struct defcmd_set to struct kdb_macro as that sounds more
appropriate given its purpose.

Suggested-by: Daniel Thompson <[email protected]>
Signed-off-by: Sumit Garg <[email protected]>
Reviewed-by: Douglas Anderson <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Daniel Thompson <[email protected]>
  • Loading branch information
b49020 authored and daniel-thompson committed Jul 27, 2021
1 parent 95f7f15 commit b39cded
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions kernel/debug/kdb/kdb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,24 +654,24 @@ static void kdb_cmderror(int diag)
* Returns:
* zero for success, a kdb diagnostic if error
*/
struct defcmd_set {
struct kdb_macro {
int count;
bool usable;
char *name;
char *usage;
char *help;
char **command;
};
static struct defcmd_set *defcmd_set;
static int defcmd_set_count;
static struct kdb_macro *kdb_macro;
static int kdb_macro_count;
static bool defcmd_in_progress;

/* Forward references */
static int kdb_exec_defcmd(int argc, const char **argv);

static int kdb_defcmd2(const char *cmdstr, const char *argv0)
{
struct defcmd_set *s = defcmd_set + defcmd_set_count - 1;
struct kdb_macro *s = kdb_macro + kdb_macro_count - 1;
char **save_command = s->command;
if (strcmp(argv0, "endefcmd") == 0) {
defcmd_in_progress = false;
Expand Down Expand Up @@ -704,15 +704,15 @@ static int kdb_defcmd2(const char *cmdstr, const char *argv0)

static int kdb_defcmd(int argc, const char **argv)
{
struct defcmd_set *save_defcmd_set = defcmd_set, *s;
struct kdb_macro *save_kdb_macro = kdb_macro, *s;
if (defcmd_in_progress) {
kdb_printf("kdb: nested defcmd detected, assuming missing "
"endefcmd\n");
kdb_defcmd2("endefcmd", "endefcmd");
}
if (argc == 0) {
int i;
for (s = defcmd_set; s < defcmd_set + defcmd_set_count; ++s) {
for (s = kdb_macro; s < kdb_macro + kdb_macro_count; ++s) {
kdb_printf("defcmd %s \"%s\" \"%s\"\n", s->name,
s->usage, s->help);
for (i = 0; i < s->count; ++i)
Expand All @@ -727,13 +727,13 @@ static int kdb_defcmd(int argc, const char **argv)
kdb_printf("Command only available during kdb_init()\n");
return KDB_NOTIMP;
}
defcmd_set = kmalloc_array(defcmd_set_count + 1, sizeof(*defcmd_set),
GFP_KDB);
if (!defcmd_set)
kdb_macro = kmalloc_array(kdb_macro_count + 1, sizeof(*kdb_macro),
GFP_KDB);
if (!kdb_macro)
goto fail_defcmd;
memcpy(defcmd_set, save_defcmd_set,
defcmd_set_count * sizeof(*defcmd_set));
s = defcmd_set + defcmd_set_count;
memcpy(kdb_macro, save_kdb_macro,
kdb_macro_count * sizeof(*kdb_macro));
s = kdb_macro + kdb_macro_count;
memset(s, 0, sizeof(*s));
s->usable = true;
s->name = kdb_strdup(argv[1], GFP_KDB);
Expand All @@ -753,19 +753,19 @@ static int kdb_defcmd(int argc, const char **argv)
strcpy(s->help, argv[3]+1);
s->help[strlen(s->help)-1] = '\0';
}
++defcmd_set_count;
++kdb_macro_count;
defcmd_in_progress = true;
kfree(save_defcmd_set);
kfree(save_kdb_macro);
return 0;
fail_help:
kfree(s->usage);
fail_usage:
kfree(s->name);
fail_name:
kfree(defcmd_set);
kfree(kdb_macro);
fail_defcmd:
kdb_printf("Could not allocate new defcmd_set entry for %s\n", argv[1]);
defcmd_set = save_defcmd_set;
kdb_printf("Could not allocate new kdb_macro entry for %s\n", argv[1]);
kdb_macro = save_kdb_macro;
return KDB_NOTIMP;
}

Expand All @@ -781,14 +781,14 @@ static int kdb_defcmd(int argc, const char **argv)
static int kdb_exec_defcmd(int argc, const char **argv)
{
int i, ret;
struct defcmd_set *s;
struct kdb_macro *s;
if (argc != 0)
return KDB_ARGCOUNT;
for (s = defcmd_set, i = 0; i < defcmd_set_count; ++i, ++s) {
for (s = kdb_macro, i = 0; i < kdb_macro_count; ++i, ++s) {
if (strcmp(s->name, argv[0]) == 0)
break;
}
if (i == defcmd_set_count) {
if (i == kdb_macro_count) {
kdb_printf("kdb_exec_defcmd: could not find commands for %s\n",
argv[0]);
return KDB_NOTIMP;
Expand Down

0 comments on commit b39cded

Please sign in to comment.