From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_PASS, USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D5D1C43387 for ; Tue, 15 Jan 2019 21:07:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D511920859 for ; Tue, 15 Jan 2019 21:07:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="q1pNR4gD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390204AbfAOVH1 (ORCPT ); Tue, 15 Jan 2019 16:07:27 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48798 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732849AbfAOVH1 (ORCPT ); Tue, 15 Jan 2019 16:07:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ab1XxmEWqRBqSdRWD5iJPz9vefweXhvyObKAnywN/Nw=; b=q1pNR4gDgKB5SoyevZ+CxZrMJ 50e/hO0CS6M8hubdG8encSMrLrBihmhGRtXjVNDVaGgPfRehYLzFxR8PusYKZKKmklJR7zDiT5361 krw06T/sWTUgLO+Es4Z3EAXAWVoUPGTdOl2hkOGDI+tjF0ox+O1zSMGy0aATPESd+t1udGUnsrdSs OH8zybwzsYmuWJi1FB0B1WE+BISfcSUvFcWOGWLUV1EY4eeg2lnCLxQ2nw9iLVQtqI4bgNCiurMtZ DYYO3JelvSAWvf1BbUBzOy+Q2WKblDR3stMGKGUBLgFiDX7ycSX21/bEX8A1WI87Tuoe8ejdLcDQE bYU5+TefQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gjVvi-0002yw-Oc; Tue, 15 Jan 2019 21:07:26 +0000 Date: Tue, 15 Jan 2019 13:07:26 -0800 From: Matthew Wilcox To: Dan Carpenter Cc: linux-fsdevel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] XArray: Fix a math problem in xa_is_err() Message-ID: <20190115210726.GC6310@bombadil.infradead.org> References: <20190115195241.GB1074@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190115195241.GB1074@kadam> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Tue, Jan 15, 2019 at 10:52:41PM +0300, Dan Carpenter wrote: > @@ -177,7 +177,8 @@ static inline bool xa_is_internal(const void *entry) > static inline bool xa_is_err(const void *entry) > { > return unlikely(xa_is_internal(entry) && > - (unsigned long)entry >= -((MAX_ERRNO << 2) + 2)); > + (unsigned long)entry >= > + (((unsigned long)(-MAX_ERRNO << 2) + 2))); > } Ugh all the brackets, I'm not surprised I got it wrong. How about this instead; does it make your static checker happy? diff --git a/include/linux/xarray.h b/include/linux/xarray.h index 7da665f5cb20..5d9d318bcf7a 100644 --- a/include/linux/xarray.h +++ b/include/linux/xarray.h @@ -177,7 +177,7 @@ static inline bool xa_is_internal(const void *entry) static inline bool xa_is_err(const void *entry) { return unlikely(xa_is_internal(entry) && - (unsigned long)entry >= -((MAX_ERRNO << 2) + 2)); + entry >= xa_mk_internal(-MAX_ERRNO)); } /** (passes sparse & gcc, but ...)