Skip to content

Conversation

netanelgonen
Copy link
Contributor

@netanelgonen netanelgonen commented Mar 8, 2018

Description

Incase used \r or \n inside the prints of the fault handler
fault_print_str function would only \r.
The fix is adding \n if needed

Pull request type

  • Fix

Incase used \r or \n inside the prints of the fault handler
fault_print_str function would only \r.
The fix is adding \n if needed
serial_putc(&stdio_uart, '\r');
if (fmtstr[i] == '\n') {
serial_putc(&stdio_uart, '\n');
}
Copy link
Contributor

@geky geky Mar 8, 2018

Choose a reason for hiding this comment

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

Should this just be

if(fmtstr[i] == '\r') {
     serial_putc(&stdio_uart, '\r');
     serial_putc(&stdio_uart, '\n');

and let '\r' fall through to the else statement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@geky actually no, this will cause double newline in case of the user will print something like
"hello work double newline \r\n"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and of course if use only \n you will not have any carriage return

Copy link
Contributor

@geky geky Mar 8, 2018

Choose a reason for hiding this comment

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

Oh hmm, won't this turn "\r\n" into "\r\n\r\n" in that case?

I mistyped, meant:

if(fmtstr[i] == '\n') {

In this case "\r\n" would turn into "\r\r\n", but I think the extra "\r" doesn't hurt anything?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, the current implementation will do '\r\r\n'

Copy link
Contributor

@geky geky Mar 8, 2018

Choose a reason for hiding this comment

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

oh I see, gotcha

That would be the same as this right? But with more conditionals?

if(fmtstr[i] == '\n') {
     serial_putc(&stdio_uart, '\r');
     serial_putc(&stdio_uart, '\n');

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not quite as you are discarding any \r char sent to print...
i think the outcome may be the same but in some edge cases it will cause a different issue

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, wouldn't the '\r' still go through the else statement and get printed out?

if(fmtstr[i] == '\n') {
     serial_putc(&stdio_uart, '\r');
     serial_putc(&stdio_uart, '\n');
} else {
     if(fmtstr[i]=='%') {
         hex_to_str(values[vidx++],hex_str);
         for(idx=7; idx>=0; idx--) {
             serial_putc(&stdio_uart, hex_str[idx]);
         }
     } else {
         serial_putc(&stdio_uart, fmtstr[i]);
     }
}

Copy link
Contributor

@geky geky left a comment

Choose a reason for hiding this comment

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

I think we're bikeshedding, but this is good change.

Don't let my comments block the pr

@SenRamakri
Copy link
Contributor

This is already taken care of in - #6257

@0xc0170
Copy link
Contributor

0xc0170 commented Mar 9, 2018

This is already taken care of in - #6257

👍

@0xc0170 0xc0170 closed this Mar 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants