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=-10.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 1E8D6C43461 for ; Thu, 17 Sep 2020 17:34:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A87F12137B for ; Thu, 17 Sep 2020 17:34:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600364060; bh=Qc6oXe1rwu/T7LinCxViJXdUsnwPzOoMYiqccpITeq4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=rFByfMTwmbD59dgvzeRlGAzeGLIs2QsbVxHaFCL05yuWMz/gBKXaTCOzzDwLBZIRb PxjWnDrRohTxRyOwY6XCOoDC/WEkKVa+xkRnIEZ6rFUXavlkZ0a/e13FH7DBYUNow2 ZcJi5u6QDjkbbAyWf3bzPgFqQUZ0S0iGiMr3pE1I= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726591AbgIQRdy (ORCPT ); Thu, 17 Sep 2020 13:33:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:39068 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726587AbgIQRdv (ORCPT ); Thu, 17 Sep 2020 13:33:51 -0400 Received: from localhost (unknown [213.57.247.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 51CFB20725; Thu, 17 Sep 2020 17:33:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600364031; bh=Qc6oXe1rwu/T7LinCxViJXdUsnwPzOoMYiqccpITeq4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ea5VEhPJpY4ywn6lw0EF6nRv20t3oAb6xN/2KsFDiX3qbcWQIxDZ+zAkifceSQw6I SY4xJxHJNqNqi3jd27BJvH/xgbO8lMPz27EDZ2lMtr6BUk33e1+7+q3pNx9vKgciGk je+d95Ntl1UXP1XDh54jVssIrv5ezbY2ZcvAjA9U= Date: Thu, 17 Sep 2020 20:33:46 +0300 From: Leon Romanovsky To: Jason Gunthorpe Cc: Liu Shixin , Doug Ledford , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH -next] RDMA/mlx5: fix type warning of sizeof in __mlx5_ib_alloc_counters() Message-ID: <20200917173346.GK869610@unreal> References: <20200917082926.GA869610@unreal> <20200917091008.2309158-1-liushixin2@huawei.com> <20200917090810.GB869610@unreal> <20200917123806.GA114613@nvidia.com> <20200917170511.GI869610@unreal> <20200917172451.GK8409@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200917172451.GK8409@ziepe.ca> Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org On Thu, Sep 17, 2020 at 02:24:51PM -0300, Jason Gunthorpe wrote: > On Thu, Sep 17, 2020 at 08:05:11PM +0300, Leon Romanovsky wrote: > > On Thu, Sep 17, 2020 at 09:38:06AM -0300, Jason Gunthorpe wrote: > > > On Thu, Sep 17, 2020 at 12:08:10PM +0300, Leon Romanovsky wrote: > > > > On Thu, Sep 17, 2020 at 05:10:08PM +0800, Liu Shixin wrote: > > > > > sizeof() when applied to a pointer typed expression should give the > > > > > size of the pointed data, even if the data is a pointer. > > > > > > > > > > Signed-off-by: Liu Shixin > > > > > > Needs a fixes line > > > > > > > > if (!cnts->names) > > > > > return -ENOMEM; > > > > > > > > > > cnts->offsets = kcalloc(num_counters, > > > > > - sizeof(cnts->offsets), GFP_KERNEL); > > > > > + sizeof(*cnts->offsets), GFP_KERNEL); > > > > > > > > This is not. > > > > > > Why not? > > > > cnts->offsets is array of pointers that we will set later. > > The "sizeof(*cnts->offsets)" will return the size of size_t, while we > > need to get "size_t *". > > Then why isn't a pointer to size **? > > Something is rotten here No problem, I'll check. > > Jason