From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Burakov, Anatoly" Subject: Re: [PATCH v3 2/2] eal: fix signed integers in fbarray Date: Sat, 14 Apr 2018 11:03:50 +0100 Message-ID: References: <20180413155417.29643-1-adrien.mazarguil@6wind.com> <20180413183950.17625-1-adrien.mazarguil@6wind.com> <20180413183950.17625-2-adrien.mazarguil@6wind.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org To: Adrien Mazarguil Return-path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 2EF0E1B793 for ; Sat, 14 Apr 2018 12:04:06 +0200 (CEST) In-Reply-To: <20180413183950.17625-2-adrien.mazarguil@6wind.com> Content-Language: en-US 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 13-Apr-18 7:43 PM, Adrien Mazarguil wrote: > While debugging startup issues encountered with Clang (see "eal: fix > undefined behavior in fbarray"), I noticed that fbarray stores indices, > sizes and masks on signed integers involved in bitwise operations. > > Such operations almost invariably cause undefined behavior with values that > cannot be represented by the result type, as is often the case with > bit-masks and left-shifts. > > This patch replaces them with unsigned integers as a safety measure and > promotes a few internal variables to larger types for consistency. > > Fixes: c44d09811b40 ("eal: add shared indexed file-backed array") > Cc: Anatoly Burakov > > Signed-off-by: Adrien Mazarguil > > -- > > v3 changes: > > - Added INT_MAX upper bound check in fully_validate() as suggested by > Anatoly. > - Added a sysconf() result check to appease Coverity since calc_data_size() > now takes an unsigned page size (Coverity issues 272598 and 272599). > > v2 changes: > > Removed unnecessary "(unsigned int)" cast leftovers. Acked-by: Anatoly Burakov -- Thanks, Anatoly