[Lldb-commits] [PATCH] D44056: [lldb] Fix "code unreachable" warning in HostThreadPosix::Cancel

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 2 18:57:09 PST 2018


labath added inline comments.


================
Comment at: source/Host/posix/HostThreadPosix.cpp:44
   if (IsJoinable()) {
 #ifndef __ANDROID__
 #ifndef __FreeBSD__
----------------
xiaobai wrote:
> aprantl wrote:
> > What about:
> > ```
> > #ifdef __ANDROID__
> >     error.SetErrorString("HostThreadPosix::Cancel() not supported on Android");
> > #else
> > #ifdef __FreeBSD__
> >     int err = ::pthread_cancel(m_thread);
> >     error.SetError(err, eErrorTypePOSIX);
> > #else
> >     llvm_unreachable("someone is calling HostThread::Cancel()");
> > #endif
> > #endif
> >   }
> >   return error;
> > }
> > ```
> I agree with Adrian's suggestion, but I would add that you can remove one of the `#endif` if you use `#elif defined(__FreeBSD__)` instead of an `#else` + `#ifdef __FreeBSD__`.
I think we can just unify the __ANDROID__ and __FreeBSD__  cases (turn both into unreachable). We only run lldb-server on android, and there we're mostly single-threaded, so there shouldn't be any thread cancelling going on anyway...


https://reviews.llvm.org/D44056





More information about the lldb-commits mailing list