-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Created a History Command #5
base: master
Are you sure you want to change the base?
Conversation
Resolves #4 |
src/kernel/kshell.c
Outdated
@@ -107,6 +107,9 @@ bool alt_mode = false; | |||
bool ctrl_mode = false; | |||
bool super_mode = false; | |||
|
|||
char history_data[100][RDL_SIZE]; | |||
uint8_t tot_cmds=0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer you keep this in some sort of dynamic data structure, rather than a list - not just for cleanliness, but because this implementation is rife with data overflow opportunities. - for instance, you never bounds check on tot_cmds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have created a dynamic list to resolve the overflow problem.
src/kernel/kshell.c
Outdated
else if (!strncmp(run, "history", 7)){ | ||
for(int i=0;i<tot_cmds;i++){ | ||
write_num(i+1); | ||
kprintf(" %05s",history_data[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use 1 kprintf for this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compressed my code to 1 line kprintf.
src/kernel/kshell.c
Outdated
for (i = 0; i < rdl_index; i++) | ||
{ | ||
history_data[tot_cmds][i]=readline[i]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a memcpy implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied data using memcpy and reduced the no. of lines.
I have created the history command for SOS, which is not present. The command and output will look like below...