From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9DA46A0546; Fri, 30 Apr 2021 04:39:46 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3BFB64069E; Fri, 30 Apr 2021 04:39:46 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id DF0E140395 for ; Fri, 30 Apr 2021 04:39:44 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1059) id 2162C20B7188; Thu, 29 Apr 2021 19:39:44 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2162C20B7188 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1619750384; bh=cfaedlldUieGrsQmRpnuOdpkMj4y2KtGGt4mV9qsI/w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AAMS7mvWEF7JrLGm14lE4MrVkI/japxJtqdPFGUFfXcS6oiKigUxYtSPjMG+LGhJK xMgU/4jkXsDJKvjvhyf9lqGcTtBlwcmip6Y41DZS5qw4ZinV0BQDqhrdbGOOmX12B2 eh9I+zOk6fqZuRpY37tcFzzvDb2NufnGCABPvcGM= Date: Thu, 29 Apr 2021 19:39:44 -0700 From: Narcisa Ana Maria Vasile To: Dmitry Kozlyuk Cc: dev@dpdk.org, thomas@monjalon.net, khot@microsoft.com, navasile@microsoft.com, dmitrym@microsoft.com, roretzla@microsoft.com, talshn@nvidia.com, ocardona@microsoft.com, bruce.richardson@intel.com, david.marchand@redhat.com, pallavi.kadam@intel.com Message-ID: <20210430023944.GA30300@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1617057640-24301-2-git-send-email-navasile@linux.microsoft.com> <1617413948-10504-1-git-send-email-navasile@linux.microsoft.com> <1617413948-10504-4-git-send-email-navasile@linux.microsoft.com> <20210429035038.40c9602f@sovereign> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210429035038.40c9602f@sovereign> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [dpdk-dev] [PATCH v6 03/10] windows/eal: translate Windows errors to errno-style errors X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 > > > > Add function to translate Windows error codes to > > errno-style error codes. > > > > Signed-off-by: Narcisa Vasile > > Commit topic should be "eal/windows", not "windows/eal". > > > --- > > lib/librte_eal/include/rte_thread.h | 5 +- > > lib/librte_eal/windows/rte_thread.c | 75 ++++++++++++++++++++++------- > > 2 files changed, 60 insertions(+), 20 deletions(-) > > > > diff --git a/lib/librte_eal/include/rte_thread.h b/lib/librte_eal/include/rte_thread.h > > index bfdd8e1b1..2d7b3bc05 100644 > > > @@ -87,15 +132,13 @@ rte_thread_key_create(rte_thread_key *key, > > *key = malloc(sizeof(**key)); > > if ((*key) == NULL) { > > RTE_LOG(DEBUG, EAL, "Cannot allocate TLS key.\n"); > > - rte_errno = ENOMEM; > > - return -1; > > + return ENOMEM; > > } > > (*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); } > Same applies below in this file. > > [...]