2021-04-29 19:39 (UTC-0700), Narcisa Ana Maria Vasile:
> On Thu, Apr 29, 2021 at 03:50:38AM +0300, Dmitry Kozlyuk wrote:
> > 2021-04-02 18:39 (UTC-0700), Narcisa Ana Maria Vasile:  
> > > From: Narcisa Vasile <navas...@microsoft.com>
[...]
> > >   (*key)->thread_index = TlsAlloc();
> > >   if ((*key)->thread_index == TLS_OUT_OF_INDEXES) {
> > >           RTE_LOG_WIN32_ERR("TlsAlloc()");
> > >           free(*key);
> > > -         rte_errno = ENOEXEC;
> > > -         return -1;
> > > +         return rte_thread_translate_win32_error();  
> > 
> > Logging above can overwrite GetLastError() value.
> > I suggest splitting rte_thread_translate_win32_error() into translation part
> > for cases when you have error number already, and a wrapper that calls
> > GetLastError() to shorten calling code.
> >   
> 
>   Thanks Dmitry! I can split the translation function into something like:
>   static int rte_thread_translate_win32_error(DWORD error) {
>       switch(error) {
>           [...]
>       }
>   } 
> 
>   static int get_error_and_translate(void) {
>      return rte_thread_translate_win32_error(GetLastError());
>   }
> 
>   Is the above what you meant?
> 
>   Here, however, I don't think the wrapper over GetLastError() will be of 
> much help, as 
>   we still need to do something like:
>   if ((*key)->thread_index == TLS_OUT_OF_INDEXES) {
>        ret = GetLastError();
>        RTE_LOG(DEBUG, EAL, "TlsAlloc() failed, GetLastError()=%lu: ", ret);
>        free(*key);
>        return rte_thread_translate_win32_error(ret);
>   }

I'm afraid we don't have a choice, the logs with exact Win32 API call and its
result is very handy for debugging. Patches 4/10 and 5/10 shorten it a bit.

Reply via email to