[Lldb-commits] [PATCH] D111030: [lldb] [Host] Add setters for common teletype properties to Terminal

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 21 00:26:41 PDT 2021


labath accepted this revision.
labath added inline comments.
This revision is now accepted and ready to land.


================
Comment at: lldb/source/Host/common/Terminal.cpp:117
+  switch (baud_rate) {
+#if defined(B0)
+  case 0:
----------------
Out of curiosity: how does a baud rate of zero work?


================
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;
----------------
mgorny wrote:
> 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.
I like that.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111030/new/

https://reviews.llvm.org/D111030



More information about the lldb-commits mailing list