[Lldb-commits] [PATCH] D111030: [lldb] [Host] Add setters for common teletype properties to Terminal
Michał Górny via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 20 07:08:03 PDT 2021
mgorny added inline comments.
================
Comment at: lldb/source/Host/common/Terminal.cpp:316-347
+ bool parity_bit = true;
+ bool odd_bit = false;
+ bool stick_bit = false;
+
+ switch (parity) {
+ case Parity::No:
+ parity_bit = false;
----------------
labath wrote:
> I am wondering if we can avoid the double conversion (enum->bools->flags). Would something like this be shorter/cleaner:
> ```
> unsigned(?) GetParityFlagMask() {
> return PARENB | PARODD
> #ifdef CMSPAR
> | CMSPAR
> #endif
> ;
> }
> Expected<unsigned> GetParityFlags(Parity) // error if parity not supported
>
> SetParity(parity) {
> getParityFlags(parity); // and check result
> GetData(); // and check result
> data.m_termios.c_cflag &= ~GetParityFlagMask();
> data.m_termios.c_cflag |= flags;
> SetData();
> ```
TBH, I don't like the extra functions because they mean more `#ifdef`s. How do you feel about my new version? I think it might be less optimal but I think it's as readable as it gets.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111030/new/
https://reviews.llvm.org/D111030
More information about the lldb-commits
mailing list