Boot2Rust icon indicating copy to clipboard operation
Boot2Rust copied to clipboard

A few more comments?

Open Etenil opened this issue 10 years ago • 2 comments

Although Rust is pretty readable to a newcomer, some of the code is quite obscure, particularly in uefi.mod. For example:

((*(*self).output).OutputString)(self.output, str);

A few comments to explain what those do would help.

Etenil avatar Nov 20 '13 08:11 Etenil

Is that necessary? If one can do self.output somewhere, (*self).output shouldn't be required, and Console could be rewritten to use &'static instead of raw pointers, but that wouldn't work because OutputString takes a raw pointer. Hmm... SimpleTextOutput could be implemented by *EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, making the code a little cleaner, but now I'm just nitpicking.

eddyb avatar Nov 20 '13 11:11 eddyb

I thought about using &'static instead of * for the EFI stuff, but I'm not sure I have a good reason to prefer one way or the other. The code will probably be cleaner with &'static, but it might be unsafer... It probably doesn't really matter, if you can't trust the UEFI code to do what it says then you probably have no hope of doing anything safely.

As far as comments, a lot of the stuff like the ((*(*self).output).OutputString)(self.output, str) is meant to be hidden in the library, so I'm not as worried about this being quite so ugly (although breaking it into multiple lines with variables holding the intermediate results might help). At the very least, we should add doc comments though.

eholk avatar Nov 20 '13 19:11 eholk