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=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no 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 6CEFCC43381 for ; Fri, 12 Mar 2021 21:52:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D56B64F8E for ; Fri, 12 Mar 2021 21:52:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235355AbhCLVwH (ORCPT ); Fri, 12 Mar 2021 16:52:07 -0500 Received: from mga12.intel.com ([192.55.52.136]:43337 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235288AbhCLVv5 (ORCPT ); Fri, 12 Mar 2021 16:51:57 -0500 IronPort-SDR: 75oQiYs0q8lBYyvsj4aqnLxrFGdlnp52n4j6zSaC8f8mtLA395WqqeiN4IWDe/5NI9wnbpdIwA a4kpJ8gBWEfQ== X-IronPort-AV: E=McAfee;i="6000,8403,9921"; a="168167076" X-IronPort-AV: E=Sophos;i="5.81,244,1610438400"; d="scan'208";a="168167076" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2021 13:51:47 -0800 IronPort-SDR: sEyJrDV40PbpN3UUX4MfDknCTVMh3ZsDfnCTf3oW0fZUX3PViyeFQOyP6D56iLGZVq2GfKBxd5 oZTffeEAW6Yw== X-IronPort-AV: E=Sophos;i="5.81,244,1610438400"; d="scan'208";a="510453600" Received: from otcwcpicx3.sc.intel.com ([172.25.55.73]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2021 13:51:47 -0800 Date: Fri, 12 Mar 2021 21:51:40 +0000 From: Fenghua Yu To: Babu Moger Cc: Shuah Khan , Tony Luck , Reinette Chatre , linux-kselftest , linux-kernel Subject: Re: [PATCH v5 02/21] selftests/resctrl: Fix compilation issues for global variables Message-ID: References: <20210307145502.2916364-1-fenghua.yu@intel.com> <20210307145502.2916364-3-fenghua.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Babu, On Fri, Mar 12, 2021 at 01:08:31PM -0600, Babu Moger wrote: > > From: Fenghua Yu > > Taking a closer look at the usage of these variables reveals that these > > variables are used only locally to functions such as cqm_resctrl_val() > > %s/ locally to functions/locally in two functions OK. Will change it. > > -int get_cbm_mask(char *cache_type) > > +int get_cbm_mask(char *cache_type, char *cbm_mask) > > { > > char cbm_mask_path[1024]; > > FILE *fp; > > > > + if (!cbm_mask) > > + return -1; > > Can cbm_mask be NULL? I see it is statically allocated. > Or should this be if (!(*cbm_mask))? Or did I miss something. This is a sanity checking. Although current callers do pass statically allocated cbm_mask to the parameter, future callers may incorrectly pass un-allocated cbm_mask to the parameter and may cause segmentation fault without the sanity checking. To debug this kind of issue, the sanity checking will be very helpful. So I would keep this sanity checking. Thanks. -Fenghua