Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

mrchocha
Copy link

@mrchocha mrchocha commented Nov 8, 2020

I have created the history command for SOS, which is not present. The command and output will look like below...
Histoy_cmd

@mrchocha
Copy link
Author

mrchocha commented Nov 9, 2020

Resolves #4

@@ -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;
Copy link
Owner

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

Copy link
Author

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.

else if (!strncmp(run, "history", 7)){
for(int i=0;i<tot_cmds;i++){
write_num(i+1);
kprintf(" %05s",history_data[i]);
Copy link
Owner

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.

Copy link
Author

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.

Comment on lines 197 to 200
for (i = 0; i < rdl_index; i++)
{
history_data[tot_cmds][i]=readline[i];
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a memcpy implementation.

Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants