Skip to content

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

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